WebSphere MQ Everyplace publish/subscribe methods

The WebSphere MQ Everyplace nodes support a limited subset of the publish/subscribe capability of WebSphere Business Integration Message Broker.

Publish

As with all messages destined for a bridge queue going to WebSphere Business Integration Message Broker, a message type must be specified. For a publish message, this is MQeMbMsgObject.TYPE_PUB.

The field names available are as follows:

MQeMbMsgObject.TOPIC
This contains a string of the single topic to publish to. This attribute is mandatory.
MQeMbMsgObject.RETAINED
This contains a Boolean value. If this is set to true, the publication is retained and therefore unsubscribed clients subscribing will receive the last published value for the given topic. This attribute is optional. If this is not specified, the default value is false (not retained).
MQeMbMsgObject.MQ_Persistence
This contains an integer value containing the persistence value of the message. Value '0' represents a non persistent message. Value '1' represents a persistent message.
MQeMbMsgObject.MESSAGE
This contains an array of bytes representing the payload of the message. This field is mandatory.
This is an example of code:
try
{
   System.out.println("Local QM Name: " + myQM.getName());

   MQeMsgObject mqeMsg = new MQeMsgObject();
   mqeMsg.putInt(MQeMbMsgObject.TYPE_OF_MSG, MQeMbMsgObject.TYPE_PUB);
   mqeMsg.putAscii(MQeMbMsgObject.TOPIC, "Weather");
   mqeMsg.putArrayOfByte(MQeMbMsgObject.MESSAGE, asciiToByte("Hello");
   mqeMsg.putBoolean(MQeMbMsgObject.RETAINED, true);

   System.out.println("..Put message to QM/queue: " + destQueueManager +
                      "/" + destBridgeQueue);
   myQM.putMessage(destQueueManager, destBridgeQueue, mqeMsg, null, 0);
   System.out.println("Finished");
}
catch (Exception e)
{
   e.printStackTrace();
   System.out.println("Failed! " + e);
}

Subscribe

The message type that must be specified for a subscription message is MQeMbMsgObject.TYPE_SUB. The fields names available are as follows:

MQeMbMsgObject.TOPIC
This contains an array of strings containing topics to subscribe to.
MQeMbMsgObject.MQ_DestQueueMgr
This is the returning WebSphere MQ Everyplace queue manager name to send any published messages to.
MQeMbMsgObject.MQ_DestQueueName
This is the returning WebSphere MQ Everyplace queue name to send any published messages to.
This is an example of code:
try {
   System.out.println("Local QM Name: " + myQM.getName());

   MQeMsgObject mqeMsg = new MQeMsgObject();
   mqeMsg.putInt(MQeMbMsgObject.TYPE_OF_MSG, MQeArgoLaunch.TYPE_SUB);
   mqeMsg.putAsciiArray(MQeMbMsgObject.TOPIC, new String[]
                         {"Topic1", "Topic2", "Topic3"});
   mqeMsg.putAscii(MQeMbMsgObject.MQ_DestQueueName, "Inbox");
   mqeMsg.putAscii(MQeMbMsgObject.MQ_DestQueueMgr, "ServerQM1");

   System.out.println("..Put message to QM/queue: " + destQueueManager +
                      "/" + destBridgeQueue);
   myQM.putMessage(destQueueManager, destBridgeQueue, mqeMsg, null, 0);
   System.out.println("Finished");
}
catch (Exception e)
{
   e.printStackTrace();
   System.out.println("Failed! " + e);
}

Unsubscribe

The message type that must be specified for an unsubscription message is MQeMbMsgObject.TYPE_UNSUB. The fields names available are as follows:

MQeMbMsgObject.TOPIC
This contains an array of strings containing topics to unsubscribe from.
MQeMbMsgObject.MQ_DestQueueMgr
This is the returning WebSphere MQ Everyplace queue manager name to send any published messages to.
MQeMbMsgObject.MQ_DestQueueName
This is the returning WebSphere MQ Everyplace queue name to send any published messages to.
This is an example of some code:
try {
   System.out.println("Local QM Name: " + myQM.getName());
   MQeMsgObject mqeMsg = new MQeMsgObject();
   mqeMsg.putInt(MQeMbMsgObject.TYPE_OF_MSG, MQeArgoLaunch.TYPE_UNSUB);
   mqeMsg.putAsciiArray(MQeMbMsgObject.TOPIC, new String[]
                         {"Topic1", "Topic2", "Topic3"});
   mqeMsg.putAscii(MQeMbMsgObject.MQ_DestQueueName, "Inbox");
   mqeMsg.putAscii(MQeMbMsgObject.MQ_DestQueueMgr, "ServerQM1");

   System.out.println("..Put message to QM/queue: " + destQueueManager
                      + "/" + destBridgeQueue);
   myQM.putMessage(destQueueManager, destBridgeQueue, mqeMsg, null, 0 );
   System.out.println("Finished");
}
catch (Exception e)
{
   e.printStackTrace();
   System.out.println("Failed! " + e);
}
WebSphere MQ Everyplace currently does not support any additional features not described here. Messages supported in WebSphere MQ such as request update, are not supported.

Related concepts
WebSphere MQ Mobile Transport
WebSphere MQ Everyplace messages

Related reference
WebSphere MQ Mobile Transport
WebSphere MQ Everyplace point-to-point methods