You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by kumaap <am...@gmail.com> on 2010/07/27 17:17:17 UTC
Route Definition Autostart and JMX issue
Apache Camel version 2.4
Does the Management Strategy (JMX) only start when the camel context is
start?
Once a Camel context is started all route definition loaded seem to ignore
autoStartup="false". Is this correct behavior?
--
View this message in context: http://camel.465427.n5.nabble.com/Route-Definition-Autostart-and-JMX-issue-tp2255948p2255948.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Route Definition Autostart and JMX issue
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Ah its the autoStartup in the route XML. There is also one on <camelContext>.
Yeah this option may not be triggered when loading the route from XML
as the logic is a bit different, then regular.
<?xml version="1.0" encoding="UTF-8"?>
<route xmlns="http://camel.apache.org/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd"
id="v_from_app1_app1" autoStartup="false" trace="true" group="o1" >
<from uri="jms:start"/>
<to uri="mock:result"/>
</route>
Fell free to create a ticket in JIRA
On Wed, Jul 28, 2010 at 1:08 PM, kumaap <am...@gmail.com> wrote:
>
> Ok more Explanation on how im adding routes to the camel context,
>
> The camel Context is already started and im adding route definitions like
> below.
>
> RouteDefinition routeDefinition = (RouteDefinition)
> unmarshaller.unmarshal(stringReader);
> ArrayList arrayList = new ArrayList();
> arrayList.add(routeDefinition);
> camelContext.addRouteDefinitions(arrayList);
>
> I need to load the routes this way as each route is dynamically loaded from
> xml route files getting submitted to our app.
>
> Here is a unit test that fails that shows the Issue
>
> package sandbox;
>
> import org.apache.activemq.ActiveMQConnectionFactory;
> import org.apache.camel.*;
> import org.apache.camel.component.jms.JmsComponent;
> import org.apache.camel.component.mock.MockEndpoint;
> import org.apache.camel.model.Constants;
> import org.apache.camel.model.RouteDefinition;
> import org.apache.camel.spring.SpringCamelContext;
> import org.apache.camel.test.junit4.CamelTestSupport;
> import org.junit.Assert;
> import org.junit.Before;
> import org.springframework.context.support.GenericApplicationContext;
>
> import javax.xml.bind.JAXBContext;
> import javax.xml.bind.Unmarshaller;
> import java.net.URL;
> import java.util.ArrayList;
>
> /**
> * Unit test for simple App.
> */
> public class AppTest extends CamelTestSupport
> {
> private ActiveMQConnectionFactory factory;
> private SpringCamelContext camelContext;
> @Before
> public void setUp() throws Exception
> {
>
> factory = new ActiveMQConnectionFactory("vm://local");
> super.setUp();
> }
> @EndpointInject(uri = "mock:result")
> protected MockEndpoint resultEndpoint;
>
> @Produce(uri = "jms:start")
> protected ProducerTemplate template;
>
>
> @org.junit.Test
> public void test() throws Exception
> {
> JAXBContext jaxbContext = null;
> Unmarshaller unmarshaller = null;
> RouteDefinition input = null;
> jaxbContext =
> JAXBContext.newInstance(Constants.JAXB_CONTEXT_PACKAGES);
> unmarshaller = jaxbContext.createUnmarshaller();
> input = (RouteDefinition) unmarshaller.unmarshal(new
> URL("file:input.xml"));
> Assert.assertTrue(input != null);
> Assert.assertTrue(context.getStatus() == ServiceStatus.Started);
> ArrayList<RouteDefinition> routes = new ArrayList();
> routes.add(input);
> resultEndpoint.setExpectedMessageCount(0);
> camelContext.addRouteDefinitions(routes);
> template.sendBody("test");
> resultEndpoint.setSleepForEmptyTest(1000);
> resultEndpoint.assertIsSatisfied();
> }
>
>
> @Override
> protected CamelContext createCamelContext() throws Exception
> {
> GenericApplicationContext applicationContext = new
> GenericApplicationContext();
> camelContext = new SpringCamelContext(applicationContext);
> JmsComponent jmsComponent = new JmsComponent();
> jmsComponent.setConnectionFactory(factory);
>
> applicationContext.getBeanFactory().registerSingleton("jms",jmsComponent);
> return camelContext;
> }
>
> }
>
>
> input.xml
>
> <?xml version="1.0" encoding="UTF-8"?>
> <route xmlns="http://camel.apache.org/schema/spring"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xsi:schemaLocation="http://camel.apache.org/schema/spring
> http://camel.apache.org/schema/spring/camel-spring.xsd"
> id="v_from_app1_app1" autoStartup="false" trace="true" group="o1" >
> <from uri="jms:start"/>
> <to uri="mock:result"/>
> </route>
>
> pom dependencies
> <dependency>
> <groupId>junit</groupId>
> <artifactId>junit</artifactId>
> <version>4.7</version>
> <scope>test</scope>
> </dependency>
> <dependency>
> <groupId>org.apache.camel</groupId>
> <artifactId>camel</artifactId>
> <version>2.4.0</version>
> </dependency>
> <dependency>
> <groupId>org.apache.camel</groupId>
> <artifactId>camel-core</artifactId>
> <version>2.4.0</version>
> </dependency>
> <dependency>
> <groupId>org.apache.camel</groupId>
> <artifactId>camel-jms</artifactId>
> <version>2.4.0</version>
> </dependency>
> <dependency>
> <groupId>org.apache.camel</groupId>
> <artifactId>camel-test</artifactId>
> <version>2.4.0</version>
> </dependency>
> <dependency>
> <groupId>org.apache.camel</groupId>
> <artifactId>camel-spring</artifactId>
> <version>2.4.0</version>
> </dependency>
> <dependency>
> <groupId>org.apache.activemq</groupId>
> <artifactId>activemq-core</artifactId>
> <version>5.3.0</version>
> </dependency>
> </dependencies>
>
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Route-Definition-Autostart-and-JMX-issue-tp2255948p2256669.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
Apache Camel Committer
Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Re: Route Definition Autostart and JMX issue
Posted by kumaap <am...@gmail.com>.
Ok more Explanation on how im adding routes to the camel context,
The camel Context is already started and im adding route definitions like
below.
RouteDefinition routeDefinition = (RouteDefinition)
unmarshaller.unmarshal(stringReader);
ArrayList arrayList = new ArrayList();
arrayList.add(routeDefinition);
camelContext.addRouteDefinitions(arrayList);
I need to load the routes this way as each route is dynamically loaded from
xml route files getting submitted to our app.
Here is a unit test that fails that shows the Issue
package sandbox;
import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.camel.*;
import org.apache.camel.component.jms.JmsComponent;
import org.apache.camel.component.mock.MockEndpoint;
import org.apache.camel.model.Constants;
import org.apache.camel.model.RouteDefinition;
import org.apache.camel.spring.SpringCamelContext;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Assert;
import org.junit.Before;
import org.springframework.context.support.GenericApplicationContext;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.Unmarshaller;
import java.net.URL;
import java.util.ArrayList;
/**
* Unit test for simple App.
*/
public class AppTest extends CamelTestSupport
{
private ActiveMQConnectionFactory factory;
private SpringCamelContext camelContext;
@Before
public void setUp() throws Exception
{
factory = new ActiveMQConnectionFactory("vm://local");
super.setUp();
}
@EndpointInject(uri = "mock:result")
protected MockEndpoint resultEndpoint;
@Produce(uri = "jms:start")
protected ProducerTemplate template;
@org.junit.Test
public void test() throws Exception
{
JAXBContext jaxbContext = null;
Unmarshaller unmarshaller = null;
RouteDefinition input = null;
jaxbContext =
JAXBContext.newInstance(Constants.JAXB_CONTEXT_PACKAGES);
unmarshaller = jaxbContext.createUnmarshaller();
input = (RouteDefinition) unmarshaller.unmarshal(new
URL("file:input.xml"));
Assert.assertTrue(input != null);
Assert.assertTrue(context.getStatus() == ServiceStatus.Started);
ArrayList<RouteDefinition> routes = new ArrayList();
routes.add(input);
resultEndpoint.setExpectedMessageCount(0);
camelContext.addRouteDefinitions(routes);
template.sendBody("test");
resultEndpoint.setSleepForEmptyTest(1000);
resultEndpoint.assertIsSatisfied();
}
@Override
protected CamelContext createCamelContext() throws Exception
{
GenericApplicationContext applicationContext = new
GenericApplicationContext();
camelContext = new SpringCamelContext(applicationContext);
JmsComponent jmsComponent = new JmsComponent();
jmsComponent.setConnectionFactory(factory);
applicationContext.getBeanFactory().registerSingleton("jms",jmsComponent);
return camelContext;
}
}
input.xml
<?xml version="1.0" encoding="UTF-8"?>
<route xmlns="http://camel.apache.org/schema/spring"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://camel.apache.org/schema/spring
http://camel.apache.org/schema/spring/camel-spring.xsd"
id="v_from_app1_app1" autoStartup="false" trace="true" group="o1" >
<from uri="jms:start"/>
<to uri="mock:result"/>
</route>
pom dependencies
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.7</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-jms</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-test</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-core</artifactId>
<version>5.3.0</version>
</dependency>
</dependencies>
--
View this message in context: http://camel.465427.n5.nabble.com/Route-Definition-Autostart-and-JMX-issue-tp2255948p2256669.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Route Definition Autostart and JMX issue
Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Jul 27, 2010 at 5:17 PM, kumaap <am...@gmail.com> wrote:
>
> Apache Camel version 2.4
>
> Does the Management Strategy (JMX) only start when the camel context is
> start?
>
> Once a Camel context is started all route definition loaded seem to ignore
> autoStartup="false". Is this correct behavior?
> --
AutoStartup is *only* applicable when CamelContext is starting itself.
After CamelContext has been started, adding a route will start also
automatic start it.
> View this message in context: http://camel.465427.n5.nabble.com/Route-Definition-Autostart-and-JMX-issue-tp2255948p2255948.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
--
Claus Ibsen
Apache Camel Committer
Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus
Re: Route Definition Autostart and JMX issue
Posted by Willem Jiang <wi...@gmail.com>.
kumaap wrote:
> Apache Camel version 2.4
>
> Does the Management Strategy (JMX) only start when the camel context is
> start?
>
> Once a Camel context is started all route definition loaded seem to ignore
> autoStartup="false". Is this correct behavior?
Sorry, I didn't get you point.
How can a Camel context is start with all route definition which
autoStartup="false"? Are you starting the route from JMX ?
Willem
----------------------------------
Apache Camel, Apache CXF committer
Open Source Integration http://www.fusesource.com
Blog http://willemjiang.blogspot.com
Tiwtter http://twitter.com/willemjiang