0
votes

Is it possible to dynamically assign a runtime value for "destination" in MDB (Message Driven Bean)?

The annotation based approach forces to hardcode it on MDB

@MessageDriven(name="PingPongMDB", activationConfig = {
    @ActivationConfigProperty(
            propertyName = "destinationType", 
            propertyValue = "javax.jms.Queue"),
         @ActivationConfigProperty(
            propertyName = "destination", 
            propertyValue = "ref_fooQueue")})
public class PingPongMDB implements MessageListener {

I also tried the ejb-jar.xml approach, but value for "activation-config-property-name" = "destination" is read as a literal physical name of queue. Hence I am not able to do a JNDI lookup of the resource.

<message-driven>

  <ejb-name>PingPongMDB</ejb-name>
  <ejb-class>com.company.sample.services.PingPongMDB</ejb-class>

  <messaging-type>javax.jms.MessageListener</messaging-type>

  <activation-config>
    <activation-config-property>
      <activation-config-property-name>destination</activation-config-property-name>
      <activation-config-property-value>openejb:Resource/ref_fooQueue</activation-config-property-value>
    </activation-config-property>
    <activation-config-property>
      <activation-config-property-name>destinationType</activation-config-property-name>
      <activation-config-property-value>javax.jms.Queue</activation-config-property-value>
    </activation-config-property>
  </activation-config>

</message-driven>

What is the right way to read and assign the destination from properties or pass the value using -D params?

1

1 Answers

0
votes

If anyone encounters it, it was solved on http://tomee-openejb.979440.n4.nabble.com/TomEE-override-parameterize-ActivationConfigProperty-td4680969.html

story short: using last version makes it possible to use placeholders