|
YOUR FEEDBACK
Did you read today's front page stories & breaking news?
SYS-CON.TV |
TOP THREE LINKS YOU MUST CLICK ON WebSphere Message-Driven Beans in WebSphere
Use MQ Messaging for Many Processes
By: Jonathan Forck
Oct. 3, 2005 11:00 AM
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.
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. WEBSPHERE LATEST STORIES . . .
SUBSCRIBE TO THE WORLD'S MOST POWERFUL NEWSLETTERS SUBSCRIBE TO OUR RSS FEEDS & GET YOUR SYS-CON NEWS LIVE!
|
SYS-CON FEATURED WHITEPAPERS MOST READ THIS WEEK BREAKING WEBSPHERE NEWS
|
||||||||||||||||||||||||||||