dimanche 12 avril 2015

How to create dynamic instance of connection to external activemq broker?

I would like an application which already has an embedded activemq broker to ask a webservice for the location/name of an external JMS standalone broker.


Once the application receives this name from the webservice, it should register a "dynamic" bean, instance of the connection to the external JMS broker (sort of dynamic registration of connection).


If it is a normal "static" connection, I usually use with activemq/spring :



<bean id="jmsConnectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="${externalbrokerurl}"/>
</bean>

<bean id="pooledJmsConnectionFactory" class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
<property name="maxConnections" value="8" />
<property name="connectionFactory" ref="jmsConnectionFactory" />
</bean>


So here I would thus like a way to somehow create a bean instance of a connection to the external activemq with property value of "brokerURL" set to the value received from the webservice.


And a way to refresh this dynamic "connection bean" and all the other beans using it with dependency injection everytime we ask to the webservice a new name of external broker.


How can I do this ?


Aucun commentaire:

Enregistrer un commentaire