Question

I have 2 Message driven beans. 2 Activation Specs for these beans. I have one Message bus and both the activation specs are configured to this one bus. I have 2 different queues and one queue connection factory configured for that one Message bus.

Now, I would write my code to send a message to one of the queues at runtime after determining the queue. However, both my MDBs receive the same message. How is this configuration done in general? Do I always configure 1 Queue -> 1 Queue Connection Factory -> 1 Message Bus -> 1 MDB? Is it all a one-to-one relationship?

Oh, I forgot to mention this: I am using Websphere Application Server v6.1

Was it helpful?

Solution

In general the concept is that:

  1. a message is sent(Queue)/published(Topic) to a destination (Queue/Topic)
  2. the ActivationSpec listens to messages at a particular destintation (Queue/Topic)
  3. ActivationSpec : Destination is a 1:1 relationship
  4. A bean (MDB which is a consumer) is configured to listen to an ActivationSpec.

What this means is that in effect the bean is linked to a destination with a layer of indirection provided by the activationSpec.

Where does the bus come in - SIBus is the messaging infrastructure that makes all this possible. Destinations are hosted on the bus.

Coming to the question - the ActivationSpec would be configured to listen to a destination on the bus to which messages would be sent. The connection factory decides the bus to which message would be sent. As long as the destination name is unique and targetted to a specific queue (JMS Queue is linked to destination on the bus) one message would only be received by one ActivationSpec.

how many destinations (under SIBus link in WAS admin console) have been created on the bus ? Could you check/validate if the configuration is correct?

to answer your questions - "Is it one bus per activation spec and one queue connection factory per queue." - the answer is NO.

  1. Bus is the underlying infrastructure that can host "n" destinations. One ActivationSpec listens to one destination.
  2. With queue connection factory is a factory (J2EE factory pattern) for creating queues.

OTHER TIPS

I think you're saying you want both MDBs to receive the same message, right?

If this is the case then the MDBs should be listening to a topic not a queue.

Alternatively, there are ways you can configure IBM MQ to forward messages, so for example a message posted to a particular queue could be re-posted to n other queues, but I've only seen that used when some sort of message enrichment takes place before the re-posting and so I suspect would be overkill for what you're trying to achieve.

Why do you need the message bus?

Usually I associate an MDB with a queue - it's a 1:1 relationship. Send a message to a queue, the listener gets it. What is the bus buying you?

I've done JMS with WebLogic, and there's no such construct as a message bus required. I think it's an IBM thing.

Here's an example of how to do JMS with Spring. That's how I'd recommend proceeding.

UPDATE: I misinterpreted your question. When you said both your queues were getting the same message, I didn't think that was the desired behavior. If it is, then topics are the correct way to go. Queues are point-to-point messaging; topics are publish/subscribe.

I suspect the configuration you have is not set up the way you think it is. We use the same configuration your described, with many MDB's (with a queue and activation spec), a single factory and message bus and everything works as expected.

To get the behaviour you are seeing is not actually possible unless you either send the same message to both queues, or have defined a topic instead of a queue. I am pretty sure that even if both MDB's are reading from the same queue, only one will get the message, since a queue only supports point to point messaging. What you have described is topic based behaviour.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top