Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Managing very long time operations with Java

Actually, I have the following flow:

  1. User click in "huge operation" button;
  2. It call a RESTful service;
  3. The rest service call an the HugeOpServiceBean, which is an EJB;
  4. This EJB will tell to the JMS queue to do the HugeOperation;
  5. This HugeOperation could have two or more implementations, so, every MDBean that is listening for it will run (which means that it could be in another .ear)

I'll like to hear how you guys do or suggest me to made me able to get the "status" of these MDBeans.

Basically, each MDBean will run some method in a list of some object type, so, calc the percentage done should be easy, I just don't know how and which is the best architectural decision I could make to made this accessible in some RESTful service.

Thanks in advance.

like image 628
caarlos0 Avatar asked Jan 21 '13 20:01

caarlos0


2 Answers

The RESTful way of handling this would be to:

  1. Return an HTTP 202 status code 'Accepted' to the client, after the first call, to indicate that the request was successful, but further processing is required. You can also supply a URI with the response that the client can use to query the status of the 'job'
  2. Implement an endpoint that the client can call to query the status of the job.
  3. When the operation is complete, the endpoint from 2) above would issue a permanent redirection to the actual URI of the main entity created by the operation.
like image 124
Perception Avatar answered Oct 22 '22 13:10

Perception


Since MDB consumption and treatment is transacted, it's all or nothing. Showing progress will be complicated and will require sub transaction to update the progress. I would suggest to chunnk the work in multiple JMS messages in the EJB and monitor progress in term on JMS messages successfully consumed later. See Patterns of Enterprise Integation

like image 2
ewernli Avatar answered Oct 22 '22 12:10

ewernli