camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marco Crivellaro <marco.cr...@gmail.com>
Subject camel shutsdown route even when using failover
Date Tue, 19 Feb 2013 10:45:51 GMT
Hi All,
I am setting up a camel context with 2 routes consuming 2 ActiveMQ queues.
The connectionstring to the broker specifies failover protocol, however if
the broker for some reason goes offline the context shutsdown itself
automatically. Is there a way to keep the context trying to reconnect to
ActiveMQ?

my spring context is as following:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
         http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
         http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd">

  <camelContext id="hulkcontext"
xmlns="http://camel.apache.org/schema/spring" autoStartup="false">
    <package>com.crive</package>
    
    <route>
   		<from uri="jms:queue:crive.data"/>
   		<to uri="bean:myDataProcessor"/>
   		<inOut uri="mock:dataresult" />   		
	</route>
	<route>
   		<from uri="jms:queue:crive.status"/>
   		<to uri="bean:myStatusProcessor"/>
   		<inOnly uri="mock:statusresult" />
	</route>
    
    
  </camelContext>

  
  <bean id="myDataProcessor" class="com.crive.DataProcessor"/>
  <bean id="myStatusProcessor" class="com.crive.StatusProcessor"/>  

  
  <bean id="jms"
class="org.apache.activemq.camel.component.ActiveMQComponent">
    <property name="connectionFactory">
      <bean class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL"
value="failover://(tcp://hostname:61616)?initialReconnectDelay=100"/>
      </bean>
    </property>
  </bean>
</beans>





main method is as following:

	public static void main(String[] args) throws Exception {
	
				
		ApplicationContext appContext = new
FileSystemXmlApplicationContext("camel-context.xml");
		final SpringCamelContext context = (SpringCamelContext)
appContext.getBean("hulkcontext");
		context.start();
		
		Runtime rt = Runtime.getRuntime();
		rt.addShutdownHook(new Thread() {
			public void run() {
				LOG.info("Application is being shutdown.");
				try {						
					context.stop();						
				} catch (Exception e) {
					LOG.error("Exception occured while stopping the service", e);
				}
			}
		});
		
		
	}






it looks like the shutdown hook is being called as in the Logs I can find
"Application is being shutdown." but I am not calling it programmatically



--
View this message in context: http://camel.465427.n5.nabble.com/camel-shutsdown-route-even-when-using-failover-tp5727781.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message