Integrating IBM MQ
You can use Product Master with IBM® MQ to connect Product Master with enterprise applications to send and receive messages.
Before you begin
About this task
The main benefit of integrating with IBM MQ is the enterprise-wide connectivity. Any enterprise application can create the messages for Product Master, and IBM MQ can route these messages.
In some scenarios, an external business process must receive or update the Product Master data. Different organizations within the enterprise can take business decisions that are based on this data. Therefore, integrating Product Master with a competent message-oriented middleware product such as IBM MQ is a good communication option.
A message is defined as input in CSV, XML, or UDF format that is provided by an external source. These messages can be parsed before they are sent or after you receive the messages by using the Script API or Java™ API of Product Master that is provided for interacting with IBM MQ.
- IBM MQ native message format
- These messages can be produced by any IBM MQ support languages.
- IBM MQ JMS
- These messages can be produced by only JMS message aware API provided by IBM MQ. These APIs can be JMS or XMS clients for IBM MQ.
IBM IBM MQ is bundled with Product Master.
Procedure
Example
- Create and start IBM MQ queue manager
WPC_QMGR
crtmqm WPC_QMGR strmqm WPC_QMGR
- Create IBM MQ SVRCONN CHANNEL
WPC.SVRCONN
runmqsc WPC.SVRCONN //define the channel in the command prompt that displays DEF CHL(WPC.SVRCONN) CHLTYPE(SVRCONN)
- Create IBM MQ local queues. You must create
the queue in
runmqsc
command prompt.DEF QL(WPC.IN.QUEUE) DEF QL(WPC.OUT.QUEUE) DEF QL(MY.QUEUE)
- Exit from
runmqsc
by running theend
command. - Start the listener on queue manager
WPC_QMGR
to accept TCP/IP connections.runmqlsr –m WPC_QMGR –ttcp –p1415 & //The & symbol at the end makes //the listener run in the background
//setup properties for MQ
var properties = [];
properties["mqHost"] = "test.ibm.com"; //assign the host name of the machine
// where queue manager is running
properties["mqPort"] = "1415"; //The port number of the listener through
// which we can connect to queue manager
properties["mqChannel"] = "WPC.SVRCONN"; //CHANNEL name through which
// we connect to queue manager
properties["mqManager"] = "WPC_QMGR"; //Queue manager name
properties["mqInqueue"] = "WPC.INPUT.QUEUE";
properties["mqOutqueue"] = "WPC.OUTPUT.QUEUE";
properties["myQueue"] = "MY.QUEUE";
MY_MQ_HOST = properties["mqHost"];
MY_MQ_PORT = properties["mqPort"];
MY_MQ_CHANNEL = properties["mqChannel"];
MY_MQ_MGR = properties["mqManager"];
MY_MQ_INBOUND_QUEUE = properties["mqInqueue"];
MY_MQ_OUTBOUND_QUEUE = properties["mqOutqueue"];
function sendMessage(Item)
{
//First get the Queue manager
qMgr = mqGetQueueMgr(MY_MQ_HOST, MY_MQ_PORT, MY_MQ_CHANNEL, MY_MQ_MGR);
//Doing a send message
mqSentMsg = qMgr.mqSendTextMsg(Item, MY_MQ_QUEUE, MQ_OPEN_OPTIONS, MQ_PUT_OPTIONS);
textMsg = mqGetTextFromMsg(mqSentMsg);
out.writeln("Sent Message :"+textMsg +"\n\n");
}
function createXMLMsg()
{
var text = ""
+ "<msg>"
+ "<item"
+ "<sku>123456</sku>"
+ "<quantity>1</quantity>"
+ "<Price>99.99</Price>"
+ "</item>"
+ "</msg>";
return text;
}
function receiveMsg()
{
qMgr = mqGetQueueMgr(MY_MQ_HOST, MY_MQ_PORT, MY_MQ_CHANNEL, MY_MQ_MGR);
//Receive message from MY.QUEUE
mqMsg = qMgr.mqGetReceivedMsg(MY_MQ_QUEUE, MQ_OPEN_OPTIONS, MQ_GET_OPTIONS);
textMsg = mqGetTextFromMsg(mqMsg);
out.writeln("\n\nReceived Message : "+textMsg +"\n\n");
}
Msg = createXMLMsg();
sendMessage (Msg);
receiveMsg();