是否有等效于MQ / JMS setTargetClient的MQ / XMS

问题描述 投票:0回答:1

我有一个正在运行的XMS发布应用程序,但是它包含JMS标头作为消息的一部分。我的订阅应用程序实际上是一个python应用程序,我想知道是否有可能从XMS应用程序中删除JMS标头。我知道在JMS中是可能的,但是在C#/ XMS中是可能的。

我的C#代码非常简单(省略了一些详细信息-

            // Get an instance of factory.
            factoryFactory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);

            // Create WMQ Connection Factory.
            cf = factoryFactory.CreateConnectionFactory();

            // Set the properties
            cf.SetStringProperty(XMSC.WMQ_HOST_NAME, conn.host);
            ...

            // Create connection.
            connectionWMQ = cf.CreateConnection();

            // Create session
            sessionWMQ = connectionWMQ.CreateSession(false, AcknowledgeMode.AutoAcknowledge);

            // Create destination
            destination = sessionWMQ.CreateTopic(conn.topic_name);

            // Create producer
            producer = sessionWMQ.CreateProducer(destination);

            // Start the connection to receive messages.
            connectionWMQ.Start();

            // Create a text message and send it.
            textMessage = sessionWMQ.CreateTextMessage();
            textMessage.Text = xmsJson.toJsonString();
            producer.Send(textMessage);

在MQ / JMS中,我可以使用setTargetClient删除JMS标头-


  private void setToNoJMSHeaders(Destination destination) {
    try {
        MQDestination mqDestination = (MQDestination) destination;
        mqDestination.setTargetClient(WMQConstants.WMQ_CLIENT_NONJMS_MQ);
    } catch (JMSException jmsex) {
      logger.warning("Unable to set target destination to non JMS");
    }
  }

我想知道是否可以对XMS中的主题目标执行相同的操作

            // Create destination
            destination = sessionWMQ.CreateTopic(conn.topic_name);
            // Configure the destination to Non-JMS
            ... ???
c# mq xms
1个回答
0
投票

是,您应该可以这样做

尝试

// Create destination
       destination = sessionWMQ.CreateTopic(conn.topic_name);
       destination.SetIntProperty(XMSC.WMQ_TARGET_CLIENT, XMSC.WMQ_TARGET_DEST_MQ);

参见:https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_9.1.0/com.ibm.mq.ref.dev.doc/prx_wmq_target_client.htm

© www.soinside.com 2019 - 2024. All rights reserved.