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/28 13:47:31 UTC
Auto Start up issue when adding RouteDefintions
Apache Camel version 2.4
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>
Is there an issue or am i doing something wrong
--
View this message in context: http://camel.465427.n5.nabble.com/Auto-Start-up-issue-when-adding-RouteDefintions-tp2256671p2256671.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Auto Start up issue when adding RouteDefintions
Posted by kumaap <am...@gmail.com>.
thanks Claus.
--
View this message in context: http://camel.465427.n5.nabble.com/Auto-Start-up-issue-when-adding-RouteDefintions-tp2256671p2259483.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Auto Start up issue when adding RouteDefintions
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
I have created a ticket to track this
https://issues.apache.org/activemq/browse/CAMEL-3007
On Wed, Jul 28, 2010 at 5:32 PM, kumaap <am...@gmail.com> wrote:
>
> As you can see the route supplied has autostart = false .
>
> Yet the test receives a message. I should not receive a message until the
> route is started.
> --
> View this message in context: http://camel.465427.n5.nabble.com/Auto-Start-up-issue-when-adding-RouteDefintions-tp2256671p2256690.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: Auto Start up issue when adding RouteDefintions
Posted by kumaap <am...@gmail.com>.
As you can see the route supplied has autostart = false .
Yet the test receives a message. I should not receive a message until the
route is started.
--
View this message in context: http://camel.465427.n5.nabble.com/Auto-Start-up-issue-when-adding-RouteDefintions-tp2256671p2256690.html
Sent from the Camel - Users mailing list archive at Nabble.com.