2

Why We can set only single destination type in message driven bean in EJB?

@MessageDriven(activationConfig = { 
@ActivationConfigProperty(propertyName = "destinationType", propertyValue = "javax.jms.Queue"), 
@ActivationConfigProperty(propertyName = "destination", propertyValue = "FileProcess"), 
@ActivationConfigProperty(propertyName = "transactionTimeout", propertyValue = "3600"), 
@ActivationConfigProperty(propertyName = "maxSession", propertyValue = "100") })
@TransactionManagement(value = TransactionManagementType.CONTAINER)
public class FileMDB implements MessageListener {

  //.....
}

I want to add more than one destination type for a single MSD , Can i add more than one queue name or destination type in a MDB class?

MaDa
  • 10,511
  • 9
  • 46
  • 84

1 Answers1

0

The short answer is: because Sun (and JSR expert groups) designed it that way.

The longer answer: I'm guessing that you need to handle many queues which all contain messages of the same format, and it does not matter to your service where the message came from. You can:

  1. Implement a base class implementing MessageListener interface and inherit from it as many times as you wish, each time applying different @ActivationConfigProperty annotation.
  2. (a better option) If your messaging system allows, create an extra queue and configure all the queues that are of interest to your application to pass messages to that queue. Then you can stay with your current MDB configuration, without the need to produce boilerplate code.
MaDa
  • 10,511
  • 9
  • 46
  • 84