Home > Net >  IBMMQDotnet client retry mechanism
IBMMQDotnet client retry mechanism

Time:10-12

Hi everyone i am completely new to queues and especialy to IBMMQDotnet cleint library. Currently my application trying to send DTO object to the queue and sometimes it could faailed for various reasons like exception occuring or network issue. Is there any retrie mechanism ?i would like to implement retry mechansim, i tried to google it but could not found any example. Bellow is the current code

                if (!TryConnectToQueueManager())
                {
                   return;
                }
               using var destination = GetMqObjectForWrite(message.Destination, message.DestinationType);

                var mqMessage = new MQMessage
                {
                    Format = MQC.MQFMT_STRING,
                    CharacterSet = 1208
                };

                if (message.Headers?.Count > 0)
                {
                    foreach (var (key, value) in message.Headers)
                    {
                        mqMessage.SetStringProperty(key, value);
                    }
                }

                mqMessage.WriteString(JsonSerializer.Serialize(message.Data));

                destination.Put(mqMessage);

                destination.Close();

CodePudding user response:

IBM MQ provides a feature called as Client Auto Reconnect.You could refer the following KC page Client Auto Reconnect

If there is a connection failure because of the network issue, the IBM MQ client will try to re-establish a connection to the Queue Manager for a specific time period(which is configurable) before throwing an exception to the application

You could refer to the sample "SimpleClientAutoReconnectPut" & "SimpleClientAutoReconnectGet" which are available as part of the client installation.

  • Related