01: package example;
02:
03: import javax.jms.*;
04: import javax.webbeans.*;
05:
06: public class MyListener implements MessageListener {
07: @In
08: private MessageStoreService _messageStore;
09:
10: public void onMessage(Message message) {
11: try {
12: if (message instanceof TextMessage) {
13: String text = ((TextMessage) message).getText();
14:
15: _messageStore.addMessage(text);
16: } else if (message instanceof ObjectMessage) {
17: Object value = ((ObjectMessage) message).getObject();
18:
19: _messageStore.addMessage(String.valueOf(value));
20: } else
21: _messageStore.addMessage(String.valueOf(message));
22: } catch (JMSException e) {
23: throw new RuntimeException(e);
24: }
25: }
26: }
|