2011-12-05 1 views
1

私のアプリケーションはTibco RVを聞いていますが、今はWebSphere MQに切り替える必要があります。私はこのようなコードを見つけたTibco RVをWebSphere MQに切り替えますか?

Tibrv.open(Tibrv.IMPL_NATIVE); 
rvdTransport = new TibrvRvdTransport(...); 
TibrvQueue queue = new TibrvQueue(); 
cmqTransport = new TibrvCmQueueTransport(...); 
queueListener = new TibrvCmListener(...); 
disp = new TibrvDispatcher(...) 

MQ側でも同様の概念がありますか?

ありがとうございました

答えて

1

短い回答 - はい。

WMQクライアント(SupportPac MQC71)をダウンロードしてインストールすると、Javaクラス、診断ユーティリティ、および多くのサンプルコードが取得されます。サンプルプログラムの中で、あなたはこのようになりますMQSample.javaを見つける:

示すサンプルは、同期(ブロッキング) GET呼び出しを使用しますが、非同期リスナーがあるなど、JMS、C、C#の、のためにもサンプルがもちろんあります
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; 

public class MQSample { 
    public static void main(String args[]) { 
    try { 
     // Create a connection to the QueueManager 
     System.out.println("Connecting to queue manager: " + qManager); 
     MQQueueManager qMgr = new MQQueueManager(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); 

     // Define a simple WebSphere MQ Message ... 
     MQMessage msg = new MQMessage(); 
     // ... and write some text in UTF8 format 
     msg.writeUTF("Hello, World!"); 

     // Specify the default put message options 
     MQPutMessageOptions pmo = new MQPutMessageOptions(); 

     // Put the message to the queue 
     System.out.println("Sending a message..."); 
     queue.put(msg, pmo); 

     // Now get the message back again. First define a WebSphere MQ 
     // message 
     // to receive the data 
     MQMessage rcvMessage = new MQMessage(); 

     // Specify default get message options 
     MQGetMessageOptions gmo = new MQGetMessageOptions(); 

     // Get the message off the queue. 
     System.out.println("...and getting the message back again"); 
     queue.get(rcvMessage, gmo); 

     // And display the message text... 
     String msgText = rcvMessage.readUTF(); 
     System.out.println("The message is: " + msgText); 

     // Close the queue 
     System.out.println("Closing the queue"); 
     queue.close(); 

     // Disconnect from the QueueManager 
     System.out.println("Disconnecting from the Queue Manager"); 
     qMgr.disconnect(); 
     System.out.println("Done!"); 
    } 
    catch (MQException ex) { 
     System.out.println("A WebSphere MQ Error occured : Completion Code " + ex.completionCode 
      + " Reason Code " + ex.reasonCode); 
     ex.printStackTrace(); 
     for (Throwable t = ex.getCause(); t != null; t = t.getCause()) { 
     System.out.println("... Caused by "); 
     t.printStackTrace(); 
     } 

    } 
    catch (java.io.IOException ex) { 
     System.out.println("An IOException occured whilst writing to the message buffer: " + ex); 
    } 
    return; 
    } 
} 

コールバックメカニズムを実装したい場合は、メソッドを使用します。

また、Infocenterのアプリケーション開発セクションを調べることをお勧めします。 Theseはv7.0のドキュメントであり、theseはv7.1のドキュメントです。