⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 poisonbean.java

📁 EJB3.0请一定要上载质量高而且本站没有的源码
💻 JAVA
字号:
package examples.messaging;

import javax.jms.*;
import javax.ejb.*;
import javax.annotation.PreDestroy;
import javax.annotation.Resource;

@MessageDriven(activationConfig = 
{ @ActivationConfigProperty(propertyName = "destinationType", 
        propertyValue = "javax.jms.Topic") })
public class PoisonBean implements MessageListener {

    @Resource
    private MessageDrivenContext ctx;

    public PoisonBean() {
        System.out.println("PoisonBean created");
    }

    public void onMessage(Message msg) {
        try {
            System.out.println("Received msg " + msg.getJMSMessageID());

            // Let抯 sleep a little bit so that we don抰
            // see rapid fire re-sends of the message.
            Thread.sleep(3000);

            // We could either throw a system exception here or
            // manually force a rollback of the transaction.
            ctx.setRollbackOnly();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @PreDestroy
    public void remove() {
        System.out.println("PoisonBean destroyed.");
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -