Ravi Srinivasan
2018-09-11 b9209f6413cb6985c0089f9677f4db9b52ca1395
commit | author | age
b9209f 1 package com.redhat.training.messaging;
RS 2
3 import javax.ejb.Singleton;
4 import javax.ejb.Startup;
5 import javax.annotation.Resource;
6 import javax.jms.Queue;
7 import javax.jms.JMSContext;
8 import javax.inject.Inject;
9
10 @Startup
11 @Singleton
12 public class JMSUtil {
13
14     @Resource(mappedName = "java:jboss/jms/queue/helloWorldQueue")
15     private Queue helloWorldQueue;
16
17     @Inject
18     JMSContext context;
19
20     public void sendMessage(String msg) {
21         try {
22             context.createProducer().send(helloWorldQueue, msg);
23         }
24         catch (Exception e) {
25             e.printStackTrace();
26         }
27     }
28 }