activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dejan Bosanac <de...@nighttale.net>
Subject Re: How to get broker in code?
Date Fri, 14 Oct 2011 08:20:34 GMT
You get it like any other Spring bean. You can take a look at
SpringBrokerContext for example

https://fisheye6.atlassian.com/browse/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/spring/SpringBrokerContext.java?hb=true

Regards
-- 
Dejan Bosanac - http://twitter.com/dejanb
-----------------
The experts in open source integration and messaging - http://fusesource.com
ActiveMQ in Action - http://www.manning.com/snyder/
Blog - http://www.nighttale.net


On Fri, Oct 14, 2011 at 3:44 AM, kureckam <mkurecka@fractech.net> wrote:

> I have the following spring file that defines my JMS setup. I want to get
> the
> Broker or BrokerService object from within my code so I can delete a
> dynamically created queue. I can wire in the jmsTemplate but how do I get
> the Broker?
>
> <?xml version="1.0" encoding="UTF-8"?>
> <beans xmlns="http://www.springframework.org/schema/beans"
>       xmlns:amq="http://activemq.apache.org/schema/core"
>       xmlns:jms="http://www.springframework.org/schema/jms"
>       xmlns:p="http://www.springframework.org/schema/p"
>       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>       xsi:schemaLocation="http://activemq.apache.org/schema/core
>
> http://activemq.apache.org/schema/core/activemq-core-5.5.0.xsd
>                           http://www.springframework.org/schema/beans
>
> http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
>                           http://www.springframework.org/schema/jms
>
> http://www.springframework.org/schema/jms/spring-jms-3.1.xsd" >
>
>
>   <amq:broker brokerName="fdsBroker"
>               useJmx="false"
>               persistent="true"
>               schedulePeriodForDestinationPurge="10000">
>
>
>      <amq:destinationPolicy>
>         <amq:policyMap>
>            <amq:policyEntries>
>
>
>               <amq:policyEntry queue=">"
>                                gcInactiveDestinations="true"
>                                inactiveTimoutBeforeGC="30000" />
>            </amq:policyEntries>
>         </amq:policyMap>
>      </amq:destinationPolicy>
>
>      <amq:persistenceAdapter>
>
>         <amq:kahaPersistenceAdapter directory="activemq-data"
>                                     maxDataFileLength="1g" />
>      </amq:persistenceAdapter>
>
>      <amq:transportConnectors>
>         <amq:transportConnector uri="tcp://localhost:0"
>                                 discoveryUri="multicast://default" />
>      </amq:transportConnectors>
>   </amq:broker>
>
>
>   <amq:connectionFactory id="jmsConnectionFactory"
>
> brokerURL="tcp://localhost:61616?jms.prefetchPolicy.queuePrefetch=50" />
>
>   <bean id="pooledJmsConnectionFactory"
>         class="org.apache.activemq.pool.PooledConnectionFactory"
>         destroy-method="stop"
>         p:connectionFactory-ref="jmsConnectionFactory" />
>
>
>   <bean id="jmsTemplate"
>         class="org.springframework.jms.core.JmsTemplate"
>         p:connectionFactory-ref="pooledJmsConnectionFactory"
>         p:defaultDestinationName="ACK" >
>      <qualifier value="jmsTemplate" />
>   </bean>
>
>
>   <bean id="startMessageHandler"
>         class="net.fractech.ops.fds.jms.StartMessageHandler">
>      <constructor-arg index="0" value="1.0" />
>   </bean>
>
>   <bean id="dataMessageManager"
>         class="net.fractech.ops.fds.jms.DataMessageManager" />
>
>
>   <jms:listener-container connection-factory="jmsConnectionFactory"
>                           task-executor="jmsExecutor"
>                           destination-type="queue"
>                           cache="auto"
>                           acknowledge="auto"
>                           concurrency="1"
>                           prefetch="1">
>      <jms:listener destination="START" ref="startMessageHandler" />
>   </jms:listener-container>
> </beans>
>
> --
> View this message in context:
> http://activemq.2283324.n4.nabble.com/How-to-get-broker-in-code-tp3903506p3903506.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message