Implementing Subscription services within MDB/EJBs

Discussions

General J2EE: Implementing Subscription services within MDB/EJBs

  1. Hello

    I need to be able to develop some sort of Event handler from within a Bean. The job of the event handler is to listen for messages which are published by a SQL API. Everytime a message is picked by the SQL API it needs to be able to write it to a Queue(JMS).
    I had the following idea and was wondering if this was a good way to use MDBs:
    Subscriber sends message to an MDB.

    Thanks

    Ramdas
    =====================================================


    MDB:
    onMessage() {
       create and start EventHandler object
    }

    EventHandler {
        while(TRUE) {
             when(event) {-------> provided by the SQL API
                 sendMessageToSubscriber();
              }
         }
    }
  2. Does the event handler start its own thread? If it does, it is violating the spec. That is what I feel.
  3. Does the event handler start its own thread? If it does, it is violating the spec. That is what I feel.


    I was intially thinking of using threads so that the control could come back to the MDB. But then I realized that the use of threads is not advised within EJBs. That leaves me with the problem of having to dedicate an MDB for every such Event to be handled, since a MDB is now tied to the EventHandler and my application needs to host a variety of these Event Handlers.
    I was wondering if this was a good use of the EJB/J2EE technology?

    Ramdas