YOUR FEEDBACK
Tim FitzGerald wrote: As an HP distributor who specializes in virtualization solutions, we view these...
AJAXWorld RIA Conference
$300 Savings Expire September 5th. Register Today and SAVE!

SYS-CON.TV
TOP THREE LINKS YOU MUST CLICK ON


Message-Driven Beans in WebSphere
Use MQ Messaging for Many Processes

With WebSphere Application server 5.0+ you can now add Message-Driven Beans (MDBs) to your WebSphere arsenal. These beans are handy for many processes. I recently had to write a MDB using MQ Series. WebSphere Application Server (WAS) 5.0 had the same functionality built-in, but I had a hard time learning how to use it. I also encountered some issues while configuring it to run in a load-balanced environment.

First of all, there's no real way of balancing the load in a clustered environment for MDBs. All nodes in the cluster will fight for the messages as they enter the queue. This is a limitation that can't be worked around.

There's another pitfall that will affect you even if you don't plan to use load balancing. If for any reason the queue manager connection fails, your MDB will be rendered useless until someone restarts the message listener service on the application server.

That said let's build an MDB. First you'll want to get some information about the queue you're attaching to. The Queue Manager name, Host, Port, Channel name, and Queue name will most likely be enough information. You'll have to create both a Destination and a Connection Factory.

To create a destination you'll want to go to the WebSphere Console and go to: Resources - WebSphere MQ JMS Provider - a WebSphere MQ Queue Destinations. At this point you'll want to decide at which level you'd like this information to be available. If you're in a load-balanced environment there's only one that will allow all the cells to play nicely together, and that's the cell level. Choose a JNDI name and note it for later use. Then populate the appropriate queue info on the next screen.

Once you've done that we'll have to create the Queue Connection Factory. This is found at: Resources - WebSphere MQ JMS Provider - a WebSphere MQ Queue Connection Factories. Here again, if you're in a load-balanced environment, make sure to create these at the cell level. Choose a JNDI name and note it for later use. Then, on the next page, populate the queue information.

At this point we're ready for the final piece of the puzzle, we have to create a Listener Port. All this really does is take the factory and bind it to the destination, and then manage the two. To create a port, go to Application Servers - (your server's name) - Message Listener Service. Here you'll create a port and assign it a JNDI name. This JNDI name will be used by your application to talk to the port. The guts of the port is pretty straightforward, just give it the JNDI names for the Connection Factory and Destination. The rest should work with the default values. Once you have that created, go back to the Listener Ports screen.

It's here that you'll probably want to add a little extra info in case your queue manager ever needs to be rebooted or taken down for short periods. We're going to add two custom properties: "MAX.RECOVERY.RETRIES" and "RECOVERY.RETRY.INTERVAL." This will let the Listener Port retry for the specified number of tries, and wait for however long you've set the interval to between tries. The interval value is in seconds.

I've created a simple MDB that will print the contents of a message to the console. This would be a good app to start your testing with. It can be found with this article, see zip.html.

About Jonathan Forck
Jonathan Forck is a J2EE developer who has done key work on several online banking applica- tions developed for a group of banks. Jonathan has written his own imple- mentation of the security interface for WAS 5.1 and is currently working on a plug-in to the Eclipse Framework that will be a clear-text TCP/IP monitor for SSL-encrypted Web sites.

WEBSPHERE LATEST STORIES . . .
Two of the biggest launches in Rich Internet Application history took place in 2007/2008 when Adobe launched AIR 1.0 in February '08 and Microsoft launched Silverlight (September '07). At the 6th International AJAXWorld RIA Conference & Expo in October SYS-CON Events is delighted to be...
Red Hat CTO Brian Stevens, Citrix CTO Simon Crosby, Egenera CTO Pete Manca, Allen Stewart, Group Manager, Windows Virtualization at Microsoft, and Brian Duckering, Sr. Director of Products and Alliances at Symantec were the top industry executives who joined Jeremy Geelan in the 4th Fl...
IBM announced that Vantage Deluxe World Travel has increased sales and improved business operations since turning to IBM to run its Web site and online booking system. Since switching to IBM WebSphere Commerce software, Vantage Travel has reduced order-taking time by 80 percent and inc...
Mike Neil is general manager for virtualization strategy in the Windows Server Division at Microsoft. Mike is focused on the delivery of the Windows virtualization technology, including Windows Server 2008 Hyper-V, Microsoft Hyper-V Server and Virtual PC 2007. Mike also directs the tec...
The AJAX for IBM WebSphere Platform Early Program is an optionally installable product extension for IBM WebSphere Application Server Version 6.1 and WebSphere Application Server Community Edition that offers targeted, incremental new features that can make Web applications running on ...
Unify announced the expansion of its Composer for Lotus Notes solution through a partnership with CASAHL Technology. Partnering with CASAHL extends the Composer solution to include an assessment of the Lotus Notes infrastructure in order to inventory, categorize and analyze the types o...
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS
SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
Click to Add our RSS Feeds to the Service of Your Choice:
Google Reader or Homepage Add to My Yahoo! Subscribe with Bloglines Subscribe in NewsGator Online
myFeedster Add to My AOL Subscribe in Rojo Add 'Hugg' to Newsburst from CNET News.com Kinja Digest View Additional SYS-CON Feeds
Publish Your Article! Please send it to editorial(at)sys-con.com!

Advertise on this site! Contact advertising(at)sys-con.com! 201 802-3021

SYS-CON FEATURED WHITEPAPERS

ADS BY GOOGLE
BREAKING WEBSPHERE NEWS
IBM (NYSE: IBM) today announced it led all vendors worldwide in identity and access management secur...