/*
Copyright (C) NEC Corporation 2004
NEC CONFIDENTIAL AND PROPRIETARY
All rights reserved by NEC Corporation.
This program must be used solely for the purpose for which
it was furnished by NEC Corporation. No part of this
program may be reproduced or disclosed to others, in any
form, without the prior written permission of NEC
Corporation. Use of copyright notice does not evidence
publication of the program.
*/
package sample;
import javax.ejb.*;
import javax.jms.*;
public class MDBSimpleBean implements MessageDrivenBean, MessageListener {
private MessageDrivenContext messageContext;
public MDBSimpleBean() {}
public void setMessageDrivenContext(MessageDrivenContext arg0) {
this.messageContext = arg0;
}
public void ejbCreate() {
System.out.println("ejbCreate() called");
}
public void ejbRemove() {
System.out.println("ejbRemove() called");
}
public void onMessage(Message arg0) {
if(arg0 instanceof TextMessage) {
try {
TextMessage mess = (TextMessage)arg0;
System.out.println("Message received: " + mess.getText());
} catch(JMSException ex) {
System.err.println("Exception caught: " + ex);
}
} else {
System.out.println("Unmatched message type!");
}
}
}
|