Sync monitoring of async processes


EJB design: Sync monitoring of async processes

  1. Sync monitoring of async processes (2 messages)

    I am using different MDBs in my application to run concurrent processes.

    A Client can request for multiple information, and hence based on the information which is required, my session bean fires multiple MDBs for processing the request currently.

    Once all the MDBs are finished , the Session bean should package all the information and create a single report for the client.

    I have been unable to find a good mechanism for this. Some of the solutions , I have thought through are
    1. Keep checking a DB table to see, if some kind of completion flag is updated. - this is not a good solution, since its too IO intensive and then questions on frequency and intervals complicate the scenario.
    2. Update a static hash with the completion status - This would have problems in a clustered environment, since updates to a hash in one container will not replicate on teh others.
    3. A dynamic queue to which the MDBs write and the Session bean attaches itself to -- This just sounds too complicated.

    I have been looking for a J2EE design pattern for this , but haven't found any. Can anybody help?

    Thanks in advance

    Anuradha Venkatesh
  2. Does your client have to wait when making the initial call to start the process? If yes,then async processing is probably not a good choice. You are better off using normal threading in a divide-an-conquer approach to assemble the final report for your client.
  3. I notice that this is a very similar question as the "Asynchronous process control" thread. In general I'm seeing a lot of people dealing with long-running business processes which should either be parallelizable (using a scatter-gather model for collecting the results, and if possible returning them all as part of a synchronous client request), or cancelable (allowing a client to monitor a long-running process and inject a cancel request in midstream), or both.

    The frustrating thing is that J2EE should provide some good native patterns for this kind of thing -- there should be some best practices -- but apparently there are not!

    If there are, what are they? ;-)
    Anuradha, what did you wind up doing?