README for this demo
jms-demo for Play! Framework
The objetive from this project is to migrate https://github.com/marcuspocus/jms-demo for PlayFramework 2.1
Based on Camel module for Play! 1
Donβt forget to run
play deps --sync
before running the app !
Creating Routes (Queues or Topics)
View the Bootstrap
class to learn how to create routes
RouteBuilder routes = new RouteBuilder(){
public void configure() throws Exception{
from("activemq:queue:myListener").id("chat").bean(MyListener.class);
from("activemq:topic:chat").id("chat").bean(Application.class, "onMessage");
}
}
MyListener.class
is a standard class implementingjavax.jms.MessageListener
Application.class
is any class, the onMessage method just have a String parameter: The body of thejavax.jms.TextMessage
will be transformed to a String.
Read Camel: Routes for more details about routes.
The add routes to CamelContext
which will manage ListenerContainer
.
ctx.addRoutes(routes);
You get access to CamelContext
using Injection
@Inject static CamelContext ctx;
To send messages from Controllers
, Jobs
, or Mailer
classes, you have access to JmsTemplate
via @Inject annotation:
@Inject private static JmsTemplate jms;
To send to a topic donβt forget to set:
jms.setPubSubDomain(true)
1 Not yet released on Play! modules repository