Skip to content

Instantly share code, notes, and snippets.

@abhirockzz
Last active August 29, 2015 14:23
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 abhirockzz/2a5b50332b61ad0360ae to your computer and use it in GitHub Desktop.
Save abhirockzz/2a5b50332b61ad0360ae to your computer and use it in GitHub Desktop.
Container Managed JMS Context
@Path("email")
@Stateless
public class AwesomeEmailService {
//container managed
@Inject
JMSContext ctx;
@Resource("jms/emailQ")
Destination emailQ;
@POST
public void send(String email) {
Session session;
try {
ctx.createProducer().send(emailQ, email);
System.out.println("Message Sent to queue - " + ((Queue) emailQ).getQueueName());
} catch (JMSException ex) {
Logger.getLogger(AwesomeEmailService.class.getName()).log(Level.SEVERE, null, ex);
throw new JMSRuntimeException(ex.getMessage(), ex.getMessage(), ex);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment