Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

JMS Module

        <dependency>
            <groupId>org.jboss.seam.jms</groupId>
            <artifactId>seam-jms</artifactId>
            <version>${seam.jms.version}</version>
        </dependency>

Seam extends the CDI programming model into the messaging world by allowing you to inject JMS resources into your beans. Further, Seam bridges the CDI event bus over JMS; this gives you the benefits of CDI-style type-safety for inter-application communication.

Maintainers and contributors

Name Organization Role Hometown (Time zone)
Jordan Ganoff - Module lead Orlando, FL, USA (UTC-05)
Dan Allen JBoss, by Red Hat Advisor, contributor Laurel, MD, USA (UTC-05)

Description

The general goals can be divided into two categories: injection of JMS resources and forwarding of events.

Injection of JMS Resources

  • Connection
  • Session
  • Destinations
  • Message Producer
  • Message Consumer

Event Bridge

  • Egress: Routes CDI events to JMS destinations
  • Ingress: Fires CDI events based on the reception of JMS messages

Release plan

Version Time frame Focus
3.0.0.Alpha1 2010-05-14
  • Injection
  • Event Forwarding
3.0.0.Alpha2 TBD
  • Revised JMS Resource injection
  • Elaboration of Event Forwarding
3.0.0.Alpha-NEXT TBD
  • Ingress translation of JMS Messages to CDI Events
3.0.0.Beta1 TBD

Additional Configuration

There is currently no way to configure the ConnectionFactory URL or JNDI name Seam JMS uses; it is hardcoded as ConnectionFactory. That being said, if you're testing with Glassfish V3 you should define a ConnectionFactory by that name as follows. Thanks Dan Allen for this tip:

The prerequisite for using this on GlassFish V3 is to define a ConnectionFactory named ConnectionFactory. You can either do this through the Admin Console or this asadmin command:

Admin Console:

Resources > JMS Resources > Connection Factories New... Pool Name: ConnectionFactory Resource Type: javax.jms.ConnectionFactory OK (Accept all other defaults)

asadmin:

$GLASSFISH_HOME/bin/asadmin create-jms-resource --restype javax.jms.ConnectionFactory ConnectionFactory

That will enable the internal resource injection that Seam JMS uses:

@Resource("ConnectionFactory")
private ConnectionFactory cf;

Design notes

Destination Injection

Goal: Injection should be simple, intuitive, and type-safe.

Implemented:

@Qualifier
@Retention(RUNTIME)
@Target({ PARAMETER, METHOD, FIELD })
@JmsDestination(jndiName = "/jms/my-topic")
public @interface MyTopic {}
@Inject @MyTopic Topic t;

Planned:

SEAMJMS-2: Implement original design from spec draft from 20090520 (Page 41) where we use the producer field pattern to provide access JMS artifacts. This is much more flexible, as it allows the use of @Alternative etc:

@Resource(name="java:global/env/jms/PaymentQueue")
@Produces @PaymentProcessor Queue paymentQueue;
@Resource(name="java:global/env/jms/Prices")
@Produces @Prices Topic pricesTopic;

Event Bridge

Goal: Provide a mechanism to send/receive events transparently over JMS.

Implemented:

Bridging JMS messages and CDI events can also be done by annotated a method @EventRouting and returning Collection<Route> or Route:

@Inject EventBridge bridge;

@EventRouting
public Route eventRoutingConfig()
{
   return bridge.createRoute(EGRESS, Object.class).addQualifier(SPECIAL).connectTo(Topic.class, myTopic);
}

@EventRouting
public Collection<Route> manyRoutingConfigs()
{
   return Arrays.asList(
      bridge.createRoute(EGRESS, MyEvent.class).connectTo(Queue.class, myQueue),
      bridge.createRoute(EGRESS, LogginEvent.class).connectTo(Topic.class, eventTopic));
}

Planned:

  • SEAMJMS-5: EventBridge should be able to add and remove routings dynamically, allowing for contextual routings. For example, something triggers a route to be enabled (event, user request, etc). All subsequent events that match the route will be routed accordingly. At some later time something triggers the route to be disabled (user log off, batch process end, etc) and the routing can be removed thus preventing any further forwarding of said event types. Combined with the ability to qualify event types being routed this could prove to be fairly useful.
  • SEAMJMS-6: Change EventRouting to be produced instead of allowing any method to be annotated. Additional routes can always be registered dynamically by injecting an EventBridge.
   @Produces @EventRouting List<Route> ...
  • SEAMJMS-3 SEAMJMS-4: Routing of events - change back to original design from spec draft (as above) where we generate proxies for relevant interfaces and support the use of @Alternative on this to enable disable/disable it:
@Observes
interface JMSMapping 
{
   void myMapping(@Observes @SomeQualifier SomeType type, @MyTopic Topic topic);
}

Miscellaneous Outstanding Project Items

  • Arquillian configuration for Glassfish