Eclipse or SUNrise...

Eclipse or SUNrise...
...JAVA for sure

Wednesday, September 29, 2010

Configuration of WebSphere Application Server with WebSphere MQ to implement Message Driven Beans part 1

In my last post I showed how to use DataPower Appliance in WebSphere MQ environment. Now I'll show you how to configure WebSphere Application Server to use MQ. This is first part of the configuration, the second part will deal with a sample implementation of Message Driven Bean which will be deployed on WAS.

I will not cover the MQ itself, I assume that you already have a Queue Manager with proper queues up and running. Preparing WebSphere MQ is a topic of its own, If you would like me to post an article about it write to me.

Anyway, let's get stared. What we want to achieve is to deploy an MDB on WAS which uses JMS over MQ to send messages. To prepare environment for the MDB log on to the WAS console. Oh, and one important thing though. I will use EJB2.1 standard, not the most recent one. Why? Well, commercial software - like WAS in opposite to open source is
evolving much slower. There are many reasons for that, but I don't want to deal with it now. One of them reason (technical) is that currently many people want to use WAS6.1, not the current WAS7.0. The older WAS6.1 has an ability to implement EJB3.0 by feature pack but the base product sticks to original J2EE 1.4 spec, plus a feature pack is not a 100% satisfactory solution (using it can cause another issues and so forth).

Let's start then. First we need a connection factory to connect to Queue Manager; this one will be used for the listeners which raise the MDB instance. In the WebSphere Application Console go to:
Resources > JMS > Connection factories. Now select appropriate WebSphere scope (if you don’t know which one, choose the cell scope and click new. Select the WebSphere MQ messaging provider as your provider and fill the information bellow:

  • Name (EmdebConnectionFactory)

  • JNDI name (jms/EmdebConnectionFactory)

  • Queue manager (Name of your QM)

  • Transport (Client)

  • Hostname (Hostname or IP of your QM)

  • Port (Port of your QM, 1414 if default)

  • Server connection channel (Channel name of your QM)


If the QM is secured you will also need to create a JAAS user alias providing a user name and his password and then selecting it in Component-managed authentication alias or Container-managed authentication alias depending what you need in the J2EE application.

Listener

To add a Listener you have to click through: Application servers > name of the server > Message listener service > Listener Ports and click New. Input the following information (you can use your own names). Note that the Initial State of the listener is started by default. It is useful in a debug environment but can cause trouble when we initially start the application and there are invalid messages in the queue or the connection to the Queue Manager cannot be established.



Connection factory for the MDB sender

The configuration is similar to the listener connection factory; I will only use different JNDI names:

  • Name (EmdebOutConnectionFactory)

  • JNDI name (jms/EmdebOutConnectionFactory)


This is what you should achieve in the WebSphere administrative console view after creating both connection factories:



Input queue for the listener connection factory
To create input queue, you have to select ‘Queues’ link bellow the ‘Connection factories’ link. Apply these values to add a new queue (remember to select the same scope):

  • Select JMS resource provider (WebSphere MQ messaging provider)

  • Name (EmdebInQueue)

  • JNDI name (jms/ EmdebInQueue)

  • Base queue name (MDB.IN)


Output queue for the MDB sender

  • Select JMS resource provider (WebSphere MQ messaging provider)

  • Name (EmdebOutQueue)

  • JNDI name (jms/ EmdebOutQueue)

  • Base queue name (MDB.OUT)


After creating both queues, you should see as follows:



And that's all for now. We prepared our WebSphere App Server to host the MDB. In the next part I will show how to create a sample MDB using Eclipse IDE.

No comments: