4
votes

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); 
2

2 Answers

2
votes

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.

1
votes

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