Java Reference
In-Depth Information
@ActivationConfigProperty(propertyName =
"destinationType",
propertyValue = "javax.jms.Queue"),}
)
public class BookingQueueReceiver implements
MessageListener {
@Inject
private Logger logger;
@Override
public void onMessage(Message message) {
try {
final String text =
message.getBody(String.class);
logger.info("Received message " + text);
} catch (JMSException ex) {
logger.severe(ex.toString());
}
}
}
Here we have connected the MDB to our
ticketQueue
destination
[1]
bound at
java:jboss/jms/queue/ticketQueue
. The purpose of this component will be to
trace the message receipt via
java.util.Logger
.
Java EE 7 introduces an additional way of the queue definition. Now, you don't have to
add a queue from the application server management tool. It is possible to define queues
and their properties in the code using some basic annotations:
package com.packtpub.wflydevelopment.chapter6.jms;
import javax.jms.JMSDestinationDefinition;
@JMSDestinationDefinition(
name =
BookingQueueDefinition.BOOKING_QUEUE
,
interfaceName = "javax.jms.Queue"
)
public class BookingQueueDefinition {