(EJB) Design to process jobs in the FIFO order.

Discussions

EJB design: (EJB) Design to process jobs in the FIFO order.

  1. Hi, Here's my requirement, I have a session bean which receives jobs from outside. these jobs are usually database inserts/updates and deletes. These jobs can be isolated operations or part of a one single transaction. but the most important requirement is they must be executed in the exact order they are received. that is the jobs should maintain the FIFO order they are received. my initial idea was to use a message driven bean to do the processing. but later learned that MDB's does not guarantee the FIFO order. And another requirement is that the job should give feedback (whether success or failure) to the caller. can anyone help me with an idea for me to come up with a suitable design solution. thanks in advance
  2. Hi I think that stateful session bean can help, so you will have fifo in the scope of single session (one client scope). Please give us some feedback if it have helped.
  3. Hi thanks for the advice.. but its not one client scoped. each job must be processed in the order they are recieved irrespective of the client. on the other hand statefuls cannot be used since im expecting to expose the bean as a web service.
  4. hi So web service.... so you have no choice other than using a Singleton and synchronization mechanizim, unfortunately it implies bad performance and possible dead-locking but it's the only solution in that context. My advice is to think about other types of synchronization eg. unique-ids as timestamps or sequencers (eg. from data base). good luck
  5. Unfortunately there is no smart solution I have implemented for this yet. Please post with what you sticked to finally.
  6. Maybe you can implement a queue using one service that receive petitions and store them into a database with a timestamp and another timer based service that retrieve petitions from the database in your desired order and then do process and remove it from the db....
  7. Hi,
    Here's my requirement,
    I have a session bean which receives jobs from outside. these jobs are usually database inserts/updates and deletes. These jobs can be isolated operations or part of a one single transaction. but the most important requirement is they must be executed in the exact order they are received. that is the jobs should maintain the FIFO order they are received. my initial idea was to use a message driven bean to do the processing. but later learned that MDB's does not guarantee the FIFO order. And another requirement is that the job should give feedback (whether success or failure) to the caller. can anyone help me with an idea for me to come up with a suitable design solution.

    thanks in advance
    you can make sure that the MDB works in FIFO by implementing restrictions on the max instances of the MDB that the app server uses. You force it to use only one instance and you have FIFO. It is a hack but it can be done....... I think it is the max-beans-in-free-pool
  8. thanks again guys, Finally I decided to alter the architecture of the system. restricting the MDB was a working solution. (In fact it meets my requirement). but it is going to be a huge performance bottleneck when about 50000-2000000 requests comming per seconed. it contradicts the parellel processing. The thing is I had no solution for the problem. Instead I decided to implement a different queue for each database table. I do this by using synchronization and singletonm with the the help of internal locking in JDBC.
  9. "50000-2000000 requests comming per seconed" are you sure about the "second" or '000 ?. Sorry please dont be offended but this means a huge load on JMS and Database. I dont how your app server will cope up with this load. I suspect the using JMS will cause trouble for you in future if the queue ends up having huge backlog (which can happen in few seconds). Please remembet that JMS is not meant for such load (although claimed by app servers). But if you wish to stick to JMS solution then you can do atleats the following:- 1. Pick up message from queue 2. Dump it in DB schema with a timestamp (either JMS time stamp or your DB timestamp ) 3. Free up the JMS transaction. This will ensure that MDB is freed up asap once the message has been dumped into DB. It will pick up the next message for processing. Also use JMS file store (not DB store). Set up another component which picks up these messages from DB in order of timestamp and processes them. You can send the reply back to clients at this point of time. shrini