activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kureckam <mkure...@fractech.net>
Subject How to get broker in code?
Date Fri, 14 Oct 2011 01:44:18 GMT
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
View raw message