Created
March 17, 2019 21:10
-
-
Save brunodutr/f76d0877280d9f28a41c2b27a8b4e0b9 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 static javax.ejb.TransactionAttributeType.REQUIRES_NEW; | |
import java.io.Serializable; | |
import javax.annotation.Resource; | |
import javax.ejb.TransactionAttribute; | |
import javax.jms.ConnectionFactory; | |
import javax.jms.JMSContext; | |
import javax.jms.Queue; | |
@TransactionAttribute(REQUIRES_NEW) | |
public class Producer { | |
public static final String QUEUE = "java:/jms/queue/arquillianQueue"; | |
@Resource | |
private ConnectionFactory connectionFactory; | |
@Resource(lookup = QUEUE) | |
private Queue queue; | |
public void send(Serializable object) { | |
try (JMSContext context = connectionFactory.createContext()) { | |
context.createProducer().send(queue, object); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment