Skip to content

Instantly share code, notes, and snippets.

@brunodutr
Created March 17, 2019 21:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brunodutr/6909f8f23196a0b8d3cd5a317cd1737b to your computer and use it in GitHub Desktop.
Save brunodutr/6909f8f23196a0b8d3cd5a317cd1737b to your computer and use it in GitHub Desktop.
package example.bdutra.jms;
import javax.ejb.ActivationConfigProperty;
import javax.ejb.MessageDriven;
import javax.inject.Inject;
import javax.jms.JMSException;
import javax.jms.Message;
import javax.jms.MessageListener;
import javax.jms.ObjectMessage;
import example.bdutra.jpa.person.PersonEntity;
import example.bdutra.jpa.person.PersonRepository;
@MessageDriven(activationConfig = {
@ActivationConfigProperty(propertyName = "destinationLookup", propertyValue = "java:/jms/queue/arquillianQueue"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"),
@ActivationConfigProperty(propertyName = "maxSession", propertyValue = "1") })
public class Listener implements MessageListener {
@Inject
private PersonRepository personRepository;
@Override
public void onMessage(Message message) {
try {
ObjectMessage objeto = (ObjectMessage) message;
PersonEntity person = (PersonEntity) objeto.getObject();
personRepository.create(person);
} catch (JMSException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment