Created
March 17, 2019 21:09
-
-
Save brunodutr/6909f8f23196a0b8d3cd5a317cd1737b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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