activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asdfg195 <mez5...@psu.edu>
Subject How can I avoid hard coding the remote queue name in @MessageDriven when using resource adapter
Date Tue, 02 May 2017 20:04:05 GMT
I am using an ActiveMQ resource adapter to connect to a remote ActiveMQ queue
on a wildfly server. I have the following code in my jboss-ejb.xml to set up
my resource adapter

<mdb:resource-adapter-binding>
  <ejb-name>MyNotificationMDB</ejb-name>
  <mdb:resource-adapter-name>mq-ra</mdb:resource-adapter-name>
</mdb:resource-adapter-binding>

This maps to the following MDB

@MessageDriven(
    activationConfig = {
    @ActivationConfigProperty(propertyName = "destination", propertyValue =
"Queue.Notifications.Project"),
    @ActivationConfigProperty(propertyName = "destinationType",
propertyValue = "javax.jms.Queue"),
    @ActivationConfigProperty(propertyName = "acknowledgeMode",
propertyValue = "Auto-acknowledge")})
public class MyNotificationMDB implements MessageListener {
 ...
}

This code works, but I do not like having the name of the remote queue hard
coded into my code. I would like to add another layer of bindings so that we
can change the server configuration to change the queue instead of
recompiling and redeploying the code. The only solution I found was to set
an system property in my standalone.xml and add the following to my
jboss-ejb.xml

<enterprise-beans>
    <message-driven>
      <ejb-name>MyNotificationMDB</ejb-name>
      <activation-config>
        <activation-config-property>
         
<activation-config-property-name>destination</activation-config-property-name>
         
<activation-config-property-value>${project.queue.queuename.override}</activation-config-property-value>
        </activation-config-property>
      </activation-config>
    </message-driven>
  </enterprise-beans>

I am not a big fan of this solution since we will have many queues and
setting system properties for each will be a difficult maintenance problem.
Are there any alternative ways that will allow me to not hard code the
remote queue name into my MDB?



--
View this message in context: http://activemq.2283324.n4.nabble.com/How-can-I-avoid-hard-coding-the-remote-queue-name-in-MessageDriven-when-using-resource-adapter-tp4725481.html
Sent from the ActiveMQ - User mailing list archive at Nabble.com.

Mime
View raw message