(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 :-)].
Will the book be translated into English?
Posted by viggo on February 04, 2009 at 11:47 AM CET #
Hi Viggo,
sorry, it will be not translated - I write it in English :-),
regards,
adam
Posted by Adam Bien on February 04, 2009 at 05:24 PM CET #
Great!!! Hope you will announce it when it's ready ;)
Posted by Viggo on February 04, 2009 at 08:25 PM CET #
Great to know yours next book will be in English
Posted by Kenneth on February 05, 2009 at 05:20 AM CET #
openMQ's HTTP API may be useful, but "RESTful" it's certainly not.
Posted by Stefan Tilkov on February 05, 2009 at 05: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
Posted by Mark Giuliani on February 09, 2009 at 06: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?
Posted by Alperen on July 02, 2009 at 12:40 PM CEST #
Hi,
I manage to deploy the war archive and have the url http://localhost:38080/ums/ running.
But when I POST a receive request I get:
com.sun.messaging.ums.service.UMSServiceException: java.lang.ClassNotFoundException: com.sun.messaging.ums.readonly.impl.receive
Can you please tell me What do I missed?
Posted by Cristina Laura Prohaska on January 31, 2012 at 12:06 PM CET #
Hi,
Managed to bypass the error, I have tested using a browser GET.
One more error i have when running imqums in a cluster GF environment. Does UMS support clustered mode?
Thank you,
Cristina
Posted by Cristina Laura Prohaska on February 06, 2012 at 04:01 PM CET #