1

I would like to have an MDB that fires only after two independent states have been reached. For example:

Event A occurs some time passes Event B occurs MDB onMessage is called as a result of both A and B event occurring A and B events are cleared

So for example if Event B occurs but Event A has not occurred then I do not want the onMessage triggered. Similarly if Event A occurs but Event B has not occurred I do not want the onMessage to fire. I also want Event A and B to be correlated such that when onMessage is fired Events A and B are cleared.

One way to do this would be to have Event A produce a message and the message handler for that would check to see if Event B has occurred but it would have to block and loop until an Event B had fired. The polling scheme seems inefficient.

Functionally this would act like a CyclicBarrier but implemented with messaging.

Any thoughts as to whether or not something like this is possible with MDBs?

MaDa
  • 10,511
  • 9
  • 46
  • 84
NBW
  • 1,467
  • 2
  • 18
  • 27

1 Answers1

1

There is no builtin mechanism for this. I would recommend storing incremental state in a DB table (insert when the first event is received, update/delete when the second event is received).

I would definitely not recommend polling; there are far too many things that can go wrong (hung server threads, wasted CPU, transaction timeouts, etc.).

Brett Kail
  • 33,593
  • 2
  • 85
  • 90