Skip navigation

Jordan Ganoff's Blog

May 2010 Previous month Next month

Here's a sneak peak at the new EventRouting API coming to the Seam 3 JMS Module:


public class RoutingConfig
   @Inject EventBridge bridge;
   @Inject @MyQueue Queue q;
   private static final AnnotationLiteral<Bridged> BRIDGED = new AnnotationLiteral<Bridged>() {};
   public Route registerBridgedRouting()
      return bridge.createRoute(EGRESS, String.class).addQualifiers(BRIDGED).connectTo(Queue.class, q);


This will replace JmsForwarding and is scheduled to be included in Seam JMS 3.0.0.Alpha2.  The nightly snapshots include a working egress implementation.  Ingress to follow shortly.  Stay tuned!

The Seam JMS module extends the CDI programming module into the messaging world.  You can now inject the full array of JMS resources, whose lifecycles that are managed transparently, into your beans and forward CDI events over JMS.  This gives you the benefits of CDI-style type-safety coupled with the power of JMS.


Resource Injection

Seam JMS aims to provide simple JMS resource injection.  The following JMS resources are now first class beans in Seam 3, allowing you to inject them as you would any other complete and type-safe bean anywhere needed!  And in addition, their life cycles are now managed too.


  • Connection
  • Session
  • Destinations (Topic, Queue)
  • Message Producer (TopicPublisher, QueueSender)
  • Message Consumer (TopicSubscriber, QueueReceiver)


Need a specific topic injected?  Let's assume you have registered the topic "jms/Topic" with your application server.  Use @JmsDestination:


@Inject @JmsDestination(jndiName="jms/Topic") Topic t;


Well that was easy but wouldn't it be better to not have to duplicate the topic name everywhere?  Create your own qualifiers for more type safety:


@Retention(RUNTIME) @Qualifier @JmsDestination("jms/Topic")
public @interface MyTopic {}


Now you can use @MyTopic in place of the @JmsDestination:


@Inject @MyTopic Topic t;
@Inject @MyTopic TopicProducer tp;


Event Forwarding

Quickly map CDI events to JMS Destinations then fire events to produce JMS messages with ease!  With a little configuration via @JmsForwarding* sending a message to JMS is this easy:


@Inject @Bridged Event<MyObject> event;
...;  // To JMS... and beyond!


* See the Arquillian tests for a sample @JmsForwarding here.

What's Next

The next few items on the list are:


  • Fire CDI events from received JMS messages (2nd half of event bridge)
  • Elaboration of event bridge configuration
  • Revise JMS resource injection implementation


Dive in and get started today and tell us what you think!  Visit the Seam 3 User Forums to participate in the discussion!


More information is available on the Seam JMS module page at Check out the documentation here.  Also related, a blog on how Arquillian has helped test the module in container can be found on the Arquillian space here.


Special note for Glassfish V3 Users:  Make sure to define a ConnectionFactory with the name "ConnectionFactory".  More details here.

Filter Blog