📄 queuemdb.java
字号:
package testmdb.ejb;
import javax.ejb.EJBException;
import javax.ejb.MessageDrivenBean;
import javax.ejb.MessageDrivenContext;
import javax.jms.*;
/**
* XDoclet-based Message Driven entity bean.
*
* To generate EJB related classes using XDoclet:
*
* - Add Standard EJB module to XDoclet project properties
* - Customize XDoclet configuration
* - Run XDoclet
*
* Below are the xdoclet-related tags needed for this EJB.
*
* @ejb.bean name="QueueMDB"
* display-name="Name for QueueMDB"
* description="Description for QueueMDB"
* destination-type="javax.jms.Queue"
* acknowledge-mode="Auto-acknowledge"
* @jboss.destination-jndi-name name="queue/queueMDB"
*/
public class QueueMDB implements MessageDrivenBean, MessageListener {
/** The MessageDrivenContext */
private MessageDrivenContext context;
public QueueMDB() {
// TODO Auto-generated constructor stub
}
public void ejbRemove() throws EJBException {
// TODO Auto-generated method stub
}
/**
* Set the associated context. The container calls this method
* after the instance creation. <br>
*
* The enterprise bean instance should store the reference to the context
* object in an instance variable. <br>
*
* This method is called with no transaction context.
*
* @param newContext A MessageDrivenContext interface for the instance.
*
* @throws EJBException Thrown by the method to indicate a failure caused by a system-level error.
*/
public void setMessageDrivenContext(MessageDrivenContext newContext)
throws EJBException {
context = newContext;
}
public void onMessage(Message msg) {
// TODO Auto-generated method stub
try{
if(msg instanceof TextMessage){
TextMessage tmsg = (TextMessage)msg;
System.out.println("[ejb2.1,queue]" + tmsg.getText());
}
}catch(Exception ex){
ex.printStackTrace();
}
}
/**
* An ejbCreate method as required by the EJB specification.
*
* The container calls the instance?s <code>ejbCreate</code> method
* immediately after instantiation.
*
* @ejb.create-method
*/
public void ejbCreate() {
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -