Java Reference
In-Depth Information
public static final String BOOKING_QUEUE = "java:global/
jms/bookingQueue ";
}
Then, in BookingQueueReceiver , you can just change propertyValue =
"java:jboss/jms/queue/ticketQueue" to propertyValue = Book-
ingQueueDefinition.BOOKING_QUEUE .
Adding the JMS producer
Once we're done with the JMS consumer, we need a component that will take care of
sending JMS messages. For this purpose, we will add an Application Scoped CDI Bean,
say BookingQueueProducer , which gets injected in the JMS resources:
package com.packtpub.wflydevelopment.chapter6.jms;
import javax.annotation.Resource;
import javax.enterprise.context.RequestScoped;
import javax.inject.Inject;
import javax.jms.JMSContext;
import javax.jms.Queue;
@ApplicationScoped
public class BookingQueueProducer {
@Inject
private JMSContext context;
@Resource(mappedName =
BookingQueueDefinition.BOOKING_QUEUE)
private Queue syncQueue;
public void sendMessage(String txt) {
context.createProducer().send(syncQueue, txt);
}
}
This might be a bit shocking for those who have used the previous versions of the JMS.
For those who haven't, in the following code we present this code's equivalent in JMS 1.1:
Search WWH ::




Custom Search