IBM Process Server での JMS MQ バインディングの使用

WebSphere® MQ を使用している際にメッセージ駆動型ルール Bean を呼び出すには、カスタム・データ・バインディングを使用して JMS オブジェクト・メッセージをバインドする必要があります。

このタスクについて

クライアント・アプリケーションは、IBM® Process Server 内で稼働でき、WebSphere MQ を JMS プロバイダーとして使用してメッセージ駆動型ルール Bean を呼び出すことができます。

メッセージ駆動型ルール Bean は JMS オブジェクト・メッセージのペイロードとして java.util.Map を必要としますが、クライアント・アプリケーションはビジネス・オブジェクトを必要とします。デフォルトの JMS データ・バインディングはこれを適切にシリアライズできません。このため、java.util.Map インスタンスをビジネス・オブジェクト表現にマップするカスタム JMS データ・バインディングを作成する必要があります。

以下に、Point-to-Point メッセージング・モデルを使用したカスタム・データ・バインディングの例を示します。

手順

カスタム・データ・バインディングを実装し、このバインディングを IBM Process Server で使用するには、以下のようにします。

  1. com.ibm.websphere.sca.jms.data.JMSDataBinding インターフェースを実装します。

    そのようなクラスのスケルトンを以下に示します。

    import javax.jms.JMSException;
    import javax.jms.Message;
    
    import com.ibm.websphere.sca.jms.data.JMSDataBinding;
    import commonj.connector.runtime.DataBindingException;
    import commonj.sdo.DataObject;
    
    public class CustomerApplicationDataBinding implements JMSDataBinding {
    
    public int getMessageType() {return 0;}
    public void read(Message arg0) throws JMSException {}
    public void write(Message arg0) throws JMSException {}
    public boolean isBusinessException() {return false;}
    public void setBusinessException(boolean arg0) {}
    public DataObject getDataObject() throws DataBindingException {return null;}
    public void setDataObject(DataObject arg0) throws DataBindingException {}
    }
  2. 以下に示す getMessageType() メソッド、read(Message arg0) メソッド、および write(Message arg0) メソッドの実装を使用して、CustApplication ビジネス・オブジェクトを java.util.HashMap にマップします。
    public int getMessageType() {
       return JMSDataBinding.OBJECT_MESSAGE;
    }
    public void write(Message message) throws JMSException {
       try {
            ObjectMessage requestMessage = queueSession.createObjectMessage();
            // Set the mandatory Rule Execution Server JMS properties.
            requestMessage.setStringProperty("ilog_rules_bres_mdb_rulesetPath", rulesetPath);
            requestMessage.setStringProperty("ilog_rules_bres_mdb_status", "request");
            // Mandatory to get a reply message with the result of the rules execution.
            requestMessage.setJMSReplyTo(replyTo);
            // Set the ruleset parameters.
            HashMap<String, String> parametersIn = new HashMap<String, String>();
            CustApplication customerApplication = convertSDOCustApplication(customerApplicationSdo);
            parametersIn.put("CustomerApplication", customerApplication);
            requestMessage.setObject(parametersIn);
            // Send the message.
            queueSender.send(requestMessage); 
       } catch (DataBindingException e) {
       throw new JMSException(e.getLocalizedMessage());
    }
    }
    public void read(Message message) throws JMSException {
       //Get the payload of the JMS Object message.
       ObjectMessage responseMessage = (ObjectMessage) msg;
       HashMap parametersOut = (HashMap) responseMessage.getObject();
       // Get the number of rules fired.
       str.append("¥nThere are "
            + parametersOut.get("ilog.rules.firedRulesCount")
            + " rules executed¥n");
       // Get the value of the output report parameter.
       String report = (String) parametersOut.get("report");
       CustApplication outCustomerApplication =
            (CustApplication) (parametersOut.get("CustomerApplication"));
       // Create the business object.
       DataObject dobject = convertToSDOCustApplication(outCustomerApplication);
       try {
            // Set the data object
            setDataObject(dobject);
       } catch (DataBindingException e) {
    throw new JMSException(e.getLocalizedMessage());
    }
    }

    これで、IBM Process Server で JMS インポートを作成できます。

  3. 「インポート」を右クリックし、「バインディングの生成」>「メッセージング・バインディング」>「MQ JMS バインディング」をクリックします。

    「WebSphere MQ JMS インポート・サービスの構成」ウィザードが開きます。

  4. 「エンドポイント構成」の下で、「事前構成メッセージング・プロバイダー・リソースを使用する」を選択してから、接続ファクトリーの JNDI 名、送信先の JNDI 名、受信先の JNDI 名を入力します。
  5. 「選択」をクリックして、デフォルト・データ・フォーマットを選択します。

    「データ変換構成」ダイアログが開きます。

  6. 「OK」をクリックします。
  7. 「選択」をクリックして、ワークスペースからカスタム・データ・バインディング・クラスを見つけます。
  8. セキュリティー構成のチェック・ボックスをクリアし、「終了」をクリックします。

    MQ JMS インポートが生成されます。

タスクの結果

WebSphere MQ を使用した Point-to-Point メッセージングに必要なリソースの統合方法について詳しくは、メッセージ駆動型ルール Bean のインストールを参照してください。