ibm mq - Websphere MQ using XMS.Net -
i wanted understand how can use web sphere mq following scenario:
1.how can read message queue without removing message queue. 2. have web application need listener read queue. there tool ?
yes, it's possible read message without removing queue, it's known browsing. need create browser consumer read messages. have posted snippet here, same code available in tools\dotnet\samples\cs\xms\simple\wmq\simplequeuebrowser\simplequeuebrowser.cs
also.
// create connection. iconnection connectionwmq = cf.createconnection(); // create session isession sessionwmq = connectionwmq.createsession(false, acknowledgemode.autoacknowledge); // create destination idestination destination = sessionwmq.createqueue(queuename); // create consumer iqueuebrowser queuebrowser = sessionwmq.createbrowser(destination); // create message listener , assign consumer messagelistener messagelistener = new messagelistener(onmessagecallback); queuebrowser.messagelistener = messagelistener; // start connection receive messages. connectionwmq.start();
callback method
static void onmessagecallback(imessage message) { try { // display received message console.write(message); } catch (exception ex) { console.writeline("exception caught in onmessagecallback: {0}", ex); } }
Comments
Post a Comment