हो जाता है नहीं होना चाहिए, जब गुलाम दलाल शुरू होता है तो मार्गों के साथ CamelContext भी करता है। तुम क्या कर ऐसा कर सकते हैं हालांकि निम्नलिखित:
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring" autoStartup="false">
...
</camelContext>
इसके बाद आप एक वर्ग को लागू करने वाली बनाने की जरूरत:
camelContext गुलाम दलाल के साथ तैनात किया पर निम्नलिखित autostartup विशेषता प्रारंभ होने से मार्गों को रोकने के लिए जोड़ने ActiveMQ सेवा इंटरफ़ेस।
<services>
<bean xmlns="http://www.springframework.org/schema/beans" class="com.fusesource.example.CamelContextService">
<property name="camel" ref="camel"/>
</bean>
</services>
अब, एक बार गुलाम दलाल के रूप में कार्यभार संभाला:
package com.fusesource.example;
import org.apache.activemq.Service;
import org.apache.camel.spring.SpringCamelContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Example used to start and stop the camel context using the ActiveMQ Service interface
*
*/
public class CamelContextService implements Service
{
private final Logger LOG = LoggerFactory.getLogger(CamelContextService.class);
SpringCamelContext camel;
@Override
public void start() throws Exception {
try {
camel.start();
} catch (Exception e) {
LOG.error("Unable to start camel context: " + camel);
e.printStackTrace();
}
}
@Override
public void stop() throws Exception {
try {
camel.stop();
} catch (Exception e) {
LOG.error("Unable to stop camel context: " + camel);
e.printStackTrace();
}
}
public SpringCamelContext getCamel() {
return camel;
}
public void setCamel(SpringCamelContext camel) {
this.camel = camel;
}
}
तो दलाल का विन्यास फाइल में, activemq.xml, सेवा रजिस्टर करने के लिए निम्नलिखित जोड़ें: इस का एक नमूना इस प्रकार होगा मास्टर, स्टार्ट विधि सर्विस क्लास पर लागू की जाएगी और मार्ग शुरू हो जाएंगे।
मैं भी इस बारे में यहाँ एक ब्लॉग पोस्ट किया है: http://jason-sherman.blogspot.com/2012/04/activemq-how-to-startstop-camel-routes.html
स्रोत
2012-04-30 21:59:31