How to set up 2-way-connection between WAS and MQ? - Websphere

This is a discussion on How to set up 2-way-connection between WAS and MQ? - Websphere ; 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 ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: How to set up 2-way-connection between WAS and MQ?

  1. How to set up 2-way-connection between WAS and MQ?

    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_PERSI STENT);
    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!
    (This question is also posted at http://www.mqseries.net/phpBB2/index.php)

    Best regards
    Fredrik

  2. Re: How to set up 2-way-connection between WAS and MQ?

    Actually now we are able to send a message from rfutil.exe. But with the rfutil-tool we need reading a file, and setting the jms-type to text and we then are able to read a Bytemessage, strange!!

    But it do works!

    Please se our new question about weblogic.

  3. Re: How to set up 2-way-connection between WAS and MQ?

    > Please se our new question about weblogic.

    Probably it's best to ask about interacting with this or other non-IBM
    products at www.mqseries.net - you will probably find more expertise on
    these products there.

    Regards,
    Martin



+ Reply to Thread