How to create an MDB connected to MQ

Use a Message Driven J2EE Bean (MDB) to ‘listen’ to a queue and fire when a message arrives.  The message is removed from the queue once the MDB processes it (calls onMessage()).

 

  1. Login to admin console (right click on server, choose “Run Administrative Console”
  2. Go to Resources | Websphere MQ JMS Provider
  3. In “Additional Resources” section, choose “Websphere MQ Queue Destination”
  4. Click [New]
  5. Enter the required fields
  6. Go back to Resources | Websphere MQ JMS Provider
  7.  In “Additional Resources” section, choose “Websphere MQ Queue Connection Factories”
  8. Click [New]
  9. Enter Name, JNDI Name, Queue Manager, Host, Port, Channel, Transport Type
    e.g.
  10. Save changes in admin console
  11. Open up server configuration (double click server in Server tab)
  12. Goto EJB tab
  13. Under “Listener Ports”, click [Add…]
  14. Enter a name, and the connection factory JNDI name, and destination JNDI names you created above
  15. In J2EE Hierarchy, right click your EJB module (if you don’t have one, right click “EJB Modules”, then select New | EJB Project”), select New | Enterprise Bean
  16. Reselect your project, click [Next]
  17. Select “Message Driven Bean”, give it a name, click [Next]
  18. Enter the listener port name you created above.  Click [Finish]
  19. In your new bean, you can then put your logic in the onMessage() method, which will be called whenever a message appears in the queue.

 

Advertisements
This entry was published on December 26, 2008 at 4:18 pm and is filed under Java/J2EE, Websphere. Bookmark the permalink. Follow any comments here with the RSS feed for this post.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: