简体   繁体   English

从WebSphere MQ中的集群队列接收消息

[英]Receiving messages from clustered queue in WebSphere MQ

I am looking for some guidance regarding how to set up an application that listens to clustered queues on multiple queue managers. 我正在寻找有关如何设置在多个队列管理器上侦听集群队列的应用程序的指导。 Below is our current setup: 以下是我们当前的设置:

Physical Box "Alpha": TCP listener defined for port: 1111 Queue Manager Name: QM1 Channel Name: "MyChannel" Queue Name: Q1 物理框“ Alpha”:为端口定义的TCP侦听器:1111队列管理器名称:QM1通道名称:“ MyChannel”队列名称:Q1

Physical Box "Beta": TCP Listener defined for port 1112 Queue Manager Name: QM2 Channel Name: "MyChannel" Queue Name: Q1 物理框“ Beta”:为端口1112定义的TCP侦听器队列管理器名称:QM2通道名称:“ MyChannel”队列名称:Q1

An external client application has a connection to QM1 on physical box Alpha on port 1111. 外部客户端应用程序已连接到端口1111上物理盒Alpha上的QM1。

When I PUT messages onto Q1, because of the clustered setup, every second message is placed on either Q1 on QM1 or Q1 on QM2. 当我将消息放入Q1时,由于是群集设置,因此每隔一条消息就会放在QM1的Q1或QM2的Q1上。

When another application is connected to QM2 on physical box Beta on port 1112, it receives only half the messages that have been sent to Q1 because it is not monitoring both queue managers. 当另一个应用程序连接到端口1112上物理盒Beta上的QM2时,它仅接收已发送到Q1的消息的一半,因为它没有监视两个队列管理器。

Is there a way to connect to both queue managers so that my second application receives all messages that are placed on Q1 regardless of the Queue Manager that it is monitoring? 有没有办法连接到两个队列管理器,以便我的第二个应用程序接收放置在Q1上的所有消息,而不管它正在监视的队列管理器?

We are connecting via JMS using the following code: 我们使用以下代码通过JMS连接:

 public static ConnectionFactory createConnectionFactory(final ConnectionString connectionString) throws JMSException {
        MQConnectionFactory cf = new MQConnectionFactory();
        cf.setHostName(connectionString.getHost());
        cf.setPort(connectionString.getPort());
        cf.setTransportType(WMQConstants.WMQ_CM_CLIENT);
                cf.setClientReconnectOptions(WMQConstants.WMQ_CLIENT_RECONNECT_Q_MGR);
        cf.setQueueManager(connectionString.getQueueManager());
        cf.setChannel(connectionString.getChannel());

        return cf;
    }

Applications must be locally connected to GET messages. 应用程序必须在本地连接到GET消息。 The locally here means 'application can get messages from queues that are hosted in the queue manager to which the application is directly connected'. 这里的locally意味着“应用程序可以从应用程序直接连接到的队列管理器中托管的队列中获取消息”。 As the second application running Beta box is connected to queue manager QM2 where Q1 is hosted, it is getting messages. 当第二个运行Beta应用程序连接到托管Q1的队列管理器QM2时,它正在获取消息。

Your can run another instance of your second application on Alpha box where the application connects to QM1 to get messages from Q1. 您可以在Alpha框上运行第二个应用程序的另一个实例,该应用程序连接到QM1以从Q1获取消息。

Update 更新

Please note MQ cluster is for work loading balancing messages among multiple cluster queue instances in queue managers in a cluster. 请注意,MQ集群用于在集群中的队列管理器中的多个集群队列实例之间负载均衡消息。 MQ cluster is not same as High Availability cluster. MQ群集与高可用性群集不同。 In MQ cluster messages will be distributed to all instances of a queue in a round robin basis( round robin distribution is the default. It can be changed to by developing cluster work load exit). 在MQ集群中,消息将以循环方式分配到队列的所有实例(循环分配是默认方式。可以通过开发集群工作负载出口将其更改为)。

Since the job is to load balance messages, one application per cluster queue instance must be setup to process messages. 由于这项工作是为了负载平衡消息,因此必须为每个群集队列实例设置一个应用程序来处理消息。 If such a setup is not made, then messages will remain in cluster queue instances. 如果未进行此类设置,则消息将保留在群集队列实例中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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