backgroud thread


EJB programming & troubleshooting: backgroud thread

  1. backgroud thread (1 messages)

    I need to do something in the jboss server periodically.
    I know user can't create thread in the j2ee server, then how can i do that?

    I can run another process, which will notify a message-driven bean in jboss periodically, then the bean will do something.
    is that the only solution?
  2. JMX? JBoss Scheduler?[ Go to top ]

    Don't forget that JBoss is foremost a JMX container. So you can simply write an MBean that spawns (and manages) it's own background thread for performing actual task.

    Personally, we use this background thread to post messages to JMS queue, so it's almost the same thing you are suggesting. However, I guess that it's better to have a managed entity (MBean) in managed environment (JMX) rather then stand-alone program.

    Also, if your “periodically” tasks should be fired at fixed-rate intervals, do not reinvent the wheel at all -- JBoss has build-in Scheduler MBean. You can easily plug necessary code to fire JMS message by some kind of “onTimer” event. More details in paid doc (but, AFAIK, some info available in QuickStart as well).

    Hopefully, the situation will change with J2EE 1.4 when we get (at last) Timer MDB.