Adam Bien's Weblog
(Asynchronous :-)) AJAX/RESTFul Java EE Integration With Glassfish And Others - Installation And Smoke Test (with GF v2)
Short announcement, great feature. OpenMQ 4.3, which will come with Glassfish 2.1, includes a REST-Style API for JMS messaging. This features is delivered as a reusable, single WAR (imqums.war). It can be even easily backported to an existing Glassfish installation:
- Install openMQ 4.3 (it's painless - only few clicks required). This is only required to get the WAR: imqums.war
- Go to the installation directory and copy [openMQ43]\mq\lib\imqums.war into your Glassfish v2 autodeployment ([glassfish-v2]\domains\domain1\autodeploy) directory.
- Launch the sample with: http://localhost:8080/ums/
- Start the example.
The sample application will create destinations for you on the fly. These are "physical" queues. You only have to create a logical queue in the admin console (approx. 3 clicks) - and then you are able to receive JSON messages with a ...Message Driven Bean. The Message Driven Bean has to be mapped to the logical queue (the mapped name):
@MessageDriven(mappedName = "ajax", activationConfig = {
@ActivationConfigProperty(propertyName = "acknowledgeMode", propertyValue = "Auto-acknowledge"),
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue")
})
public class AJAXListenerBean implements MessageListener {
@EJB
private MessageConsumer consumer;
public void onMessage(Message msg) {
TextMessage tm = (TextMessage) msg;
try {
String message = tm.getText();
consumer.consume(message);
} catch (JMSException ex) {
throw new EJBException("Cannot receive payload : " +ex,ex);
}
}
}
The REST-API is simple, concise and Java-independent per definition. It is perfectly suitable for integration of non-Java clients with enterprise applications (AJAX, Perl, PHP etc.). Even load / extraction jobs, or monitoring could be easily implemented with the UMS.
[The sample is borrowed from the book, which I currently write :-)].
Posted at 09:00AM Feb 04, 2009 by Adam Bien in Productive Java EE - Rethinking Best Practices | Kommentare[7]
[my tweets]
Rss My book: Real World Java EE - Rethinking Best Practices


Will the book be translated into English?
Gesendet von viggo am February 04, 2009 at 10:47 AM CET #
Hi Viggo,
sorry, it will be not translated - I write it in English :-),
regards,
adam
Gesendet von Adam Bien am February 04, 2009 at 04:24 PM CET #
Great!!! Hope you will announce it when it's ready ;)
Gesendet von Viggo am February 04, 2009 at 07:25 PM CET #
Great to know yours next book will be in English
Gesendet von Kenneth am February 05, 2009 at 04:20 AM CET #
openMQ's HTTP API may be useful, but "RESTful" it's certainly not.
Gesendet von Stefan Tilkov am February 05, 2009 at 04:48 PM CET #
Hello Adam,
Interesting article.
Would you be interested in reviewing Fusion (http://fusion.codeglide.com) in your blog?
It is an open source Enterprise Integration platform.
Thank you!
Mark
Gesendet von Mark Giuliani am February 09, 2009 at 05:44 PM CET #
Hi Adam,
it is really great reusable component. I download and deploy it to glassfish and test the examples without any problems.
But i have one problem. when i create a destination (Queue type) on glassfish and send a message from a jms client (that i had developed before) the example RecieveMsg.html does not recieve the message.
is it normal?
Gesendet von Alperen am July 02, 2009 at 10:40 AM CEST #