|
RSS Feed - WebSphere MQ Support
|
RSS Feed - Message Broker Support
|
 |
|
How to set up 2-way-connection between WAS and MQ? |
« View previous topic :: View next topic » |
Author |
Message
|
fredand44 |
Posted: Sun Feb 19, 2006 11:43 pm Post subject: How to set up 2-way-connection between WAS and MQ? |
|
|
Acolyte
Joined: 14 Feb 2006 Posts: 63
|
Hello!
We are trying to learn about WebSphere Application Server 6.0 and WebSphere MQ.
Our goal is to be able to set up a queue at WebSphere MQ and put messages to it from a javaapplication at a WebLogic Server 8.1 and get the messages from ajavaapplication at a WebSphere Application Server 6.0.
To start with we would like to be able to manage this just with 2 WebSphere Application Servers on 2 machines.
We have set up our system like the image (see url below) at 1 machine. In this environment we have been able to send a message from jms/WSQueue to MQQueueRec. But we have not been able to send a message from MQQueueSend to jms/WSQueue2. (The arrows in the image defines what we think is refreence between items. The diamonds defines what we think is aggregate between items.) Hopefully all needed information is added to the image. Please ask if there is anything that you think is missing to give us an comment.
Image at:
http://www.dsv.su.se/~fr-ander/images/Overview.jpg
Now we got a couple of questions.
1) Do you see why we do not manage to send a message from the MQ side to the WAS side?? Have we missed anything?
2) To me this looks like alot of components. Do we really need to manually set up all of this?? Is there any easier way? Perhaps the use of "WebSphere MQ messaging provider" does something of this for us or am I wrong???
3) Suppose we should set up one more queueu at the Queue Manager, is there any components we could reuse?
4) Is there any component on the image that is unnecesseray that we do not need? I have not understand what the "Default messaging - JMS activation specification" is doing?
Code snippet from JSP-page for send:
try
{
String JMSCF_JNDI_NAME = "jms/WSFactory";
String JMSQ_JNDI_NAME = "jms/WSQueue";
InitialContext initCtx = new InitialContext();
javax.jms.ConnectionFactory qcf = (javax.jms.ConnectionFactory) initCtx.lookup(JMSCF_JNDI_NAME);
Destination q = (Destination) initCtx.lookup(JMSQ_JNDI_NAME);
Connection connection = qcf.createConnection();
Session ssession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer queueSender = ssession.createProducer(q);
TextMessage outMessage = ssession.createTextMessage();
outMessage.setText(messageText);
outMessage.setJMSType("package_received");
outMessage.setJMSDestination(q);
queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
queueSender.send(outMessage);
connection.close();
System.out.println("Send completed");
}
catch(Exception e)
{
e.printStackTrace();
}
Code snippet from JSP-page for receive:
try
{
String JMSCF_JNDI_NAME = "jms/WSFactory";
String JMSQ_JNDI_NAME = "jms/WSQueue2";
InitialContext initCtx = new InitialContext();
javax.jms.ConnectionFactory qcf = (javax.jms.ConnectionFactory) initCtx.lookup(JMSCF_JNDI_NAME);
Destination q = (Destination) initCtx.lookup(JMSQ_JNDI_NAME);
Connection connection = qcf.createConnection();
Session ssession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer queueReceiver = ssession.createConsumer(q);
connection.start();
Message message = queueReceiver.receiveNoWait();
if (message != null)
{
if (message instanceof BytesMessage)
{
byte[] bytes = new byte[2000];
((BytesMessage)message).readBytes(bytes);
messageText = new String(bytes);
}
else if (message instanceof MapMessage)
{
messageText = (String) ((MapMessage)message).getObject("messageString");
}
else if (message instanceof ObjectMessage)
{
messageText = (String) ((ObjectMessage)message).getObject();
}
else if (message instanceof StreamMessage)
{
messageText = ((StreamMessage)message).readString();
}
else if (message instanceof TextMessage)
{
messageText = ((TextMessage)message).getText();
}
}
System.out.println(message);
queueReceiver.close();
ssession.close();
connection.close();
System.out.println("Recv completed");
jmsQueueReceiveManager.terminate();
}
catch(Exception e)
{
e.printStackTrace();
}
All comments are welcome!
Best regards
Fredrik |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Feb 20, 2006 6:21 am Post subject: Re: How to set up 2-way-connection between WAS and MQ? |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
fredand44 wrote: |
Hello!
We are trying to learn about WebSphere Application Server 6.0 and WebSphere MQ.
Our goal is to be able to set up a queue at WebSphere MQ and put messages to it from a javaapplication at a WebLogic Server 8.1 and get the messages from ajavaapplication at a WebSphere Application Server 6.0.
To start with we would like to be able to manage this just with 2 WebSphere Application Servers on 2 machines.
We have set up our system like the image (see url below) at 1 machine. In this environment we have been able to send a message from jms/WSQueue to MQQueueRec. But we have not been able to send a message from MQQueueSend to jms/WSQueue2. (The arrows in the image defines what we think is refreence between items. The diamonds defines what we think is aggregate between items.) Hopefully all needed information is added to the image. Please ask if there is anything that you think is missing to give us an comment.
Image at:
http://www.dsv.su.se/~fr-ander/images/Overview.jpg
Now we got a couple of questions.
1) Do you see why we do not manage to send a message from the MQ side to the WAS side?? Have we missed anything? |
You need to read thoroughly the JMS provider chapter for WAS 6.0. It is quite different from 5.x and the same assumptions do not apply. In WAS 6.0 you do no longer talk to "MQ" but only to the SI Bus's JMS engine. You set up MQ as a foreign Bus and MQ acts as another qmgr in your network. This means that you never read from MQ only from the bus. You need to send any message destined to WAS to the qmgr representing the WAS SI Bus...
fredand44 wrote: |
2) To me this looks like alot of components. Do we really need to manually set up all of this?? Is there any easier way? Perhaps the use of "WebSphere MQ messaging provider" does something of this for us or am I wrong??? |
If you use the SI Bus and define it in the right scope (cell?) all WAS machines in the scope will be able to access the queues defined on the SI Bus JMS engine.
fredand44 wrote: |
3) Suppose we should set up one more queueu at the Queue Manager, is there any components we could reuse? |
You should be able to reuse all components that are not queues. The channels don't change. Think of the patterns as being request/reply from WAS to MQ.
fredand44 wrote: |
4) Is there any component on the image that is unnecesseray that we do not need? I have not understand what the "Default messaging - JMS activation specification" is doing? |
The JMS activation Specification is the new way you link the queue to the MDB. Read up on the 6.0 manual. It explains it better than I can. (RTFM )
fredand44 wrote: |
Code snippet from JSP-page for send:
try
{
String JMSCF_JNDI_NAME = "jms/WSFactory";
String JMSQ_JNDI_NAME = "jms/WSQueue";
InitialContext initCtx = new InitialContext();
javax.jms.ConnectionFactory qcf = (javax.jms.ConnectionFactory) initCtx.lookup(JMSCF_JNDI_NAME);
Destination q = (Destination) initCtx.lookup(JMSQ_JNDI_NAME);
Connection connection = qcf.createConnection();
Session ssession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageProducer queueSender = ssession.createProducer(q);
TextMessage outMessage = ssession.createTextMessage();
outMessage.setText(messageText);
outMessage.setJMSType("package_received");
outMessage.setJMSDestination(q);
queueSender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
queueSender.send(outMessage);
connection.close();
System.out.println("Send completed");
}
catch(Exception e)
{
e.printStackTrace();
}
Code snippet from JSP-page for receive:
try
{
String JMSCF_JNDI_NAME = "jms/WSFactory";
String JMSQ_JNDI_NAME = "jms/WSQueue2";
InitialContext initCtx = new InitialContext();
javax.jms.ConnectionFactory qcf = (javax.jms.ConnectionFactory) initCtx.lookup(JMSCF_JNDI_NAME);
Destination q = (Destination) initCtx.lookup(JMSQ_JNDI_NAME);
Connection connection = qcf.createConnection();
Session ssession = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
MessageConsumer queueReceiver = ssession.createConsumer(q);
connection.start();
Message message = queueReceiver.receiveNoWait();
if (message != null)
{
if (message instanceof BytesMessage)
{
byte[] bytes = new byte[2000];
((BytesMessage)message).readBytes(bytes);
messageText = new String(bytes);
}
else if (message instanceof MapMessage)
{
messageText = (String) ((MapMessage)message).getObject("messageString");
}
else if (message instanceof ObjectMessage)
{
messageText = (String) ((ObjectMessage)message).getObject();
}
else if (message instanceof StreamMessage)
{
messageText = ((StreamMessage)message).readString();
}
else if (message instanceof TextMessage)
{
messageText = ((TextMessage)message).getText();
}
}
System.out.println(message);
queueReceiver.close();
ssession.close();
connection.close();
System.out.println("Recv completed");
jmsQueueReceiveManager.terminate();
}
catch(Exception e)
{
e.printStackTrace();
}
All comments are welcome!
Best regards
Fredrik |
Like I said WAS no longer talks to MQ directly... only through the JMS Engine. So why would you expect to be able to read from the SI Bus's JMS Engine if the message is on a local queue on MQ? Have it go to a remote queue on MQ that sends it to a second queue on the SI Bus's JMS engine and read that one. Maybe you'll be able to retrieve it then.
And you DO need to read the 6.0 manual about the JMS parts...  _________________ MQ & Broker admin |
|
Back to top |
|
 |
fredand44 |
Posted: Mon Feb 20, 2006 7:08 am Post subject: Please take a look at this... |
|
|
Acolyte
Joined: 14 Feb 2006 Posts: 63
|
Hello!
Thanks for your reply!
I DO will read the manual at once.
But I will just say that we now are able to put a message on to the MQQueueSend and read it from jms/WSQueue2. I guess we are doing it the way you suggest??
We have updated the image with some more info at:
http://www.dsv.su.se/~fr-ander/images/Overview.jpg
May I ask you to take a look at the image again and see if you would set up a connection like this between WAS and MQ?? If not please say what you think is wrong. (OBS just the green and the orange items)
Our next goal is to read messages from MQQueueRec. Messages at this queue is sent from jms/WSQueue. Now we will try to reda them from weblogic. The weblogic items are gray.
We will soon add one more question about weblogic.
Best regards
Fredrik |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Feb 20, 2006 7:18 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Your topology still looks awfully confusing to me. Suggestion:
In Green the WAS SI Bus with all its queues.
Attached to specific queues (for message retrieval through MDB) the activation
In mixed: Queues pointing to the "other" side (green top orange bottom)
In Orange MQ QMGR and local queues
In mixed: Queues pointing to the other side (orange top green bottom)
Channels: (from foreign bus to MQ and MQ to foreign bus) (mixed)
Channels: within the MQ network (orange).
Hope this helps clean up a bit the picture and make it more understandable.
Hope you'll have a great time reading the manuals and redbooks.
Enjoy
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
|
|
 |
|
Page 1 of 1 |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|