• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

MQSeries programming with Java API and JMS API

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do we read(but not getting the message from) XML messages from a MQ queue which is point to point,asynchronous communication and also store them in an unix file system?
The purpose of reading a XML Message is to archive the data into an unix file.
Please answer me soon
It's very important and urgent
[ August 20, 2003: Message edited by: Thirumaran Somasundaram ]
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can user the following class.
javax.jms.QueueBrowser
 
S SG
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
public Message[] getMessages(String qLookup) throws NamingException, JMSException {
Queue ioQueue = null;
javax.jms.QueueBrowser queueBrowser = null;
Enumeration enum = null;
Message[] msgs= null;
try{
connect();
ioQueue = getQueueFromJNDI(qLookup);

// Create a QueueReceiver in the same way
//System.out.println( "Creating a Queue Browser");
if(getMsgSelector()==null){
queueBrowser = jmssession.createBrowser(ioQueue);
}else{
queueBrowser = jmssession.createBrowser(ioQueue,getMsgSelector());
}
//System.out.println("Starting the Connection");
connection.start();

//System.out.println( "Reading the message back again" );
enum = queueBrowser.getEnumeration();
//count the number of messages on the Queue
int count =0;
while(enum.hasMoreElements()){
enum.nextElement();
count++;
}
//put messages in an array.
enum = queueBrowser.getEnumeration();
int index = 0;
msgs = new Message[count];
while(enum.hasMoreElements()){
Object msg = enum.nextElement();
msgs[index]=(Message)msg;
index++;
//System.out.print(msg);
}
}catch(JMSException e){
logger.severe(cxom.util.Common.getStackTrace(e));
logger.severe(e.toString());
throw e;
}finally {
try {
if (connection != null) {
connection.stop();
}
}catch(Exception e){/**/}
try {
if (queueBrowser != null) {
queueBrowser.close();
}
}catch(JMSException e){/**/}

disconnect();
}
return msgs;
}
 
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic