3

私はWebSphereMQを初めて使用します。

次のように、AIXでキュー・マネージャー、チャネル、およびリスナーを作成しました。

crtmqm MY_Q_MGR

strmqm MY_Q_MGR

runmqsc

DEFINE LISTENER(MY_QM_LISTENER) TRPTYPE(TCP) PORT(5030)

DEFINE CHANNEL(MY_QM_CHANNEL) CHLTYPE(SDR) CONNAME('10.128.1.51(5030)') XMITQ('MY_Q_MGR') DISCINT(0)

次に、QMGRが実行されていることを確認しました。procでリスナーを見ました。

次に、次のようにJavaからMQQueueManagerを作成しようとしましたが、MQJE001: Completion Code '2', Reason '2059'.

import com.ibm.mq.MQException;
import com.ibm.mq.MQGetMessageOptions;
import com.ibm.mq.MQMessage;
import com.ibm.mq.MQPutMessageOptions;
import com.ibm.mq.MQQueue;
import com.ibm.mq.MQQueueManager;
import com.ibm.mq.constants.MQConstants;
import com.ibm.mq.MQEnvironment;

public class MQSample {

  // code identifier
  static final String sccsid = "@(#) samples/wmqjava/MQSample.java, jmscc.samples, k700, k700-L080529 1.4.1.1 08/06/01 09:37:53";

    // define the name of the QueueManager
     private static final String qManager = "MY_Q_MGR";

  // and define the name of the Queue
  private static final String qName = "SYSTEM.DEFAULT.LOCAL.QUEUE";

  /**
   * Main entry point
   * 
   * @param args - command line arguments (ignored)
   */
  public static void main(String args[]) {
    try {
        MQEnvironment.hostname = "MY IP ADDRESS";
        MQEnvironment.channel = "MY_QM_CHANNEL";
        MQEnvironment.port = 5030;


      // Create a connection to the QueueManager
      System.out.println("Connecting to queue manager: " + qManager);
      System.out.println("Connecting to queue manager is finished: " + qManager);
      // Set up the options on the queue we wish to open
      int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF | MQConstants.MQOO_OUTPUT;

      // Now specify the queue that we wish to open and the open options
      System.out.println("Accessing queue: " + qName);
      MQQueue queue = qMgr.accessQueue(qName, openOptions);
      MQQueueManager qMgr = new MQQueueManager(qManager); // here i got error
      System.out.println("Connecting to queue manager is finished: " + qManager);
      // Set up the options on the queue we wish to open
      int openOptions = MQConstants.MQOO_INPUT_AS_Q_DEF | MQConstants.MQOO_OUTPUT;

      // Now specify the queue that we wish to open and the open options
      System.out.println("Accessing queue: " + qName);
      MQQueue queue = qMgr.accessQueue(qName, openOptions);

私はここで立ち往生しています。

4

1 に答える 1

7

You need a Sever connection (SVRCONN) type channel, not SDR type. A SVRCONNtype channel is required for clients applications to connect to queue manager where SDR type channel is for communication between two queue managers.

When a queue manager is created, a default SVRCONN channel, SYSTEM.DEF.SVRCONN is created. You can use this for your tests. But in production it's recommended to create your own channel and not use any predefined channels.

Please see this link for complete details what you need to do. This is from WebSphere MQ Quick Beginnings book.

于 2012-06-28T03:53:35.887 に答える