Can you post the linked MQ exception as well? There will be a MQRC reason code that indicates what the issue is. Make sure you specify correct queue name and queue manager name when creating consumer.
Original Message:
Sent: Mon September 19, 2022 06:28 AM
From: Balaji Patil
Subject: MQ - XMS
Hi Shashi,
I have created a QueueBrowser for reading messages.
For deleting a message I am trying to create consumer with selector, but its throwing an error.
Can you please help.
XMSException =IBM.XMS.IllegalStateException: Failed to open MQ queue XXX.
XMS attempted to perform an MQOPEN, but IBM MQ reported an error.
Use the linked exception to determine the cause of this error. Check that the specified queue and queue manager are defined correctly.
at IBM.XMS.Client.WMQ.WmqMessageConsumer.CheckNmqiCallSuccess(String messageid, String insert, String insertKey, Int32 completionCode, Int32 reason, NmqiEnvironment environment, String probeid, WmqCommonConnection commonConnection, Hconn hconn)
at IBM.XMS.Client.WMQ.WmqConsumerShadow.Initialize()
at IBM.XMS.Client.WMQ.WmqSyncConsumerShadow.Initialize()
at IBM.XMS.Client.WMQ.WmqMessageConsumer..ctor(WmqDestination destination, WmqSession session, String selector, Boolean nolocal, XmsPropertyContext xmsProps)
at IBM.XMS.Client.WMQ.WmqSession.CreateConsumer(ProviderDestination destination, String selector, Boolean nolocal, XmsPropertyContext propertyContext)
at IBM.XMS.Client.Impl.XmsSessionImpl.CreateConsumer(IDestination dest, String selector, Boolean noLocal)
at IBM.XMS.Client.Impl.XmsSessionImpl.CreateConsumer(IDestination dest, String selector)
at Siemens.MOM.Interoperability.BscIBMMQAdapter.OnSendMessage(CIOMessage sentMessage, CancellationToken token)
thanks,
Balaji
------------------------------
Balaji Patil
Original Message:
Sent: Fri September 09, 2022 09:21 AM
From: Shashikanth Rao Thambrahalli
Subject: MQ - XMS
Hi Balaji,
I am happy to help. You can contact me on my email id.
Thank you
Shashi
------------------------------
Shashikanth Rao Thambrahalli
IBM
Original Message:
Sent: Fri September 09, 2022 03:22 AM
From: Balaji Patil
Subject: MQ - XMS
@Shashikanth Rao Thambrahalli:
Please help on the above design.. is it even possible?
We really need your help on this.. Please please..!
------------------------------
Balaji Patil
Original Message:
Sent: Fri September 09, 2022 12:20 AM
From: Shashikanth Rao Thambrahalli
Subject: MQ - XMS
Sorry, what do you want to me look at please?
------------------------------
Shashikanth Rao Thambrahalli
IBM
Original Message:
Sent: Thu September 08, 2022 11:59 AM
From: Balaji Patil
Subject: MQ - XMS
Shashi,
Please shade some light on the below:
Class ABC{ Void Step1() { Initialize MQ connection params } Void Step2() { session = connection.CreateSession(false, AcknowledgeMode.ClientAcknowledge); Connect to MQ and create messageListener = new MessageListener(OnMessageCallback); } OnMessageCallback (Msg) { Push the msg into other system, response will be sent to Step 3. } Void Step3() { After getting the response I want to delete the msg from MQ. Since the AcknowledgeMode is ClientAcknowledge, how to acknowlede the msg? }}
------------------------------
Balaji Patil
Original Message:
Sent: Thu September 08, 2022 08:24 AM
From: Shashikanth Rao Thambrahalli
Subject: MQ - XMS
The error reported is correct. Once a message listener is assigned to a consumer in a session, synchronous calls like creating another consumer or producer is not allowed.
You will have to issue connection.stop() first, make synchronous calls and then issue connection.start() again.
Hope this helps
Shashi
------------------------------
Shashikanth Rao Thambrahalli
IBM
Original Message:
Sent: Thu September 08, 2022 08:00 AM
From: Balaji Patil
Subject: MQ - XMS
Hello Shashi,
I am getting this error while creating consumer, can you please help finding the root cause:
XMSException =IBM.XMS.IllegalStateException: CWSMQ0101E: Synchronous method call not permitted when a session is being used asynchronously: CreateConsumer.
The XMS specification does not permit the use of a session for synchronous methods when asynchronous message delivery is running.
Create a separate session if you wish to use both synchronous methods and asynchronous delivery simultaneously.
at IBM.XMS.Client.Impl.XmsSessionImpl.CheckSynchronousUsage(String methodName)
at IBM.XMS.Client.Impl.XmsSessionImpl.CreateConsumer(IDestination dest, String selector)
------------------------------
Balaji Patil
Original Message:
Sent: Fri August 26, 2022 11:40 AM
From: Shashikanth Rao Thambrahalli
Subject: MQ - XMS
How did you check that connection is active?
Usually XMSException will contain an MQ exception as well and that exception will provide details on the error. Could you post the complete exception stack?
------------------------------
Shashikanth Rao Thambrahalli
IBM
Original Message:
Sent: Fri August 26, 2022 05:08 AM
From: Balaji Patil
Subject: MQ - XMS
Hi Shashi,
I am getting the below error while sending a message outbound queue using xms producer.
XMSException =IBM.XMS.IllegalStateException: XMSCC0020
XMSCC0020.explanation
XMSCC0020.useraction
at IBM.XMS.Client.Impl.State.CheckNotClosed(String message)
at IBM.XMS.Client.Impl.XmsSessionImpl.CreateBytesMessage()
I see the connection is still active, but not sure why this error comes up.
Any suggestion?
------------------------------
Balaji Patil
Original Message:
Sent: Mon August 22, 2022 09:49 AM
From: Shashikanth Rao Thambrahalli
Subject: MQ - XMS
Okay, I think I understand a little more of your architecture.
Instead of using a consumer with ClientAcknowledge, I think it may be better for you to use IQueueBrowser which browses messages without removing them from queue. You don't have to do acknowledge in that case. Once processing is done, your custom program can either use MQ .NET or XMS .NET to remove the message given that your application knows the MessageId.
------------------------------
Shashikanth Rao Thambrahalli
IBM
Original Message:
Sent: Mon August 22, 2022 04:50 AM
From: Balaji Patil
Subject: MQ - XMS
I am sorry if my ask is not clear, but:
I can't use the AutoAcknowledge on session as I need to delete the msg once it has been processed into MES.
Once the message has been processed successfully in the MES, a response message will ne sent from MES to my custom program.
Upon receiving the response, I need to delete the message from queue. My sample class is as below.
I want to delete the message in Step3() method.
Class ABC{ Void Step1() { Initialize MQ connection params } Void Step2() { session = connection.CreateSession(false, AcknowledgeMode.ClientAcknowledge); Connect to MQ and create messageListener = new MessageListener(OnMessageCallback); } OnMessageCallback (Msg) { Push the msg into other system, response will be sent to Step 3. } Void Step3() { After getting the response I want to delete the msg from MQ. Since the AcknowledgeMode is ClientAcknowledge, how to acknowlede the msg? }}
RE: MQMO_MATCH_MSG_ID + MQC.MQMO_MATCH_CORREL_ID - for this to work you will need both MessageId and CorrelationId:
In response message (Step3()) above, I am able to get the Messageid and CorrelationId.
------------------------------
Balaji Patil
Original Message:
Sent: Mon August 22, 2022 04:27 AM
From: Shashikanth Rao Thambrahalli
Subject: MQ - XMS
You can use XMS itself to delete the message, just created AutoAck session and call receive() method. But you will need the Id of the message to delete it. In your code above, you have set options MQMO_MATCH_MSG_ID + MQC.MQMO_MATCH_CORREL_ID - for this to work you will need both MessageId and CorrelationId.
------------------------------
Shashikanth Rao Thambrahalli
IBM
Original Message:
Sent: Mon August 22, 2022 03:30 AM
From: Balaji Patil
Subject: MQ - XMS
For fetching the messages I can use XMS libraries.
For deleting can I use below?
MQMessageOptions.WaitInterval = 0;
MQMessageOptions.Options = MQC.MQMO_MATCH_MSG_ID + MQC.MQMO_MATCH_CORREL_ID + MQC.MQGMO_NO_WAIT + MQC.MQGMO_FAIL_IF_QUIESCING;
while (true)
{
queueIn_Delete.Get(queueMessage, MQMessageOptions);
queueManagerIn_Delete.Commit();
if (m_ShowExtendedTracing >= 1)
{
Trace.WriteLine("In DeleteDocument: Deleteing multiple entries for " + this.Name + " Document Name: " + documentName);
}
}
------------------------------
Balaji Patil
Original Message:
Sent: Mon August 22, 2022 01:48 AM
From: Shashikanth Rao Thambrahalli
Subject: MQ - XMS
When using ClientAcknowledge, you must call Message.Acknowledge() method to tell a messaging provider that you are done with processing of that message and it can now delete the message from queue. Message processing is generally done in a single thread, often passing the Message object between different methods. I have no knowledge of your application/solution design, so unable to comment/help further.
------------------------------
Shashikanth Rao Thambrahalli
IBM
Original Message:
Sent: Mon August 22, 2022 01:12 AM
From: Balaji Patil
Subject: MQ - XMS
Hi,
Thanks for you suggestion.
RE: "Deleting message after processing into other system":
I don't want to set Message.Acknowledge() in the call back method.
the message must be deleted in the Step3() method where I can't access the Message class in this method.
Step 1> Step2>Step3 sequentially called by other program, can't call them explicitly.
------------------------------
Balaji Patil
Original Message:
Sent: Fri August 19, 2022 10:43 AM
From: Shashikanth Rao Thambrahalli
Subject: MQ - XMS
1) After processing the received message just call the Acknowledge() method of the Message class.
2) The best way to check is to either Send or Receive message it self. If the connection is not active, then you would get an exception with reason code MQRC 2009. You also have an option of automatic client reconnection where the MQ .NET library will automatically attempt to reconnect if there is connection error.
------------------------------
Shashikanth Rao Thambrahalli
IBM
Original Message:
Sent: Fri August 19, 2022 02:51 AM
From: Balaji Patil
Subject: MQ - XMS
1. Deleting message after processing into other system:
(comments and question added in the methods.)
Class ABC{ Void Step1() { Initialize MQ connection params } Void Step2() { session = connection.CreateSession(false, AcknowledgeMode.ClientAcknowledge); Connect to MQ and create messageListener = new MessageListener(OnMessageCallback); } OnMessageCallback (Msg) { Push the msg into other system, response will be sent to Step 3. } Void Step3() { After getting the response I want to delete the msg from MQ. Since the AcknowledgeMode is ClientAcknowledge, how to acknowlede the msg? }}
2. How to periodically check if MQ connection is active/stale, etc. If its inactive, auto-reconnect.
------------------------------
Balaji Patil
------------------------------