Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

design question  RSS feed

 
Kevin Sullivan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a trouble ticketing system written using EJBs, Servlets, JSP. My company now wants an automatic escalation system that alerts the manager when the ticket is still open over its deadline.
So basically I need a way to constantly query the database comparing current time with deadline times.
This might be possible using triggers and stored procedures on the Database side, but i was hoping to do this in java.
MY QUESTION: how would i go about doing this, would I create a session bean in a constant loop querying the database, would i have to implement runnable so i wouldnt lock up the system. If so how would I thread my session bean. Is there a better solution.
any help would be great thanks.
Kevin
 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, there are several important questions which need to be asked before deciding on a solution for this sort of problem:
1. How much time is allowed to elapse after a ticket "expires" before notification must be sent (1 second, 30 minutes, 1 hour, 3 days, 2 weeks etc.)? Without this you will never be able to set up or test any kind of polling style process as you initially described.
2. What is the estimated proportion of tickets which will "expire" compared to those which are added and terminated by other means? Knowing this proportion (albeit as an informed guess) should help you choose between a predictive vs a responsive solution.
3. Do these tickets typically take a "long" time to expire (long enough that any internal state in the monitoring process will need to be persisted in case of hardware, power or network failures, for example)?
4. Are there a "lot" of open tickets typically in the system? (enough that repeatedly querying them all would be a slow or heavy-load process)?
5. Is it OK for notification on the same ticket to be sent more than once? If not, is the indication that a notification has been sent stored with the ticket, or will the monitor process need to track (and persist) that?
I'm sure there are more similar questions, but I hope you get the picture.
If you have a fairly loose notification time requirement and querying all the open tickets is feasibly quick, then polling seems a reasonable solution, but do it as rarely as you can get away with. Also make sure that your polling process will restart sensibly and that any internal state is persisted in a usable and recoverable way.
If querying all the tickets is a heavy job, and a ticket typically takes a long time to "expire", you may want to adopt a more predictive approach: Each time you poll the system, take a not of the time at which the next ticket expires (or the next time at which a newly added ticket might expire) and sleep your monitor process until then.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!