[jboss-user] [EJB 3.0] - Re: @PostConstruct and @PreDestroy in JBoss AS 5.0.0CR2
do-not-reply at jboss.com
Mon Sep 22 11:01:58 EDT 2008
"aojensen" wrote : @jakiran: I already tried the @Service extension for EJB 3.0 in JBoss but it didn't work out properly.
When you say, it doesn't work, what exactly happens? Any exceptions?
"aojensen" wrote :
| I am developing a simple mail daemon/service) that looks up new entries in a table called mail_events (mapped to an EJB entity called MailEvent). The service runs as a while loop in a separate thread that loads new MailEvents from the database and processes each message according to a template (e.g. sends out a mail to a newly registrated user with login information). I considered using JMS, but this is not possible due to several environmental issues (we depend on other legacy applications that do not speak JMS -- hence we just use a relational database).
| Currently I have made a EJB called QueueExecuterBean that is a stateless session bean which implements QueueExecuterLocal. This bean loads a singleton class, QueueRunner which extends java.lang.Thread. Hence, QueueRunner is the aforementioned thread that polls for new entries in the MailEvents table (using a proper Facade).
| As such, I am open to any other design solution to this problem. I am not saying that my @PostConstruct/@PreDestroy solution with an integrated singleton thread is the optimal solution.
| Could you give any other architectural advises on the event queue application?
Creating threads in the EJB is not recommended. Instead of polling through a thread, you could have a scheduler which has a job scheduled every x seconds/minutes. The job will then look for any new MailEvents in the database. Maybe you can use this http://wiki.jboss.org/wiki/QuartzSchedulerIntegration
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4178089#4178089
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4178089
More information about the jboss-user