Last active
August 29, 2015 14:23
-
-
Save abhirockzz/2a5b50332b61ad0360ae to your computer and use it in GitHub Desktop.
Container Managed JMS Context
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
@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