Java with MQ load balancing - Websphere

This is a discussion on Java with MQ load balancing - Websphere ; Refering to the load balancing: http://www.ibm.com/developerworks/fo...29576&tstart=0 I wrote a Java code to put messages into the load balancing decks: import com.ibm.mq.*; public class MQSample { private String qManager = "QM1"; private MQQueueManager qMgr; public static void main(String args[]) { new ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: Java with MQ load balancing

  1. Java with MQ load balancing

    Refering to the load balancing:

    http://www.ibm.com/developerworks/fo...29576&tstart=0

    I wrote a Java code to put messages into the load balancing decks:

    import com.ibm.mq.*;

    public class MQSample
    {
    private String qManager = "QM1";

    private MQQueueManager qMgr;

    public static void main(String args[])
    {
    new MQSample();
    }

    public MQSample()
    {
    try
    {
    qMgr = new MQQueueManager(qManager);
    int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT ;
    MQQueue MQ1_RQSTIN = qMgr.accessQueue("QM1.RQSTIN",openOptions);
    MQMessage hello_world = new MQMessage();
    hello_world.writeUTF("Hello World!");
    MQPutMessageOptions pmo = new MQPutMessageOptions();
    MQ1_RQSTIN.put(hello_world,pmo);
    MQ1_RQSTIN.close();
    qMgr.disconnect();
    }
    catch (MQException ex)
    {
    System.out.println("A WebSphere MQ error occurred : Completion code " + ex.completionCode + " Reason code " + ex.reasonCode);
    }
    catch (java.io.IOException ex)
    {
    System.out.println("An error occurred whilst writing to the message buffer: " + ex);
    }
    }
    }

    However I am getting the error:

    MQJE001: Completion Code '2', Reason '2045'.
    A WebSphere MQ error occurred : Completion code 2 Reason code 2045

    Process completed.

    So I check the reason 2054 and the error is pointing to the open option MQC.MQOO_OUTPUT. Despite removing this option, the error still appears.

    Regards.

  2. Re: Java with MQ load balancing

    I remove this option MQC.MQOO_INPUT_AS_Q_DEF and it works

  3. Re: Java with MQ load balancing

    int openOptions = MQC.MQOO_INPUT_AS_Q_DEF | MQC.MQOO_OUTPUT ;

    Its not possible to do a single open of a queue for both input and output at the same time.

    It is possible for one thread to get and put messages on the same queue, but there must be two open instances of the queue.

    HTH,
    Glenn.

  4. Re: Java with MQ load balancing

    I tried using MQ sample apps when testing a new cluster set-up with 2 queues. The c sample that comes with the product was first used on the SunOS 5.10 machine. I ran the tool twice:

    $ /opt/mqm/samp/bin/amqsput ClusterQueueA QueueMgrA
    test1
    $ /opt/mqm/samp/bin/amqsput ClusterQueueA QueueMgrA
    test2

    and I see that the test messages were correctly distributed across the 2 queues in the cluster.
    However, when using the equivalent Java sample app (MQSample.java) I see the messages do not get distributed across the 2 cluster queues. The c code and the java code appear that they should result in the same behavior when executed. I have attempted modifying the queue-open options, and some of the put-message options, but so far have been unable to get the sample Java app to cause messages to get distributed across the cluster (with all other things being equal). I run both sample programs from the same cmd-line as the same user-id. Thanks for any assistance!

+ Reply to Thread