使用XMS向多实例队列管理器发送消息 [英] Sending message to Multi Instance Queue Manager with XMS

查看:223
本文介绍了使用XMS向多实例队列管理器发送消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

关注此帖子:获取有效的质量管理来自多实例队列管理器的实例并连接

我已建立连接

XMSFactoryFactory factory = XMSFactoryFactory.GetInstance(XMSC.CT_WMQ);
IConnectionFactory connectionProperties = factory.CreateConnectionFactory();

connectionProperties.SetIntProperty(XMSC.WMQ_CLIENT_RECONNECT_OPTIONS, XMSC.WMQ_CLIENT_RECONNECT_Q_MGR);
connectionProperties.SetStringProperty(XMSC.WMQ_CONNECTION_NAME_LIST, String.Format("{0}({1}),{2}({3})", element.Host1, element.Port1, element.Host2, element.Port2));
connectionProperties.SetIntProperty(XMSC.WMQ_CLIENT_RECONNECT_TIMEOUT, XMSC.WMQ_CLIENT_RECONNECT_TIMEOUT_DEFAULT);
connectionProperties.SetStringProperty(XMSC.WMQ_QUEUE_MANAGER, element.QueueManager);
connectionProperties.SetStringProperty(XMSC.WMQ_CHANNEL, element.Channel);
connectionProperties.SetIntProperty(XMSC.WMQ_CONNECTION_MODE, XMSC.WMQ_CM_CLIENT);
connectionProperties.SetIntProperty(XMSC.WMQ_BROKER_VERSION, XMSC.WMQ_BROKER_V1);
connectionProperties.SetBooleanProperty(XMSC.WMQ_USE_CONNECTION_POOLING, true);

然后是

    try
    {
        using (IConnection connection = _connectionProperties.CreateConnection())
        {
            connection.Start();
            using (ISession session = connection.CreateSession(true, AcknowledgeMode.AutoAcknowledge))
            {
                using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    using (IDestination responseQueue = session.CreateQueue(replyToRequestQueue ? _requestQueueName : _responseQueueName))
                    {
                        using (IMessageProducer producer = session.CreateProducer(responseQueue))
                        {
                            IMessage response = session.CreateTextMessage(message);
                            if (!string.IsNullOrEmpty(correlationId))
                            {
                                response.JMSCorrelationID = correlationId;
                            }
                            producer.Send(response);
                            }
                        }
                        scope.Complete();
                    }
                }
            }
        }
        catch (XMSException xmse)
        {
            if (xmse.LinkedException != null)
            {
                Trace.TraceError(string.Format(MQTraceMessageFormat,
                    DateTime.Now,
                    TraceMessageType.Error,
                    Thread.CurrentThread.ManagedThreadId,
                    Thread.CurrentThread.IsThreadPoolThread ? "Threadpool " + Name : Thread.CurrentThread.Name,
                    null, null,
                    "XMSException.LinkedException on (SendTextMessage) sending message to " + this + 
                    " / xmse.LinkedException.Message : " + xmse.LinkedException.Message +
                    " / xmse.Message : " + xmse.Message +
                    " / xmse.LinkedException.StackTrace: " + xmse.LinkedException.StackTrace,
                    " / xmse.StackTrace: " + xmse.StackTrace,
                    null));
            }
            else
            {
                Trace.TraceError(string.Format(MQTraceMessageFormat,
                    DateTime.Now,
                    TraceMessageType.Error,
                    Thread.CurrentThread.ManagedThreadId,
                    Thread.CurrentThread.IsThreadPoolThread ? "Threadpool " + Name : Thread.CurrentThread.Name,
                    null, null,
                    "XMSException on (SendTextMessage) sending message to " + this +
                    " / xmse.Message : " + xmse.Message +
                    " / xmse.StackTrace: " + xmse.StackTrace,
                    null));
            }
        }
        catch (MQException mqex)
        {
            Trace.TraceError(string.Format(MQTraceMessageFormat,
                DateTime.Now,
                TraceMessageType.Error,
                Thread.CurrentThread.ManagedThreadId,
                Thread.CurrentThread.IsThreadPoolThread ? "Threadpool " + Name : Thread.CurrentThread.Name,
                null, null,
                "MQException cc on (SendTextMessage) sending message to " + this +
                " Exception: " + mqex.Message +
                " CompletionCode: " + mqex.CompletionCode +
                " ReasonCode: " + mqex.ReasonCode +
                " Stack Trace: " + mqex.StackTrace,
                null));
        }
        catch (IOException ioex)
        {
            Trace.TraceError(string.Format(MQTraceMessageFormat,
                DateTime.Now,
                TraceMessageType.Error,
                Thread.CurrentThread.ManagedThreadId,
                Thread.CurrentThread.IsThreadPoolThread ? "Threadpool " + Name : Thread.CurrentThread.Name,
                null, null,
                "IOException ioex on (SendTextMessage) sending message to " + this +
                " Exception: " + ioex.Message +
                " Stack Trace: " + ioex.StackTrace,
                null));
        }
        catch (Exception ex)
        {
            Trace.TraceError(string.Format(MQTraceMessageFormat,
                DateTime.Now,
                TraceMessageType.Error,
                Thread.CurrentThread.ManagedThreadId,
                Thread.CurrentThread.IsThreadPoolThread ? "Threadpool " + Name : Thread.CurrentThread.Name,
                null, null,
                "Exception ex on (SendTextMessage) sending message to " + this +
                " Exception: " + ex.Message +
                " Stack Trace: " + ex.StackTrace,
                null));
        }
    }

发送消息,但是它在最后一行生产者处抛出异常.发送(响应):

to send message, however it threw exception at the last line producer.Send(response):

renamed.exe Error: 0 : |8/15/2017 10:17:49 AM|Error|25|Threadpool XYZ|||XMSException.LinkedException on (SendTextMessage) sending message to Queue handler ABC:(In ABC.XYZ.REQUEST / Out XYZ.ABC.RESPONSE) / xmse.LinkedException.Message : 2012 / xmse.Message : Failed to send a message to destination XYZ.ABC.RESPONSE.
XMS attempted to perform an MQPUT or MQPUT1; however WebSphere MQ reported an error.
Use the linked exception to determine the cause of this error. / xmse.LinkedException.StackTrace: | / xmse.StackTrace:    at IBM.XMS.Client.WMQ.ProducerShadow.CheckNmqiCallSuccess(String messageid, WmqDestination destination, String probeid, Int32 cc, Int32 rc)
   at IBM.XMS.Client.WMQ.SpiIdentifiedProducerShadow.SendInternal(MQMessageDescriptor md, Byte[] buffers, Int32 msgLength)
   at IBM.XMS.Client.WMQ.ProducerShadow.Send(WmqDestination destAtSendCall, WmqMessage message)
   at IBM.XMS.Client.WMQ.WmqMessageProducer.Send(ProviderDestination destAtSendCall, ProviderMessage message)
   at IBM.XMS.Client.Impl.XmsMessageProducerImpl.SendMessage(IMessage message, XmsDestinationImpl dest)
   at IBM.XMS.Client.Impl.XmsMessageProducerImpl.Send_(Boolean inIdentifiedContext, XmsDestinationImpl dest, IMessage message, DeliveryMode deliveryMode, Int32 priority, Int64 timeToLive, Boolean explicitDlvModePriorityAndTimeToLive)
   at IBM.XMS.Client.Impl.XmsMessageProducerImpl.Send(IMessage message)
   at DVS.Services.Common.MQHandler.QueueHandler.SendTextMessage(String message, String correlationId, Boolean replyToRequestQueue)

从跟踪中可以看到生产者在连接名称列表中有我的两个主用/备用主机,还有"localhost"作为host_name和1414作为端口,这就是为什么我无法连接到它吗?

From the trace I can see the producer has my two active/standby host in the connection name list, but also "localhost" as host_name and 1414 as port, is that why I cannot connect to it?

producer: XMSC_WMQ_BROKER_PUBQ_QMGR : 
XMSC_CONNECTION_TYPE_NAME : IBM.XMS.Client.WMQ
XMSC_DISABLE_MSG_ID : False
XMSC_WMQ_RESOLVED_QUEUE_MANAGER_ID : QM1_2017-08-02_15.25.10                   
XMSC_WMQ_CLEANUP_INTERVAL : 3600000
XMSC_WMQ_BROKER_PUBQ : SYSTEM.BROKER.DEFAULT.STREAM
XMSC_WMQ_BROKER_SUBQ : SYSTEM.JMS.ND.SUBSCRIBER.QUEUE
XMSC_WMQ_PUB_ACK_INTERVAL : 25
targetClient : 0
XMSC_WMQ_CLEANUP_LEVEL : 1
XMSC_WMQ_MESSAGE_RETENTION : 1
XMSC_WMQ_PORT : 1414
XMSC_WMQ_PROVIDER_VERSION : 7
CCSID : 1208
deliveryMode : 2
XMSC_ADMIN_OBJECT_TYPE : 20
brokerVersion : 0
XMSC_WMQ_USE_CONNECTION_POOLING : True
XMSC_WMQ_TEMP_Q_PREFIX : 
XMSC_ACKNOWLEDGE_MODE : 4
XMSC_WMQ_BROKER_CONTROLQ : SYSTEM.BROKER.CONTROL.QUEUE
failIfQuiesce : 1
XMSC_WMQ_MESSAGE_SELECTION : 0
XMSC_ASYNC_EXCEPTIONS : -1
timeToLive : 0
XMSC_WMQ_CONNECTION_MODE : 1
XMSC_WMQ_RESOLVED_QUEUE_MANAGER : QM1
XMSC_WMQ_CONNECTION_NAME_LIST : host1(11111),host2(11111)
XMSC_WMQ_QMGR_CCSID : 819
XMSC_WMQ_SHARE_CONV_ALLOWED : 1
XMSC_WMQ_CLIENT_RECONNECT_TIMEOUT : 1800
XMSC_WMQ_MAP_NAME_STYLE : True
XMSC_PASSWORD : ********
priority : 4
XMSC_WMQ_LOCAL_ADDRESS : 
XMSC_WMQ_MAX_BUFFER_SIZE : 1000
XMSC_WMQ_CONNECT_OPTIONS : 0
XMSC_DISABLE_MSG_TS : False
XMSC_WMQ_BROKER_QMGR : 
XMSC_WMQ_CLIENT_RECONNECT_OPTIONS : 16777216
version : 7
XMSC_WMQ_CONNECTION_TAG : System.Byte[]
encoding : 546
XMSC_WMQ_POLLING_INTERVAL : 5000
XMSC_WMQ_RESCAN_INTERVAL : 5000
XMSC_WMQ_TEMPORARY_MODEL : SYSTEM.DEFAULT.MODEL.QUEUE
XMSC_WMQ_CHANNEL : MY.SVC.SVRCONN.P
XMSC_CONNECTION_TYPE : 1
XMSC_WMQ_SYNCPOINT_ALL_GETS : False
XMSC_WMQ_HOST_NAME : localhost
XMSC_WMQ_QUEUE_MANAGER : QM1
wildcardFormat : 0
XMSC_WMQ_BROKER_DUR_SUBQ : SYSTEM.JMS.D.SUBSCRIBER.QUEUE
XMSC_TRANSACTED : True
XMSC_WMQ_MSG_BATCH_SIZE : 10

推荐答案

不支持使用分布式事务进行自动客户端重新连接,这就是您看到的原因

Automatic Client Reconnection with Distributed Transactions are not supported that is the reason you see

|XMSException.LinkedException on (SendTextMessage) sending message to Queue handler ABC:(In ABC.XYZ.REQUEST / Out XYZ.ABC.RESPONSE) / xmse.LinkedException.Message : **2012** / xmse.Message : Failed to send a message to destination XYZ.ABC.RESPONSE.

2012年是MQRC_ENVIRONMENT_ERROR.

2012 is MQRC_ENVIRONMENT_ERROR.

以下链接对此进行了讨论:

Following link talks about it :https://www.ibm.com/support/knowledgecenter/SSFKSJ_9.1.0/com.ibm.mq.con.doc/q018380_.htm

这篇关于使用XMS向多实例队列管理器发送消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆