3 Replies Latest reply on Aug 30, 2001 2:52 PM by pra

    Can a Message Driven Bean Subscribe to Multiple Topics?

    rakesh

      Anyone know the answer to this? If so, how do you do it?

      Rakesh

        • 1. Re: Can a Message Driven Bean Subscribe to Multiple Topics?

          No it cannot. It can only be tied to one destination. If you want one bean to act on messages frpm multiple destinations you would have to create a central destination and have one MDB per topic, each sending/retransmitting their messages to the central destination.

          On the other hand, since it is only a matter of deplyment configuration to create a new deployable MDB for a new destination, you could have multiple MDB deploy (same bean class, different deployers and EJB names) listening on different destination.

          //Peter

          • 2. Re: Can a Message Driven Bean Subscribe to Multiple Topics?
            rakesh

            Could you clarify a bit more. I don't think I understand.

            Let's say I have a SSB (A), MDB (B) and a seperate java thread in its own JVM (C). C will only publish and subscribe to a single known topic. I want the following interaction. A sends a message to B. B sends a message to C. C then sends a response to B. The problem is the initial message from A also arrives a C, which I don't want. The message arrives at B and C is because B and C are listening to the same topic. Now you are saying to have a central MDB (D). A will send to D, D will discriminate the message and send it C based up information inside the message. When C sends a response it will be send to D, and D will again discriminate the message and send it to B. Is that right?

            I don't think the other scenario applies in my case?

            Regards

            Rakesh

            • 3. Re: Can a Message Driven Bean Subscribe to Multiple Topics?

              > Could you clarify a bit more. I don't think I
              > understand.
              Ok, let's see if I understand your scenario ;-)

              We call the destination TOPIC
              >
              > Let's say I have a SSB (A),

              A client invokes A and A send a MESSAGE TO TOPIC
              > MDB (B)
              B listens on TOPIC does something and want to send it to C
              >and a seperate
              > java thread in its own JVM (C).

              If B publish to C on TOPIC B will get its owm messages, if C respondes to B on TOPIC C will get its own messages.

              Right?

              As far as I can see it there are two possible solutions on this.

              1. Do use separate detsinations. Since MDB:s are stateless there is really no advantage or need to have the send code and the response code in the same bean. I.e, you could actually have destination A (where the session publish and MDB B listens), destination B where B publish and client listens and C where C publish and MDB D listens.

              2. The other way to do it is to use a message selector. I.e set a JMS property depending on who is sending and how should be receiving and set a message selector during subscription.

              //Peter
              C will only publish
              > and subscribe to a single known topic. I want the
              > following interaction. A sends a message to B. B
              > sends a message to C. C then sends a response to B.
              > The problem is the initial message from A also
              > arrives a C, which I don't want. The message arrives
              > at B and C is because B and C are listening to the
              > same topic. Now you are saying to have a central MDB
              > (D). A will send to D, D will discriminate the
              > message and send it C based up information inside the
              > message. When C sends a response it will be send to
              > D, and D will again discriminate the message and send
              > it to B. Is that right?
              >
              > I don't think the other scenario applies in my case?
              >
              > Regards
              >
              > Rakesh