Google Groups unterstützt keine neuen Usenet-Beiträge oder ‑Abos mehr. Bisherige Inhalte sind weiterhin sichtbar.

IBM MQ8 - how to ?

41 Aufrufe
Direkt zur ersten ungelesenen Nachricht

oha...@gmail.com

ungelesen,
22.02.2015, 01:03:1722.02.15
an
Hi all ,

I would like to use MQ8 in my project.
On one hand I saw few examples online , On the other hand saw IBM documentation that those examples are not for production environment.
For now I m doing something like :
String qManager = "testQueue"; // define name of queue
// manager to connect to.
MQQueueManager qMgr;

try {
qMgr = new MQQueueManager(qManager);

System.out.println(qMgr);
int openOptions = MQC.MQOO_INPUT_AS_Q_DEF |MQC.MQOO_OUTPUT ;
MQQueue systemDefultLocalQueue =qMgr.accessQueue("queue1",openOptions);

int counter = 1 ;
while ( true) {
try {

MQMessage getMessage = new MQMessage();
//getMessage.messageId = putMessage.messageId;
MQGetMessageOptions gmo = new MQGetMessageOptions();

systemDefultLocalQueue.get(getMessage, gmo);
String msgText = getMessage.readLine();
System.out.println("MSG #" + counter + " - The message is : " + msgText);
counter ++;
}
catch (MQException e)
{
if (e.completionCode == 2 && e.reasonCode == MQException.MQRC_NO_MSG_AVAILABLE)
System.out.println("All messages read.");
else
System.out.println("MQException: Completion Code = " + e.completionCode + " : Reason Code = " + e.reasonCode);
break;
}

}


systemDefultLocalQueue.close();
qMgr.disconnect();

} catch (MQException ex)
{
System.out.println("An MQSeries error occurred : Completion code " +
ex.completionCode + " Reason code " + ex.reasonCode);
}

Is this the right way ?
Is there a way to get bulk of messages ? and not one by one ?
Is the MQ roll back (transactional )if I took a message and something broke , or should I populate the broken message to an error queue ?

Thanks

Matthew

ungelesen,
22.02.2015, 04:01:5822.02.15
an
The reason that the samples say they are not for production is that you need to consider what you're messaging requirements are in terms of persistence, transactions etc. and how error conditions are going to be handled.

It looks like you are already considering some of these issues - so that is good. I would check the Red Books on MQ for some guidance on these issues. Also in terms of HA facilities.

I would also recommned using JMS as the API. You the features of MQ available, plus it uses a open standard API - that you can get extra guidance as well on line.

Messages are really meant to singular consumption; multiple messages can be browsed. Of course you can also handle multiple messages in a single transaction.. so they all can get rolled back.

Also check IBM Knowledge Centre for details of the backout logic.

Matthew
0 neue Nachrichten