try { ... } catch (Exception up) { Message message = session.createMessage(); message.setStringProperty("Exception", up.getMessage()); publisher.publish(message); throw up; }
Interested consumers can receive this notification like this:
public void onMessage(Message message) { System.out.println("Exception: " + message.getStringProperty()); }
This uses a simple Message object, which contains no payload - only JMS headers and properties. As noted in the book, when simple notification is all that is needed, use of the Message type is the most efficient means to do this.
No comments:
Post a Comment