Java Reference
In-Depth Information
}
@Override
public void onException(Message message, Exception
exception) {
try {
final String text =
message.getBody(String.class);
logger.info("Send failed..." + text);
} catch (Throwable e) {
logger.severe("Problem with message format");
}
}
}
During the send operation, we have to specify the asynchronous and use this listener
object. To do this, inject BookingCompletionListener to BookingQueuePro-
ducer and send messages with an updated call:
public void sendMessage(String txt) {
context.createProducer()
.setAsync(bookingCompletionListener). send(syncQueue, txt);
}
Now, appropriate listener methods will be executed when the message send is completed
or failed:
[com.packtpub.wflydevelopment.chapter6.jms.BookingCompletionListener]
(Thread-3 (HornetQ-client-global-threads-269763340)) Send
was successful: [JMS Message] User registered seat 2
Compiling and deploying the application
We have based our code on the JPA application from the previous chapter. Thanks to
javaee-api , you don't have to add any new project dependencies in order to use JMS!
The only thing you have to do is to start WildFly in full profile using, for example,
standalone-full.xml standalone-full.xml —the standard full profile con-
figuration:
Search WWH ::




Custom Search