Java Reference
In-Depth Information
"activemq-rar-5.9.0.rar" (runtime-name :
"activemq-rar-5.9.0.rar")
Consuming ActiveMQ messages
Well done! The hardest part is done. Now in order to consume JMS messages sent by the
ActiveMQ broker, we will add a @ResourceAdapter annotation to a message-driven
bean. This MDB will intercept bookings from the ActiveMQ broker. In order to be able to
use the @ResourceAdapter annotation, we will need to add a JBoss-specific depend-
ency to our pom.xml :
<dependency>
<groupId>org.jboss.ejb3</groupId>
<artifactId>jboss-ejb3-ext-api</artifactId>
<version>2.1.0</version>
<scope>provided</scope>
</dependency>
Our new annotated message bean is presented as follows (note that the property des-
tinationType is the destination now):
@MessageDriven(name = "MDBService", activationConfig = {
@ActivationConfigProperty(propertyName =
"destination",
propertyValue = "java:jboss/activemq/queue/
TicketQueue"),
@ActivationConfigProperty(propertyName =
"destinationType",
propertyValue = "javax.jms.Queue"),}
)
@ResourceAdapter(value="activemq-rar-5.9.0.rar")
public class BookingQueueReceiver implements
MessageListener {
@Inject
private Logger logger;
@Override
public void onMessage(Message message) {
Search WWH ::




Custom Search