English 中文(简体)
背 景
原标题:Background threads
  • 时间:2011-11-21 22:04:37
  •  标签:
  • jakarta-ee

I am using Websphere Application Server to create a typical web application where UI is JSPs, there is a Controller and a session EJB and a Database. I implemented a notification system which runs in the backround as a separate thread. I used WorkManager for that purpose.

My problem is, I want to start the WorkManager without having to create a session or an EJB instance for every single of the parallel sessions started by different users. It should not be session based. Right now, the WorkManager thread kicks off when the EJB is instantiated, so if there are 3 connections, there are 3 WorkManager instances.

单州会议是否好? 或者,在什么地方,我可以采用一种主要()方法,称为或其他类似方法?

任何想法都会受到赞赏。

最佳回答

我认为,你有几种选择:

  • Submit the work using a servlet context listener (which will be invoked when the WAR module is started/stopped).
  • Use a startup bean (WebSphere specific API) which is invoked once when the application is started/stopped.
  • Use a reference counting approach where you keep track of the number of EJB instances. You submit the work when the first instance is created (and stop it when the last instance is destroyed). Note that this will delay the start of the work until the first request to the EJB is made.
  • In WebSphere 8 (which supports Java EE 6) you could probably use a singleton session bean.
问题回答

暂无回答




相关问题
Recommended way to develop using Jetty and Eclipse

I am currently developing a J2EE application and I would like to use Jetty. I would like to have iot integrated with Eclipse, so I could debug the appliaction. I ve tried out couple of plugins (...

Call function periodically in Java

we need run one function periodically in Java web application . How to call function of some class periodically ? Is there any way that call function when some event occured like high load in server ...

Why make an EJB rather than a Web Service?

I would have thought that there is a lot of information out there on this, but I haven t found anything that really answers my question. What are the advantages of making an EJB rather than a web ...

Where should I put this configuration setting?

I m designing a fairly small web application which will run on a Sun application server (v9.1). It only has a few pages, no database of its own, and will retrieve/update data via web services. There s ...

JNDI Names -- Is Prefix "jdbc/" needed?

What s up with JNDI names? I m trying to get a javax.sql.DataSource using the new annotations feature of Java 5. It s not working for me, so I want to ask... I have a in my web.xml, inside of it is ...

hibernate interceptors : afterTransactionCompletion

I wrote a Hibernate interceptor : public class MyInterceptor extends EmptyInterceptor { private boolean isCanal=false; public boolean onSave(Object entity, Serializable arg1, Object[] arg2, String[]...

热门标签