EJBs and Thread sleeping..

Discussions

EJB programming & troubleshooting: EJBs and Thread sleeping..

  1. EJBs and Thread sleeping.. (1 messages)

    Ok here is the situation:

    1. I have a stateless session bean that publishes a message to the network.

    2. The bean needs to wait for a database update to occur, ( done by a different process that was triggered by the message in #1)

    3. If the update does not occur within a timeout period then the method call is aborted via an exception.

    If I do a Thread.Sleep( some time ) and check the database in a loop inside of a stateless session bean method, what kind of container issues will I have ?

    I know the j2ee spec says no thread management but, it seems that the thread sleep will appear to the container as a long running method.

    Comments?

    Thanks!
  2. EJBs and Thread sleeping..[ Go to top ]

    I'd rather wait for an 'acknowledgement' message (note that this is a message different from the ack you receive when you post a mesge to the JMS server) basically you should call (message = ) MessageConsumer.receive(timeoutValueInMillis) and wait for this message... if the message is null, the proactive wait timedout otherwise the data was posted to the db.