main website home
  • About this blog

    This blog features updates, opinions, and technical notes from Caucho engineers about Caucho products, the enterprise Java industry, and PHP. Caucho Technology is the creator of the Resin Application Server and the Quercus PHP in Java engine. A leader in Java performance since 1998, Caucho is a Sun JavaEE licensee with over 9000 customers worldwide.
  • Tags

    ajaxworld bam candi cdi cloud cluster comet configuration deploy devoxx eclipse ejb embedded flash flex google app engine hessian hmtp ioc java ee 6 javaone javazone jms messaging newsletter nyjug osgi php pomegranate quercus resin resin 4.0 REST servlet sfjug silicon valley code camp spring testing training tssjs watchdog webbeans web profile websockets wordpress
  • Meta

    • Register
    • Log in
    • Entries RSS
    • Comments RSS
    • WordPress.org
« @PooledBean attributes
Resin 4.0.7 »

Updating message beans

As part of our review of EJB in working on passing the JavaEE 6 TCK for the Web Profile, we’ve been talking about how we’d like to improve the next generation of EJB message driven beans for JavaEE 7.

Message driven beans hook up application code to reliably receive messages from a messaging queue, like a heavyweight order-fulfilment system for a retail/manufacturing site. The application’s listener beans receive messages, process the message, and then ask the queue for the next message. Like the pooled bean, message-driven beans use a pool of Java classes to process several messages at once, while limiting the total concurrency to something like 5 simultaneous messages.

We’d like to simplify the application listener to queue selection, and support application objects better, rather than keeping tied to the JMS Message interface. If we do this right, we’ll encourage more focused code, and more flexible configuration. The basic tool is to take the CDI @Observes as a design idea.

The CDI @Observes registers an application method as a listener for CDI Events. For message-driven beans, we want to do the same thing for messages. So we need to select the objects we’re interested in, and select the queue we’re attaching to. The application code would look something like:


@BlueQueue
void onMessage(@MessageObserves BlueMessage message);

The @MessageObserves marks the onMessage as a queue listener. The BlueMessage selects the kinds of messages we’re able to support, making the messaging system dispatch to the proper application method, rather than forcing the application itself to select messages.

The @BlueQueue is an application-specific CDI qualifier that selects the configured queue. The CDI qualifier is important because we want to select the queue logically, by its function in our application, not by an arbitrary name.

With this design, message-driven beans would be a CDI extension. When the MDB system sees a @MessageObserves annotation, it looks up a queue specified by the @BlueQueue qualifier, and creates the MDB pooled beans as listeners for queue events.

In our brainstorming session, we thought the queue selection by the functional qualifier would make configuration more flexible (unlike the fairly rigid @ActivationSpec annotation), and the method type would more clearly expose the application intent, unlike the opaque Message object of JMS.

This entry was posted on Friday, May 21st, 2010 at 10:33 am and is filed under Uncategorized. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

Leave a Reply

You must be logged in to post a comment.


Caucho Technology is proudly powered by WordPress and Quercus®
Entries (RSS) and Comments (RSS).

  • HOME |
  • CONTACT US |
  • DOCUMENTATION |
  • BLOG |
  • WIKI 4 |
  • WIKI 3 |
  • Resin: Java Application Server
Copyright (c) 1998-2012 Caucho Technology, Inc. All rights reserved.
caucho® , resin® and quercus® are registered trademarks of Caucho Technology, Inc.
resin® is a cloud optimized, java® application server that supports the java ee webprofile ®