On Wed, Feb 16, 2011 at 6:02 PM, Tom Howe <[email protected]> wrote: > I suspect it has something to do with this thread about blocking.. > > http://stackoverflow.com/questions/1846791/camelcontext-start-doesnt-block > > How come it blocks when consuming from a JMS queue and not from directory? > > How to make it block for all? >
There is a Main class in camel-spring you can leverage to keep it running. It has a run method. And I think we added a similar Main class into camel-core in Camel 2.6. > Thanks, Tom > > On Wed, Feb 16, 2011 at 4:20 PM, Tom Howe <[email protected]> wrote: > >> I have a simple forwarder application that has a single route: >> >> from(input).to(output) >> >> When input is activemq:somequeue and output is file:/tmp/blah, the app >> works fine, reading messages from my queue and writing to files. >> >> If I switch them around and put the input as the file:/tmp/blah and output >> as the queue, the application returns to the terminal immediately and doesnt >> start consuming... >> >> Here is the output, There is a bunch of files in /tmp/blah but it doesnt >> attempt to consume them... any ideas why? >> >> Feb 16, 2011 4:16:03 PM >> org.springframework.context.support.AbstractApplicationContext >> prepareRefresh >> INFO: Refreshing >> org.springframework.context.support.ClassPathXmlApplicationContext@2d09b23b: >> startup date [Wed Feb 16 16:16:03 GMT 2011]; root of context hierarchy >> JRebel-Spring: Monitoring Spring bean definitions in >> '/Users/tom/bbc/otg_wfe/ispy_agent_jms/trunk/target/classes/appContext.xml'. >> Feb 16, 2011 4:16:03 PM >> org.springframework.beans.factory.xml.XmlBeanDefinitionReader >> loadBeanDefinitions >> INFO: Loading XML bean definitions from class path resource >> [appContext.xml] >> Feb 16, 2011 4:16:04 PM >> org.springframework.beans.factory.support.DefaultListableBeanFactory >> preInstantiateSingletons >> INFO: Pre-instantiating singletons in >> org.springframework.beans.factory.support.DefaultListableBeanFactory@715d63da: >> defining beans >> [activemq,myConfigDelivery,jmsTransactionManagerDelivery,jmsCachingConnectionFactoryDelivery,jmsConnectionFactoryDelivery,redeliveryPolicyDelivery,activemq-int,intTransactionManager,intConnectionFactory]; >> root of factory hierarchy >> 16:16:04.307 [agentsmith.GoCamel.main()] INFO agentsmith.AkkaAgent - Set >> broker URL to: tcp://localhost:61616 >> Feb 16, 2011 4:16:04 PM org.apache.camel.impl.DefaultCamelContext start >> INFO: Apache Camel 2.5.0 (CamelContext: camel-1) is starting >> Feb 16, 2011 4:16:04 PM org.apache.camel.impl.DefaultCamelContext >> createManagementStrategy >> INFO: JMX enabled. Using ManagedManagementStrategy. >> Feb 16, 2011 4:16:05 PM >> org.apache.camel.impl.converter.AnnotationTypeConverterLoader load >> INFO: Found 7 packages with 19 @Converter classes to load >> Feb 16, 2011 4:16:05 PM >> org.apache.camel.impl.converter.BaseTypeConverterRegistry loadTypeConverters >> INFO: Loaded 166 type converters in 0.563 seconds >> Feb 16, 2011 4:16:06 PM org.apache.camel.impl.DefaultCamelContext >> doStartOrResumeRouteConsumers >> INFO: Route: route1 started and consuming from: Endpoint[file://tmp/blah] >> Feb 16, 2011 4:16:06 PM org.apache.camel.impl.DefaultCamelContext start >> INFO: Total 1 routes, of which 1 is started. >> Feb 16, 2011 4:16:06 PM org.apache.camel.impl.DefaultCamelContext start >> INFO: Apache Camel 2.5.0 (CamelContext: camel-1) started in 1.465 seconds >> [INFO] >> ------------------------------------------------------------------------ >> [INFO] BUILD SUCCESSFUL >> [INFO] >> ------------------------------------------------------------------------ >> [INFO] Total time: 7 seconds >> [INFO] Finished at: Wed Feb 16 16:16:06 GMT 2011 >> [INFO] Final Memory: 45M/265M >> [INFO] >> ------------------------------------------------------------------------ >> hanoman:trunk tom$ >> >> >> When I go from Queue => File, I get... >> >> Feb 16, 2011 4:20:13 PM >> org.springframework.context.support.AbstractApplicationContext >> prepareRefresh >> INFO: Refreshing >> org.springframework.context.support.ClassPathXmlApplicationContext@3572cc99: >> startup date [Wed Feb 16 16:20:13 GMT 2011]; root of context hierarchy >> JRebel-Spring: Monitoring Spring bean definitions in >> '/Users/tom/bbc/otg_wfe/ispy_agent_jms/trunk/target/classes/appContext.xml'. >> Feb 16, 2011 4:20:13 PM >> org.springframework.beans.factory.xml.XmlBeanDefinitionReader >> loadBeanDefinitions >> INFO: Loading XML bean definitions from class path resource >> [appContext.xml] >> Feb 16, 2011 4:20:14 PM >> org.springframework.beans.factory.support.DefaultListableBeanFactory >> preInstantiateSingletons >> INFO: Pre-instantiating singletons in >> org.springframework.beans.factory.support.DefaultListableBeanFactory@75d8362: >> defining beans >> [activemq,myConfigDelivery,jmsTransactionManagerDelivery,jmsCachingConnectionFactoryDelivery,jmsConnectionFactoryDelivery,redeliveryPolicyDelivery,activemq-int,intTransactionManager,intConnectionFactory]; >> root of factory hierarchy >> 16:20:14.736 [agentsmith.GoCamel.main()] INFO agentsmith.AkkaAgent - Set >> broker URL to: tcp://nm-int-wfe-mq-a.bbc.redbeemedia.net:61616 >> Feb 16, 2011 4:20:15 PM org.apache.camel.impl.DefaultCamelContext start >> INFO: Apache Camel 2.5.0 (CamelContext: camel-1) is starting >> Feb 16, 2011 4:20:15 PM org.apache.camel.impl.DefaultCamelContext >> createManagementStrategy >> INFO: JMX enabled. Using ManagedManagementStrategy. >> Feb 16, 2011 4:20:15 PM >> org.apache.camel.impl.converter.AnnotationTypeConverterLoader load >> INFO: Found 7 packages with 19 @Converter classes to load >> Feb 16, 2011 4:20:15 PM >> org.apache.camel.impl.converter.BaseTypeConverterRegistry loadTypeConverters >> INFO: Loaded 166 type converters in 0.489 seconds >> Feb 16, 2011 4:20:16 PM >> org.springframework.jms.connection.SingleConnectionFactory initConnection >> INFO: Established shared JMS Connection: ActiveMQConnection >> {id=ID:hanoman.national.core.bbc.co.uk-63375-1297873216544-0:0,clientId=null,started=false} >> Feb 16, 2011 4:20:16 PM org.apache.camel.impl.DefaultCamelContext >> doStartOrResumeRouteConsumers >> INFO: Route: route1 started and consuming from: >> Endpoint[activemq://topic:ispy] >> Feb 16, 2011 4:20:16 PM org.apache.camel.impl.DefaultCamelContext start >> INFO: Total 1 routes, of which 1 is started. >> Feb 16, 2011 4:20:16 PM org.apache.camel.impl.DefaultCamelContext start >> INFO: Apache Camel 2.5.0 (CamelContext: camel-1) started in 1.767 seconds >> 16:20:17.783 [DefaultMessageListenerContainer-1] INFO agentsmith.AkkaAgent >> - Message in: JmsMessage: ActiveMQTextMessage {commandId = 6, >> responseRequired = false, messageId = >> ID:vp-int-wfe-b-56866-1297782166935-0:134363:1:1:1, originalDestination = >> null, originalTransactionId = null, producerId = >> ID:vp-int-wfe-b-56866-1297782166935-0:134363:1:1, destination = >> topic://ispy, transactionId = >> TX:ID:vp-int-wfe-b-56866-1297782166935-0:134363:1, expiration = 0, timestamp >> = 1297873215471, arrival = 0, brokerInTime = 1297873215474, brokerOutTime = >> 1297873215476, correlationId = null, replyTo = null, persistent = true, type >> = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = >> null, compressed = false, userID = null, content = null, >> marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, >> size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, >> droppable = false, text = >> {"wfe_version":"R10.10.14","uuid":"A2F980DE-3...70806C98"} >> >> } >> 16:20:18.009 [DefaultMessageListenerContainer-1] INFO agentsmith.AkkaAgent >> - Message in: JmsMessage: ActiveMQTextMessage {commandId = 6, >> responseRequired = false, messageId = >> ID:vp-int-wfe-b-56866-1297782166935-0:134364:1:1:1, originalDestination = >> null, originalTransactionId = null, producerId = >> ID:vp-int-wfe-b-56866-1297782166935-0:134364:1:1, destination = >> topic://ispy, transactionId = >> TX:ID:vp-int-wfe-b-56866-1297782166935-0:134364:1, expiration = 0, timestamp >> = 1297873215487, arrival = 0, brokerInTime = 1297873215489, brokerOutTime = >> 1297873215490, correlationId = null, replyTo = null, persistent = true, type >> = null, priority = 4, groupID = null, groupSequence = 0, targetConsumerId = >> null, compressed = false, userID = null, content = null, >> marshalledProperties = null, dataStructure = null, redeliveryCounter = 0, >> size = 0, properties = null, readOnlyProperties = true, readOnlyBody = true, >> droppable = false, text = >> {"broadcast_pid":"p004jhvk","wfe_version":"R1...70806C98"} >> >> } >> >> >> >> > -- Claus Ibsen ----------------- FuseSource Email: [email protected] Web: http://fusesource.com Twitter: davsclaus Blog: http://davsclaus.blogspot.com/ Author of Camel in Action: http://www.manning.com/ibsen/
