You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by simafengyun <27...@qq.com> on 2014/07/11 12:11:54 UTC
Re: How to use a public endpoint outside of camecontext?
Hi Willem,
My code like that(not the real code)
*in xml: *
<endpoint id="testSeda"
uri="seda:trades?size=1000000&concurrentConsumers=20&waitForTaskToComplete=Never"
xmlns="http://camel.apache.org/schema/spring"/>
<routeContext id="defaultRoutes"
xmlns="http://camel.apache.org/schema/spring">
<route id="queryRoute" autoStartup="true" startupOrder="200">
<from uri="jms"/>
<to uri="testSeda"/>
</route>
</routeContext>
*in java: *
//load spring xml
final AbstractXmlApplicationContext springAppContext= new
ClassPathXmlApplicationContext("testSpring.xml");
//registry spring xml to camel context
ActorSystem system = ActorSystem.create("some-system");
Camel camel = CamelExtension.get(system);
camel.context().setRegistry(new
ApplicationContextRegistry(springAppContext));
springAppContext.refresh();
// add the routesContext to camelContext
ArrayList<RouteDefinition> rdList =
(ArrayList<RouteDefinition>)camel.context().getRegistry().lookup("defaultRoutes");
RouteDefinition rd = rdList.get(0);
CamelExtension.get(system).context().addRouteDefinition(rd);
*Error:*
Caused by: org.springframework.beans.factory.BeanCreationException: Error
creating bean with name 'testSeda': FactoryBean threw exception on object
creation; nested exception is java.lang.NullPointerException
at
org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
at
org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1440)
at
org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:247)
at
org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
at
org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
at
org.apache.camel.spring.spi.ApplicationContextRegistry.lookup(ApplicationContextRegistry.java:66)
at
org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:49)
... 21 more
Caused by: java.lang.NullPointerException
at
org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean.getObject(AbstractCamelEndpointFactoryBean.java:46)
at
org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean.getObject(AbstractCamelEndpointFactoryBean.java:30)
at
org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
... 28 more
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-use-a-public-endpoint-outside-of-camecontext-tp5752336p5753714.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to use a public endpoint outside of camecontext?
Posted by Claus Ibsen <cl...@gmail.com>.
You need to register the endpoint outside spring, as <endpoint> is for
spring/blueprint only.
Just register it in whatever registry that akka offers. There must be
some way of injecting a endpoint into akka, that Camel can lookup.
and mind that <route> is not spring, Camel is able to load routes from
xml files, without spring. Its just for historical reasons that the
namespace has /spring. We may likely change that namespace for Camel
3.0 onwards.
On Mon, Jul 14, 2014 at 3:25 AM, simafengyun <27...@qq.com> wrote:
> Yes, the camel context is not defined inside of spring configuration file
> because akka has it's own camel context. So do you have any suggestion to
> fix it?
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-use-a-public-endpoint-outside-of-camecontext-tp5752336p5753761.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
--
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
hawtio: http://hawt.io/
fabric8: http://fabric8.io/
Re: How to use a public endpoint outside of camecontext?
Posted by simafengyun <27...@qq.com>.
Yes, the camel context is not defined inside of spring configuration file
because akka has it's own camel context. So do you have any suggestion to
fix it?
--
View this message in context: http://camel.465427.n5.nabble.com/How-to-use-a-public-endpoint-outside-of-camecontext-tp5752336p5753761.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: How to use a public endpoint outside of camecontext?
Posted by Willem Jiang <wi...@gmail.com>.
It looks like you don’t have any camel context definition inside of spring configuration file.
It could cause some trouble as the endpoint need to have the reference of the camel context.
--
Willem Jiang
Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem
On July 11, 2014 at 6:14:35 PM, simafengyun (273132695@qq.com) wrote:
> Hi Willem,
>
> My code like that(not the real code)
>
> *in xml: *
>
> > uri="seda:trades?size=1000000&concurrentConsumers=20&waitForTaskToComplete=Never"
> xmlns="http://camel.apache.org/schema/spring"/>
>
> > xmlns="http://camel.apache.org/schema/spring">
>
>
>
>
>
>
>
> *in java: *
>
> //load spring xml
> final AbstractXmlApplicationContext springAppContext= new
> ClassPathXmlApplicationContext("testSpring.xml");
>
>
> //registry spring xml to camel context
> ActorSystem system = ActorSystem.create("some-system");
> Camel camel = CamelExtension.get(system);
> camel.context().setRegistry(new
> ApplicationContextRegistry(springAppContext));
> springAppContext.refresh();
>
>
> // add the routesContext to camelContext
> ArrayList rdList =
> (ArrayList)camel.context().getRegistry().lookup("defaultRoutes");
> RouteDefinition rd = rdList.get(0);
> CamelExtension.get(system).context().addRouteDefinition(rd);
>
> *Error:*
>
> Caused by: org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'testSeda': FactoryBean threw exception on object
> creation; nested exception is java.lang.NullPointerException
> at
> org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:149)
> at
> org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:102)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1440)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:247)
> at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:192)
> at
> org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:1075)
> at
> org.apache.camel.spring.spi.ApplicationContextRegistry.lookup(ApplicationContextRegistry.java:66)
> at
> org.apache.camel.impl.PropertyPlaceholderDelegateRegistry.lookup(PropertyPlaceholderDelegateRegistry.java:49)
> ... 21 more
> Caused by: java.lang.NullPointerException
> at
> org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean.getObject(AbstractCamelEndpointFactoryBean.java:46)
> at
> org.apache.camel.core.xml.AbstractCamelEndpointFactoryBean.getObject(AbstractCamelEndpointFactoryBean.java:30)
> at
> org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142)
> ... 28 more
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-use-a-public-endpoint-outside-of-camecontext-tp5752336p5753714.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>