Skip to content

marcuspocus/jms-demo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

README for this demo

jms-demo for Play! Framework

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 implementing javax.jms.MessageListener
  • Application.class is any class, the onMessage method just have a String parameter: The body of the javax.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

About

jms-demo using Play! Framework with Camel module

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages