2 Replies Latest reply on Mar 16, 2005 11:35 PM by zurchman

    Long-running Session beans

    zurchman

      Is there any way for a stateless session bean to periodically relinquish it's processing time?

      I'm using JMX in an application to periodically invoke a stateless session bean that polls a number of resources for availability.

      The problem is that the polling may require 3 to 4 minutes to complete, and it seems to block other beans from processing during that time.

      The polling bean updates entity beans that are used by other session beans, but each entity bean is updated within 10 seconds.

      I get the impression once a Thread is fired, the container basically blocks everything while waiting for the Thread to complete.

      I expect I'm going to get quite an education here.

      Thanks.



        • 1. Re: Long-running Session beans
          ianmarshall

          If the thread of execution of your polling stateless session bean cannot yield to other threads before it finishes execution (others may help you here), one work-around could be to split your polling into discrete tasks which can be invoked in succession but with time intervals between them.

          If your design allows this splitting of polling, then you could convert your session bean into a stateful one and invoke the relevant method more often. The session bean could then perform one of the discrete polling tasks at each invocation. The bean's state can then be used to decide which polling task to perform each time.

          • 2. Re: Long-running Session beans
            zurchman


            The Stateful session bean is a good idea.

            For the sake of expedience, I now have the MBean firing an EJB client which triggers the polling through the original Stateless bean's local interface.

            That approach primarily buys me Thread.yield() with no hidden consequences.