activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Gary Tully <gary.tu...@gmail.com>
Subject Re: Want one broker, two turn up
Date Fri, 03 Sep 2010 08:38:42 GMT
see the waitForStart attribute on the vm transport, this can help with
ordering issues as the vm: transport will auto created an embedded
broker by default.

http://activemq.apache.org/the-vm-transport-starts-a-broker-before-my-configured-broker-starts.html

On 3 September 2010 09:15, jsvaughan <jsvaughan@gmail.com> wrote:
>
> Hi,
>
> I have two web apps running in Tomcat and I would like both of them to make
> use of a common activemq broker.  However I seem to have a problem where two
> brokers are started instead.
>
> In my tomcat context.xml I have a single connection factory and two queues
> defined:
>
>       <Resource name="jms/connectionFactory" auth="Container"
>              type="org.apache.activemq.ActiveMQConnectionFactory"
> description="JMS Connection Factory Home"
>              factory="org.apache.activemq.jndi.JNDIReferenceFactory"
> brokerURL="vm:localhost"
>              brokerName="LocalActiveMQBrokerHome" />
>
>       <Resource name="homequeue" auth="Container"
>              type="org.apache.activemq.command.ActiveMQQueue"
> factory="org.apache.activemq.jndi.JNDIReferenceFactory"
>              physicalName="homequeue" />
>
>       <Resource name="policyqueue" auth="Container"
>              type="org.apache.activemq.command.ActiveMQQueue"
> factory="org.apache.activemq.jndi.JNDIReferenceFactory"
>              physicalName="policyqueue" />
>
> In each of my applications I use spring, and have the following in each of
> the app context files:
>
>       <jee:jndi-lookup id="jmsConnectionFactory"
>              jndi-name="java:comp/env/jms/connectionFactory"
> resource-ref="true" />
>
>       <bean id="pooledConnectionFactory"
> class="org.apache.activemq.pool.PooledConnectionFactory">
>              <property name="maxConnections" value="8" />
>              <property name="maximumActive" value="500" />
>              <property name="connectionFactory" ref="jmsConnectionFactory"
> />
>       </bean>
>
>       <bean id="jmsConfig"
> class="org.apache.camel.component.jms.JmsConfiguration">
>              <property name="connectionFactory"
> ref="pooledConnectionFactory" />
>              <property name="transacted" value="false" />
>              <property name="concurrentConsumers" value="10" />
>       </bean>
>
>       <bean id="activemq"
> class="org.apache.activemq.camel.component.ActiveMQComponent">
>              <property name="configuration" ref="jmsConfig" />
>       </bean>
>
> As far as I understand it, the ActiveMQComponent bean binds me via the
> connection factory to the broker, and whichever app starts up first will
> cause the broker to instantiate.
>
> However when I run the application, I see firstly a broker starting without
> a problem (note that I am also binding to this broker with Camel):
>
> 17:29:56,413  INFO main org.apache.activemq.broker.BrokerService:744 -
> ActiveMQ 5.4.0 JMS Message Broker (localhost) is starting
> 17:29:56,414  INFO main org.apache.activemq.broker.BrokerService:746 - For
> help or more information please see: http://activemq.apache.org/
> 17:29:56,607  INFO main
> org.apache.activemq.broker.scheduler.SchedulerBroker:60 - Scheduler using
> directory: activemq-data\scheduler
> 17:29:56,792  INFO main org.apache.activemq.broker.BrokerService:519 -
> ActiveMQ JMS Message Broker (localhost, ID:MV5-53743-1283444996462-0:0)
> started
> 17:29:56,807  INFO main org.apache.activemq.broker.TransportConnector:252 -
> Connector vm://localhost Started
> 17:29:56,916  INFO main org.apache.camel.impl.DefaultCamelContext:956 -
> Route: route1 started and consuming from: Endpoint[direct://HOME]
> 17:29:56,916  INFO main org.apache.camel.impl.DefaultCamelContext:956 -
> Route: route2 started and consuming from: Endpoint[direct://POLICY]
> 17:29:56,917  INFO main org.apache.camel.impl.DefaultCamelContext:956 -
> Route: route3 started and consuming from: Endpoint[activemq://homequeue]
>
> But then subsequently I see (I think I see) a second broker attempting to
> start and failing.
>
> 17:30:08,964  WARN JMX connector
> org.apache.activemq.broker.jmx.ManagementContext:110 - Failed to start jmx
> connector: Cannot bind to URL [rmi://localhost:1099/jmxrmi]:
> javax.naming.NameAlreadyBoundException: jmxrmi [Root exception is
> java.rmi.AlreadyBoundException: jmxrmi]
> 17:30:08,976 ERROR main org.apache.activemq.broker.BrokerService:523 -
> Failed to start ActiveMQ JMS Message Broker. Reason:
> javax.management.InstanceAlreadyExistsException:
> org.apache.activemq:BrokerName=localhost,Type=Broker
> javax.management.InstanceAlreadyExistsException:
> org.apache.activemq:BrokerName=localhost,Type=Broker
>       at com.sun.jmx.mbeanserver.Repository.addMBean(Repository.java:453)
>       at
> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.internal_addObject(DefaultMBeanServerInterceptor.java:1484)
>       at
> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerDynamicMBean(DefaultMBeanServerInterceptor.java:963)
>       at
> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerObject(DefaultMBeanServerInterceptor.java:917)
>       at
> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.registerMBean(DefaultMBeanServerInterceptor.java:312)
>       at
> com.sun.jmx.mbeanserver.JmxMBeanServer.registerMBean(JmxMBeanServer.java:482)
>       at
> org.apache.activemq.broker.jmx.ManagementContext.registerMBean(ManagementContext.java:307)
>       at
> org.apache.activemq.broker.jmx.AnnotatedMBean.registerMBean(AnnotatedMBean.java:54)
>       at
> org.apache.activemq.broker.BrokerService.startManagementContext(BrokerService.java:2044)
>       at
> org.apache.activemq.broker.BrokerService.start(BrokerService.java:474)
>       at
> org.apache.activemq.transport.vm.VMTransportFactory.doCompositeConnect(VMTransportFactory.java:123)
>       at
> org.apache.activemq.transport.vm.VMTransportFactory.doConnect(VMTransportFactory.java:53)
>       at
> org.apache.activemq.transport.TransportFactory.doConnect(TransportFactory.java:51)
>       at
> org.apache.activemq.transport.TransportFactory.connect(TransportFactory.java:80)
>       at
> org.apache.activemq.ActiveMQConnectionFactory.createTransport(ActiveMQConnectionFactory.java:243)
>       at
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:258)
>       at
> org.apache.activemq.ActiveMQConnectionFactory.createActiveMQConnection(ActiveMQConnectionFactory.java:230)
>       at
> org.apache.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:178)
>       at
> org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:137)
>       at
> org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:121)
>       at
> org.apache.activemq.pool.PooledConnectionFactory.createConnection(PooledConnectionFactory.java:92)
>       at
> org.springframework.jms.support.JmsAccessor.createConnection(JmsAccessor.java:184)
>       at
> org.springframework.jms.listener.AbstractJmsListeningContainer.createSharedConnection(AbstractJmsListeningContainer.java:404)
>       at
> org.springframework.jms.listener.AbstractJmsListeningContainer.establishSharedConnection(AbstractJmsListeningContainer.java:372)
>       at
> org.springframework.jms.listener.DefaultMessageListenerContainer.establishSharedConnection(DefaultMessageListenerContainer.java:698)
>       at
> org.springframework.jms.listener.AbstractJmsListeningContainer.doStart(AbstractJmsListeningContainer.java:279)
>       at
> org.springframework.jms.listener.AbstractJmsListeningContainer.start(AbstractJmsListeningContainer.java:264)
>       at
> org.springframework.jms.listener.DefaultMessageListenerContainer.start(DefaultMessageListenerContainer.java:526)
>       at
> org.apache.camel.component.jms.JmsConsumer.startListenerContainer(JmsConsumer.java:80)
>       at
> org.apache.camel.component.jms.JmsConsumer.doStart(JmsConsumer.java:122)
>       at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:56)
>       at
> org.apache.camel.util.ServiceHelper.startService(ServiceHelper.java:53)
>       at
> org.apache.camel.impl.DefaultCamelContext.startServices(DefaultCamelContext.java:1189)
>       at
> org.apache.camel.impl.DefaultCamelContext.doStartRoutes(DefaultCamelContext.java:1357)
>       at
> org.apache.camel.impl.DefaultCamelContext.safelyStartRouteServices(DefaultCamelContext.java:1261)
>       at
> org.apache.camel.impl.DefaultCamelContext.start(DefaultCamelContext.java:952)
>       at
> org.apache.camel.spring.SpringCamelContext.maybeStart(SpringCamelContext.java:203)
>       at
> org.apache.camel.spring.SpringCamelContext.onApplicationEvent(SpringCamelContext.java:101)
>       at
> org.apache.camel.spring.CamelContextFactoryBean.onApplicationEvent(CamelContextFactoryBean.java:231)
>       at
> org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:97)
>       at
> org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:301)
>       at
> org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:888)
>       at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:426)
>       at
> org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:276)
>       at
> org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:197)
>       at
> org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:47)
>       at
> org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:3830)
>       at
> org.apache.catalina.core.StandardContext.start(StandardContext.java:4337)
>       at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
>       at org.apache.catalina.core.StandardHost.start(StandardHost.java:719)
>       at
> org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1045)
>       at
> org.apache.catalina.core.StandardEngine.start(StandardEngine.java:443)
>       at
> org.apache.catalina.core.StandardService.start(StandardService.java:516)
>       at
> org.apache.catalina.core.StandardServer.start(StandardServer.java:710)
>       at org.apache.catalina.startup.Catalina.start(Catalina.java:566)
>       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>       at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
>       at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
>       at java.lang.reflect.Method.invoke(Method.java:597)
>       at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:288)
>       at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:413)
> 17:30:08,979  INFO main org.apache.activemq.broker.BrokerService:555 -
> ActiveMQ Message Broker (localhost, null) is shutting down
> 17:30:08,998  INFO main org.apache.activemq.broker.BrokerService:623 -
> ActiveMQ JMS Message Broker (localhost, null) stopped
>
> So have I misunderstood how ActiveMQ can be used with JNDI?  I have just
> spotted that I have both the activemq-all jar in my tomcat common dir AND
> via maven are putting activemq jars on the classpath as camel dependencies -
> might that be the problem?  Any other thoughts?
>
> Any help whatsover very gladly received
>
> Thanks
>
> Jon
>
> --
> View this message in context: http://activemq.2283324.n4.nabble.com/Want-one-broker-two-turn-up-tp2525279p2525279.html
> Sent from the ActiveMQ - User mailing list archive at Nabble.com.
>



-- 
http://blog.garytully.com

Open Source Integration
http://fusesource.com

Mime
View raw message