Wednesday, 7 August 2013

How to design & access a service from Java Web Application?

How to design & access a service from Java Web Application?

I'm developing a Twitter application in Java (Tomcat, hibernate, Netbeans
IDE, MySQL, Windows 7) which gets content by keyword from RSS feeds and
posts to Twitter. I've written the admin panel and functionality but I
want this service to run continuously in 'background' and to be able to
start/stop it from my web application.
How should I design this? I did a similar app years ago which used threads
(somehow I got a handle on the threads & maintained state, I forget how)
but am not sure if this is good design.
I've done some EJB & this might be "right" design but want to avoid that
framework if possible (slow development & no Tomcat support). I don't
think a cron solution is right since a) it's business logic and b) I will
post at random intervals, not once every x minutes. The big thing is: how
do I create, get a handle on, and maintain state for a background thread
from a Servlet application?
Edit: Found this: Thread pool with ServletContextListener and
servletcontextlistener seems a promising option but I'm not sure if it is
good design.

No comments:

Post a Comment