activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Justin Bertram <jbert...@apache.org>
Subject Re: How can I avoid hard coding the remote queue name in @MessageDriven when using resource adapter
Date Wed, 03 May 2017 12:19:25 GMT
As Clebert mentioned, this is more of an application server question.  The broker and/or resource
adapter don't control the deployment of the MDB, that's the EJB container's job.

That said, I believe the latest versions of Wildfly support using a system property in the
annotation itself rather than the deployment descriptor. For example:

  @ActivationConfigProperty(propertyName = "destination", propertyValue = "${project.queue.queuename.override}")

Of course this doesn't get around having to use system properties, but this has been the solution
for this problem in Wildfly and JBoss AS before it for the last 10 years or so.

One more thing...You can use the @ResourceAdapter annotation rather than <mdb:resource-adapter-binding>
in your deployment descriptor to define the RA you want to use.


Justin

----- Original Message -----
From: "Clebert Suconic" <clebert.suconic@gmail.com>
To: users@activemq.apache.org
Sent: Tuesday, May 2, 2017 4:41:09 PM
Subject: Re: How can I avoid hard coding the remote queue name in @MessageDriven when using
resource adapter

That's more a question to the application server guys.. I would ask
that question to wildfly. I believe there's a thing you can do that..
some guys from Wildfly I know are part of this list but i doubt they
follow this on a daily basis, so you would be better asking this
question to wildfly guys at their user forum.

On Tue, May 2, 2017 at 4:04 PM, asdfg195 <mez5001@psu.edu> wrote:
> 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.



-- 
Clebert Suconic

Mime
View raw message