How to catch exception of JMS when call onMessage()?
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   founder_chen
Posted On:   Wednesday, July 24, 2002 07:24 AM

I write a consumer client implement onMessage(), in my main() method ... try { _adapter = new Adapter(checkConsumer,env); _adapter.setSelector("client = 'Receive1'"); _adapter.start(); System.out.println("Hello..."); } catch(Exception e) { _adapter = null; System.out.println("Unable to start adapter: " + e.getMessage()); } ... _adapter.start() will call onMessage() my onMessage like this ... public void onMessage(Adapter adpt, Message message) { try { if(message instanceof TextMessage) { // Write the text out as read String text = ((TextMessage)message).getTex   More>>

I write a consumer client implement onMessage(),

in my main() method
...
try {
_adapter = new Adapter(checkConsumer,env);
_adapter.setSelector("client = 'Receive1'");
_adapter.start();
System.out.println("Hello...");
} catch(Exception e) {
_adapter = null;
System.out.println("Unable to start adapter: " + e.getMessage());
}
...

_adapter.start() will call onMessage()

my onMessage like this
...
public void onMessage(Adapter adpt, Message message) {
try {
if(message instanceof TextMessage) {
// Write the text out as read
String text = ((TextMessage)message).getText();
// Do CHECK Process
adpt.demoOut("Receive CHECK Text is :" + text);
//System.out.println("class name is " + consumerName);
} else {
// This is just a message (no particular type)
}
} catch (Exception e) {
try {
adpt.warn("Error outputing data: " + message.getJMSMessageID());
} catch(Exception ignore) {
}
adpt.warn(" Error: " + e.getMessage());
// Do some exception process
}
}
...


If the JMS Server shutdown, how can I catch the exception?

   <<Less
About | Sitemap | Contact