ibm-messaging / mq-dev-patterns

Code samples and messaging patterns for IBM MQ developers
Apache License 2.0
190 stars 164 forks source link

Issue with AMQP / apache qpid client. #57

Closed chandan84 closed 2 years ago

chandan84 commented 3 years ago

Below is a summary of the AMQP client we have trying to build to evaluate request / response message pattern with IBM MQ. The end of the mail contains the concerns am still facing. Could you help create an IBM ticket on the issue to get their feedback. Typically how many days do we have to wait before we get a response ?

AMQP channel setup with the below properties, and is available at wmqt0041:5672. Properties of the channel are below.

name COMET.AMQP_SECCLNT type AMQP alteration_date 2021-09-06 alteration_time 08.48.37 no_external_participants
description COMET Secure SSL Client for AMQP disc_interval hb_interval
keep_alive_interval
max_instances 999999999 max_instances_per_client
max_message_length 4194304 mca_user
sharing_conversations ssl_client_auth REQUIRED ssl_cipher_spec ECDHE_RSA_AES_256_CBC_SHA384 ssl_peer_name cert-label
status INACTIVE canStart false canStop false

To access an existing queue via the channel, a subscription was setup - /comet/interim/claim. The subscription was mapped to queue endpoint – COMET.INTERIM_CLAIMQ. The below client is configured to

a. Send a message and pickup the message using jms correlation id from the same queue endpoint. b. Set the JMS Message Type to MQSTR c. Set reply to end point as /comet/interim/claim – subscription created to access COMET.INTERIM_CLAIMQ.

Client code is below

package com.ibm.mq.samples.jms.qpid;

import javax.jms.JMSContext;
import javax.jms.Message;
import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueReceiver;
import javax.jms.QueueSender;
import javax.jms.QueueSession;
import javax.jms.TextMessage;

import org.apache.qpid.jms.JmsConnectionFactory;

public class TestMessageSender {
       public static void main(String[] args) {

              System.setProperty("javax.net.ssl.keyStore", "cometdesktopmq.jks");
              System.setProperty("javax.net.ssl.trustStore", "cometdesktopmq.jks");
              System.setProperty("javax.net.ssl.keyStorePassword", "<<password>>");
              System.setProperty("com.ibm.mq.cfg.useIBMCipherMappings", "false");

              try {
                     String requsetUri = "amqps://wmqrt0041.uhc.com:5672";
                     String userName = "tgusr";
                     String password = "<<password>>";

                     JmsConnectionFactory factory = new JmsConnectionFactory(userName, password, requsetUri);
                     QueueConnection conn = factory.createQueueConnection();
                     conn.start();

                     System.out.println("conn started");

                     QueueSession sess = conn.createQueueSession(false, 1);
                     System.out.println("queue session created");

                     JMSContext context = factory.createContext(userName, password);
                     System.out.println("context created");

                     Queue q = context.createQueue("/comet/interim/claim");
                     QueueSender qs = sess.createSender(q);
                     System.out.println("queue sender created");

                     TextMessage message = context.createTextMessage("Text content");
                     message.setJMSType("MQSTR");
                     String msgId = message.getJMSMessageID();
                     message.setJMSCorrelationID(msgId);

                     Queue rq = context.createQueue("/comet/interim/claim");
                     message.setJMSReplyTo(rq);
                     qs.send(message);  // Send the message

                     System.out.println("message sent");

                     QueueReceiver reciever = sess.createReceiver(rq, "JMSCorrelationID ='" + msgId + "'");
                     Message reply = reciever.receive(10*1000); // Pickup the message using the id set in correlation id field, timeout = 10 secs

                     Inspector ins = new Inspector(reply);

                     ins.showMessageType();
                     ins.showProperties();
                     ins.showMessageHeaders();
                     ins.showMessageBody();

                     conn.close();

              } catch (Exception e) {
                     e.printStackTrace();
              }
       }

}

The message that was received at queue COMET.INTERIM_CLAIMQ is a put below

RFH [1][1] ¸


MQSTR MQMD StrucId: MD Version: 1 MsgType: 8 Expiry: -1 Encoding: 546 CodedCharSetId: 1208 Format: MQHRF2 Priority: 0 Report: 0 Feedback: 0 MsgId: 414d5120574d51543532352020202020e4c44561003c722a CorrelId: 414d5120574d51543532352020202020b6273861033d162d BackoutCount: 0 AccountingToken: 0531353938370000000000000000000000000000000000000000000000000006 ApplIdentityData: ApplOriginData: ReplyToQ: ReplyToQMgr: WMQT525 Persistence: 1 UserIdentifier: mqm PutApplType: 26 PutApplName: WMQT525 PutDate: 09/19/2021 22:14:20 GroupId: 000000000000000000000000000000000000000000000000 MsgSeqNumber: 1 Offset: 0 MsgFlags: 0 OriginalLength: -1 Message
RFH [1][1] ¸


MQSTR ¸


p910-006-2007031.0140ID:ce297c87-f1f4-46af-8ecb-6f6eb4d97d70:1:1:1-1/comet/interim/claimMQSTR/comet/interim/claim016321076609400005topic:///comet/interim/claim Text content

Concerns – a. Format still shows MQHRF2 instead of MQSTR. b. ReplyToQ property shows blank. [First to concerns are high priority] c. The message body contains tag To as - /comet/interim/claim , What does this indicate ? d. It also contains tag topic:///comet/interim/claim. The relyTo destination we are setting in the code is a Queue, Why does it get translated into a topic:///?

chughts commented 3 years ago

Do these concerns relate to the AMQP client or to IBM MQ ?

chughts commented 3 years ago

I see that you also raised this as a question on stackoverflow - https://stackoverflow.com/questions/69270996/apache-qpid-client-to-ibm-mq-broker-v-9-1-0-6-request-reply-pattern-with-que

Where it has been answered.