Routing messages between queue managers using websphere message broker - ibm-mq

How can I use WebSphere Message broker instance to route messages between queues residing in two queue managers. The message broker instance can only be associated with one queue manager during creation time. So I create an MQInputNode and put messages to the specific source queue. My concern is to route this message to second queue residing in another queue manager using the same broker instance. How? I am using WebSphere Message Broker version 8.0.0.8. Not yet into IIB.

Below is a simple and efficient way of doing it.
Suppose, your broker is on QM1. You have a local queue in QM2 named LQ_QM2.
And you want the messages to go to LQ_QM2. Follow below steps:
At QM1, create a local queue of usage 'Transmission'. Let us name this transmission queue as "QM2".
At QM1, create a sender channel named "QM1.QM2" with proper connection name (Contains host(port) of target queue manager, for eg
10.1.5.2(1144)) and set transmission queue as QM2 (The one we created in step 1).
Create a receiver channel at QM2 named "QM1.QM2).
Now create a remote queue definition at QM1. Let's name it as RQ_LQ_QM2. Set remote queue property as LQ_QM2 and transmission queue
as QM2 and remote queue manager as QM2.
The messages which you want to send to the queue LQ_QM2 can now be written by the broker to RQ_LQ_QM2 in QM1 itself.
If you can't do the above MQ stuff and must use only Message broker capability then the way of doing it in WMB 8 would be to use Java and write an MQ client code using the MQ API libraries. You will then establish remote connection with the remote queue manager using SVRCONN channel and put messages on the remote queue manager's queue.

Related

IBM MQ- Create a new local definition of remote queue

Current setup is QM1 (queue manager 1) is having local definition Q1 (mq 1). On QM2, Q1 is configured as remote queue. This configuration works fine. That means any app connecting to QM2 can use name Q1 and those messages gets forwarded to QM1 through distributed Mq setup(channels, transmit queues).
I want to know if I create new Q1 as local queue on QM2 , will mqput calls forward messages to both Queues?
You cannot issue 1 MQPUT and have the message go to more than 1 queue unless you have configured a distribution list or configured the queue to be under Pub/Sub but not all fields of the MQMD are copied.
If you want to replicate messages (for a backup or SLA mechanism) including the MQMD fields then you need to look at a product like MQ Message Replication.

IBM MQ transmit queue messages not placed on dead letter queue

I currently have an XMIT queue with a SDR channel pointed to a QREMOTE. In a scenario where either the local or remote channels are down, I would like to forward the messages on the XMIT queue to the DLQ. It appears that in this scenario, messages remain on the XMIT queue until the channel is reestablished. Is it possible to do this?
I'm thinking not. From an ibm red paper: http://www.redbooks.ibm.com/redpapers/pdfs/redp0021.pdf
A transmission queue is a local queue with the USAGE(XMITQ) attribute
configured. It is a staging point for messages that are destined for a
remote queue manager. Typically, there is one transmission queue for
each remote queue manager to which the local queue manager might
connect directly. If the destination is unavailable, messages build up
on the transmission queue until the connection can be successfully
completed. Transmission queues are transparent to the application.
When an application opens a remote queue, the queue manager
internally creates a reference to the relevant transmission queue and
messages are put there.

Is it possible to setup an IBM MQ reciever channel to recieve messages from two different queue managers

Is it possible to setup an IBM MQ receiver channel to receive messages from two different queue managers with the sender channels named identically. I am looking at a situation where a client wishes to have two queue managers (A and B) able to send messages to the same destination queue manager (C). A and B are setup up in an active / passive cluster setup without shared storage.
It is not only possible to set up IBM MQ Receiver channels to receive messages from two different queue managers, it is recommended to do so.
For example, on QM3 (the receiving queue manager) make the following definition:
DEFINE CHANNEL(TO.QM3) CHLTYPE(RCVR) TRPTYPE(TCP)
Then on both QM1 and QM2 make the following definitions:
DEFINE CHANNEL(TO.QM3) CHLTYPE(SDR) TRPTYPE(TCP) CONNAME('qm3-host-name(qm3-port)') XMITQ(QM3)
DEFINE QLOCAL(QM3) USAGE(XMITQ)
Doing this will NOT cause sequence number issues as the state for each running receiver channel instance is keyed off the channel name plus the partner queue manager name, so there will be state for:-
Channel:TO.QM3 from Partner QMgr QM1
Channel:TO.QM3 from Partner QMgr QM2
Both channel instances can be running at the same time quite happily without interfering with each other.
You can see this state by issuing the following command on the receiving queue manager, QM3:-
DISPLAY CHSTATUS(TO.QM3)

What is the difference between remote, local and alias queues

Can somebody help to understand the basic of these 3 queues with example.when do we use all 3
Perhaps a more simple explanation: Think of a local queue as a queue which exists on the queue manager it is defined.. you can PUT and GET messages off a local queue. A remote queue is like a pointer to a queue on another queue manager which is usually on different host. Therefore messages can be PUT to it (and they will usually arrive on a local queue at that remote host) but you cannot GET messages from a remote queue.
Simply put, a queue manager only ever hosts messages on local or transmition queues on that queue manager. If you want to go to another queue manager, you can use definitions which tell the queue manager that the 'put' is running on, how to route the message to a destination queue manager - however this ends up with a message on a transmit queue which is then picked up and sent down a channel towards that destination. Alias queues are just an opportunity to use a different name for another queue. Remote queues are definitions on one queuemanager with information about where the message should be routed.
MQ documentation:
https://www.ibm.com/support/knowledgecenter/SSFKSJ_8.0.0/com.ibm.mq.explorer.doc/e_queues.htm
Another description:
https://www.scribd.com/doc/44887119/Different-Types-Queues-in-Websphere-MQ
A queue is known to a program as local if it is owned by the queue manager to which the program is connected; the queue is known as remote if it is owned by a different queue manager. The important difference between these two types of queue is that you can get messages only from local queues. (You can put messages on both types of queue.)
References:
https://www.ibm.com/support/knowledgecenter/en/SSFKSJ_7.0.1/com.ibm.mq.csqzal.doc/fg10950_.htm
https://www.ibm.com/support/knowledgecenter/SSFKSJ_8.0.0/com.ibm.mq.explorer.doc/e_queues.htm
An application which is connected to a local QueueManager which host a queue, So that queue will be local queue for that application. An application which is connected to a QueueManager which is located remotely and that host a queue that queue will be remote queue. we should always keeps in mind that we always read the message from the local queue. A message put on the remote queue, will be routed to local queue through the object defined on the local queue thrugh the channel and the transmission queue.

Difference between Queue Manager and Queue in MQ

Looking at the sample codes it seems I need queue manager and queue name to setup MQ through code. What is difference between those and where I can get those values from? Any suggestion?
MQTopicConnectionFactory cf = new MQTopicConnectionFactory();
// Config
cf.setHostName("localhost");
cf.setPort(1414);
cf.setTransportType(JMSC.MQJMS_TP_CLIENT_MQ_TCPIP);
cf.setQueueManager("QM_thinkpad");
cf.setChannel("SYSTEM.DEF.SVRCONN");
MQTopicConnection connection = (MQTopicConnection) cf.createTopicConnection();
MQTopicSession session = (MQTopicSession) connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
MQTopic topic = (MQTopic) session.createTopic("topic://foo");
MQTopicPublisher publisher = (MQTopicPublisher) session.createPublisher(topic);
MQTopicSubscriber subscriber = (MQTopicSubscriber) session.createSubscriber(topic);
You connect to a queue manager which may host many different queues. So yes, an application generally needs access to a queue manager and then specific queues on that queue manager. I suggest you can look at the Stack Overflow info for the websphere-mq tag to help get you started. The names of those objects should be known by your application architect/developer or can be confirmed with the MQ admin.
A Queue is a container for messages. Business applications that are connected to the Queue Manager that hosts the queue can retrieve messages from the queue or can put messages on the queue. We have difference types of Queues as follows:
Local Queue: A local queue is a definition of both a queue and the set of messages that are associated with the queue. The queue manager that hosts the queue receives messages in its local queues
Remote Queue: Remote queue definitions are definitions on the local Queue Manager of queues that belong to another queue manager. To send a message to a queue on a remote queue manager, the sender queue manager must have a remote definition of the target queue.
Alias Queue: Alias queues are not actually queues; they are additional definitions of existing queues. You create alias queue definitions that refer to actual local queues but you can name the alias queue definition differently from the local queue (the base queue). This means that you can change the queues that an application uses without needing to change the application; you just create an alias queue definition that points to the new local queue.
Source
Before going to connect Queue, we must start a queue manager.The queue manager has a name, and applications can connect to it using this name. The queue manager owns and manages the set of resources that are used by WebSphere MQ.
Page sets that hold the WebSphere MQ object definitions and message data
Logs that are used to recover messages and objects in the event of queue manager failure
Processor storage
Connections through which different application environments (CICS®, IMS™, and Batch) can access the WebSphere MQ API
The WebSphere MQ channel initiator, which allows communication between WebSphere MQ on your z/OS system and other systems
Source

Resources