简体   繁体   中英

Is there an MQ/XMS equivalent for the MQ/JMS setTargetClient

I have a XMS publish app, that is working, but it is including JMS headers as part of the message. My subscribe app is actually a python app, and I was wondering if it is possible to remove the JMS headers from the XMS app. I know it is possible in JMS, but is it possible in C# / XMS.

My C# code is fairly simple (with some of the details left out -

            // 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);

In MQ /JMS I can use setTargetClient to remove the JMS headers -


  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");
    }
  }

I was wondering if I can do the same to the topic destination in XMS

            // Create destination
            destination = sessionWMQ.CreateTopic(conn.topic_name);
            // Configure the destination to Non-JMS
            ... ???

Yes, you should be able to do this

Try

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM