Jboss EAP异步方法不起作用

时间:2018-11-22 09:39:09

标签: java asynchronous java-ee jboss jboss6.x

我已经尝试了Web上的所有资源,但是Jboss异步注释不起作用。下面是我尝试调用测试器的课程,

@Stateless
public abstract class TestApplicationBean extends OtherTest implements ESession{
    @Inject
    AsyncBeanTester tester;

    void process() {
        tester.test();
    }

}

这是测试人员课程

@Stateless
public class AsyncBeanTester {
    @Inject
    SFAsyncRemote asyncRemote;

    void test() {

        asyncRemote.test();
    }



}

界面,

@Remote
public interface SFAsyncRemote {
    void test();
}

最后是异步实现

@LocalBean
@Stateless
@TransactionAttribute(TransactionAttributeType.NEVER)
public class ImplAsyncBean implements SFAsyncRemote {

    private static final ELogger log = ELoggerFactory.getLogger(ImplAsyncBean.class);

    @Override
    @Asynchronous
    public void test() {
       try {
            Thread.sleep(10000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        System.out.println("It works");
   }

}

似乎异步注释没有任何作用。但是,我通过Jboss代理进行调用,因此Jboss应该已经异步运行了该功能。但是,线程ID是相同的,整个程序要等待10秒钟才能完成。我在这里做错了什么?此外,当我尝试在asyncRemote上使用@EJB而不是@Inject时,我得到了Could not resolve @EJB injection for @javax.ejb.EJB(name=, lookup=, description=, beanName=, beanInterface=class java.lang.Object, mappedName=) on com.bankframe.bp.retail.solutionset.impl.maintainculsfapplication.SFAsyncRemote com.bankframe.bp.retail.solutionset.impl.maintainculsfapplication.AsyncBeanTester.asyncRemote

0 个答案:

没有答案