how to do that in camel xml ?

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

how to do that in camel xml ?

pascal J
Hi all,

I am trying to implements my routes in Camel XML (vs DSL).
Anyone can help me in converting the following DSL to XML ?

                /**
                 * Define the route from "A" where applications puts
                 * their HL7 messages.<br>
                 * First : the HL7 message is transformed to XML.<br>
                 * second : message is routed to both "B" and "C".
                 */
                from("activemq:A")
                        .process(new HL7toXML())
                .to("activemq:B", "activemq:C");

I have no problem with the from and to clauses, but I don't know how to express the process clause in XML (the documentation is not verbose on the subject ).

HL7toXML is a class implementing the Processor interface like the following:

                public class HL7toXML implements Processor {
                                public void process(Exchange exchange) throws Exception {
                                String hl7Message = exchange.getIn().getBody(String.class);
                                String xmlMessage = HL7TransformerUtil.hl7ToXml(hl7Message);
                                exchange.getOut().setBody(xmlMessage, String.class);
                        }
                }

Thank in advance.

PJ.
Reply | Threaded
Open this post in threaded view
|

Re: how to do that in camel xml ?

Paulo Ramos
Hi, I have the same problem.
Can anyone help?

Paulo Ramos
Reply | Threaded
Open this post in threaded view
|

Re: how to do that in camel xml ?

Guillaume Nodet
Administrator
You need to use a reference to a spring bean.
Something like

  <route xmlns="camel">
    <from uri="xxx" />
    <process ref="mybean/>
   ...
  </route>

  <bean id="myBean" class="xxx">
     ..
  </bean>

On 10/4/07, Paulo Ramos <[hidden email]> wrote:

>
> Hi, I have the same problem.
> Can anyone help?
>
> Paulo Ramos
>
> --
> View this message in context: http://www.nabble.com/how-to-do-that-in-camel-xml---tf4562649s22882.html#a13036872
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: how to do that in camel xml ?

jstrachan
On 04/10/2007, Guillaume Nodet <[hidden email]> wrote:

> You need to use a reference to a spring bean.
> Something like
>
>   <route xmlns="camel">
>     <from uri="xxx" />
>     <process ref="mybean/>
>    ...
>   </route>
>
>   <bean id="myBean" class="xxx">
>      ..
>   </bean>

BTW I just added a JUnit test case showing how to invoke a processor via XML

https://svn.apache.org/repos/asf/activemq/camel/trunk/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/transform.xml

You can as well use the <bean ref=""/> tag as well to invoke any Java
Bean and then use the bean integration to invoke a method etc.

http://activemq.apache.org/camel/bean-integration.html
--
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com
Reply | Threaded
Open this post in threaded view
|

Re: how to do that in camel xml ?

Paulo Ramos
Can anyone help me?
Now i have this error:

SEVERE: Failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel:beanPostProcessor': Cannot resolve reference to bean 'camel' while setting bean property 'camelContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel': Invocation of init method failed; nested exception is org.apache.camel.RuntimeCamelException: target provided.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel:beanPostProcessor': Cannot resolve reference to bean 'camel' while setting bean property 'camelContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel': Invocation of init method failed; nested exception is org.apache.camel.RuntimeCamelException: target provided.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel': Invocation of init method failed; nested exception is org.apache.camel.RuntimeCamelException: target provided.
Caused by: org.apache.camel.RuntimeCamelException: target provided.

Paulo Ramos
Reply | Threaded
Open this post in threaded view
|

Re: how to do that in camel xml ?

Guillaume Nodet
Administrator
You need to post the full stack trace and keeping the formatting (this
one is quite unreadable).

On 10/4/07, Paulo Ramos <[hidden email]> wrote:

>
> Can anyone help me?
> Now i have this error:
>
> SEVERE: Failed: org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'camel:beanPostProcessor': Cannot resolve
> reference to bean 'camel' while setting bean property 'camelContext'; nested
> exception is org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'camel': Invocation of init method failed; nested
> exception is org.apache.camel.RuntimeCamelException: target provided.
> org.springframework.beans.factory.BeanCreationException: Error creating bean
> with name 'camel:beanPostProcessor': Cannot resolve reference to bean
> 'camel' while setting bean property 'camelContext'; nested exception is
> org.springframework.beans.factory.BeanCreationException: Error creating bean
> with name 'camel': Invocation of init method failed; nested exception is
> org.apache.camel.RuntimeCamelException: target provided.
> Caused by: org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'camel': Invocation of init method failed; nested
> exception is org.apache.camel.RuntimeCamelException: target provided.
> Caused by: org.apache.camel.RuntimeCamelException: target provided.
>
> Paulo Ramos
> --
> View this message in context: http://www.nabble.com/how-to-do-that-in-camel-xml---tf4562649s22882.html#a13042915
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


--
Cheers,
Guillaume Nodet
------------------------
Blog: http://gnodet.blogspot.com/
Reply | Threaded
Open this post in threaded view
|

Re: how to do that in camel xml ?

Paulo Ramos
Sorry.
SEVERE: Failed: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel:beanPostProcessor': Cannot resolve reference to bean 'camel' while setting bean property 'camelContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel': Invocation of init method failed; nested exception is org.apache.camel.RuntimeCamelException: target provided.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel:beanPostProcessor': Cannot resolve reference to bean 'camel' while setting bean property 'camelContext'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel': Invocation of init method failed; nested exception is org.apache.camel.RuntimeCamelException: target provided.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'camel': Invocation of init method failed; nested exception is org.apache.camel.RuntimeCamelException: target provided.
Caused by: org.apache.camel.RuntimeCamelException: target provided.
	at org.apache.camel.model.ProcessorType.wrapProcessorInInterceptors(ProcessorType.java:674)
	at org.apache.camel.model.ProcessorType.wrapProcessor(ProcessorType.java:89)
	at org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:660)
	at org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:80)
	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:161)
	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:89)
	at org.apache.camel.model.RouteType.addRoutes(RouteType.java:80)
	at org.apache.camel.spring.CamelContextFactoryBean.installRoutes(CamelContextFactoryBean.java:208)
	at org.apache.camel.spring.CamelContextFactoryBean.afterPropertiesSet(CamelContextFactoryBean.java:100)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1202)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:428)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
	at org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1100)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424)
	at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
	at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
	at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
	at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:733)
	at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:511)
	at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:337)
	at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:91)
	at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:75)
	at org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:65)
	at org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:229)
	at org.apache.camel.spring.Main.doStart(Main.java:223)
	at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:48)
	at org.apache.camel.spring.Main.run(Main.java:81)
	at org.apache.camel.spring.Main.run(Main.java:72)
	at org.apache.camel.example.main.Main.main(Main.java:14)
Paulo Ramos
Reply | Threaded
Open this post in threaded view
|

Re: how to do that in camel xml ?

jstrachan
what was the XML?

On 04/10/2007, Paulo Ramos <[hidden email]> wrote:

>
> Sorry.
>
>
> SEVERE: Failed: org.springframework.beans.factory.BeanCreationException:
> Error creating bean with name 'camel:beanPostProcessor': Cannot resolve
> reference to bean 'camel' while setting bean property 'camelContext'; nested
> exception is org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'camel': Invocation of init method failed; nested
> exception is org.apache.camel.RuntimeCamelException: target provided.
> org.springframework.beans.factory.BeanCreationException: Error creating bean
> with name 'camel:beanPostProcessor': Cannot resolve reference to bean
> 'camel' while setting bean property 'camelContext'; nested exception is
> org.springframework.beans.factory.BeanCreationException: Error creating bean
> with name 'camel': Invocation of init method failed; nested exception is
> org.apache.camel.RuntimeCamelException: target provided.
> Caused by: org.springframework.beans.factory.BeanCreationException: Error
> creating bean with name 'camel': Invocation of init method failed; nested
> exception is org.apache.camel.RuntimeCamelException: target provided.
> Caused by: org.apache.camel.RuntimeCamelException: target provided.
>         at
> org.apache.camel.model.ProcessorType.wrapProcessorInInterceptors(ProcessorType.java:674)
>         at
> org.apache.camel.model.ProcessorType.wrapProcessor(ProcessorType.java:89)
>         at
> org.apache.camel.model.ProcessorType.makeProcessor(ProcessorType.java:660)
>         at org.apache.camel.model.ProcessorType.addRoutes(ProcessorType.java:80)
>         at org.apache.camel.model.RouteType.addRoutes(RouteType.java:161)
>         at org.apache.camel.model.RouteType.addRoutes(RouteType.java:89)
>         at org.apache.camel.model.RouteType.addRoutes(RouteType.java:80)
>         at
> org.apache.camel.spring.CamelContextFactoryBean.installRoutes(CamelContextFactoryBean.java:208)
>         at
> org.apache.camel.spring.CamelContextFactoryBean.afterPropertiesSet(CamelContextFactoryBean.java:100)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1202)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1172)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:428)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
>         at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
>         at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:261)
>         at
> org.springframework.beans.factory.support.BeanDefinitionValueResolver.resolveValueIfNecessary(BeanDefinitionValueResolver.java:109)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyPropertyValues(AbstractAutowireCapableBeanFactory.java:1100)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:862)
>         at
> org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:424)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:251)
>         at
> org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:156)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:248)
>         at
> org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:160)
>         at
> org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:733)
>         at
> org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:511)
>         at
> org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:337)
>         at
> org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:91)
>         at
> org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:75)
>         at
> org.springframework.context.support.ClassPathXmlApplicationContext.(ClassPathXmlApplicationContext.java:65)
>         at
> org.apache.camel.spring.Main.createDefaultApplicationContext(Main.java:229)
>         at org.apache.camel.spring.Main.doStart(Main.java:223)
>         at org.apache.camel.impl.ServiceSupport.start(ServiceSupport.java:48)
>         at org.apache.camel.spring.Main.run(Main.java:81)
>         at org.apache.camel.spring.Main.run(Main.java:72)
>         at org.apache.camel.example.main.Main.main(Main.java:14)
>
>
> Paulo Ramos
> --
> View this message in context: http://www.nabble.com/how-to-do-that-in-camel-xml---tf4562649s22882.html#a13043318
> Sent from the Camel - Users mailing list archive at Nabble.com.
>


--
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com
Reply | Threaded
Open this post in threaded view
|

Re: how to do that in camel xml ?

Paulo Ramos
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">

  <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
    <package>org.apache.camel.example</package>
 
  <route>
    <from uri="file://test"/>
    <process ref="testProcessor"/>
    <to uri="log:loggingCategory?level=ERROR"/> 
  </route>
 
  </camelContext>

  <bean id="testeProcessor" class="org.apache.camel.example.spring.TestProcessor"/> 

</beans>
Reply | Threaded
Open this post in threaded view
|

Re: how to do that in camel xml ?

Paulo Ramos
Can anyone help me with this?
I want to use Camel in my project but my tests are stuck in this problem.

Thanks,
    Paulo Ramos
Reply | Threaded
Open this post in threaded view
|

Re: how to do that in camel xml ?

jstrachan
I don't see anything wrong so am pretty stuck. I wonder could you
provide a tarball of a pom.xml and source code that fails like this?
As we've numerous unit tests in Camel that do exactly this and they
all work fine?

I wonder if its related to a spring version you're using; or the Camel
version you have? Do you get the same failure with the latest
SNAPSHOT? Maybe its an OS/JVM thing?

On 09/10/2007, Paulo Ramos <[hidden email]> wrote:

>
> Can anyone help me with this?
> I want to use Camel in my project but my tests are stuck in this problem.
>
> Thanks,
>     Paulo Ramos
> --
> View this message in context: http://www.nabble.com/how-to-do-that-in-camel-xml---tf4562649s22882.html#a13113099
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


--
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com
Reply | Threaded
Open this post in threaded view
|

Re: how to do that in camel xml ?

pascal J
In reply to this post by Paulo Ramos
Do you realize that you have a typo in the bean name?
In your route you reference a processor bean named "testProcessor" but your declared bean is named "testeProcessor".

It may or may not be the problem you currently have, I don't know.

Pascal J.

Paulo Ramos wrote
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="
       http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
       http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd">

  <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
    <package>org.apache.camel.example</package>
 
  <route>
    <from uri="file://test"/>
    <process ref="testProcessor"/>
    <to uri="log:loggingCategory?level=ERROR"/> 
  </route>
 
  </camelContext>

  <bean id="testeProcessor" class="org.apache.camel.example.spring.TestProcessor"/> 

</beans>
Reply | Threaded
Open this post in threaded view
|

Re: how to do that in camel xml ?

jstrachan
On 18/10/2007, pascal J <[hidden email]> wrote:
>
> Do you realize that you have a typo in the bean name?
> In your route you reference a processor bean named "testProcessor" but your
> declared bean is named "testeProcessor".
>
> It may or may not be the problem you currently have, I don't know.

Aha! Great catch - thanks Pascal!
--
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com
Reply | Threaded
Open this post in threaded view
|

Re: how to do that in camel xml ?

Paulo Ramos
In reply to this post by pascal J
Thanks.
Yes, i have seen it. I have forgotten to post the correction. Sorry.

Paulo Ramos

pascal J wrote
Do you realize that you have a typo in the bean name?
In your route you reference a processor bean named "testProcessor" but your declared bean is named "testeProcessor".

It may or may not be the problem you currently have, I don't know.

Pascal J.
Reply | Threaded
Open this post in threaded view
|

Re: how to do that in camel xml ?

jstrachan
Great, glad its working for you Paulo

On 18/10/2007, Paulo Ramos <[hidden email]> wrote:

>
> Thanks.
> Yes, i have seen it. I have forgotten to post the correction. Sorry.
>
> Paulo Ramos
>
>
> pascal J wrote:
> >
> > Do you realize that you have a typo in the bean name?
> > In your route you reference a processor bean named "testProcessor" but
> > your declared bean is named "testeProcessor".
> >
> > It may or may not be the problem you currently have, I don't know.
> >
> > Pascal J.
> >
>
> --
> View this message in context: http://www.nabble.com/how-to-do-that-in-camel-xml---tf4562649s22882.html#a13274584
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>


--
James
-------
http://macstrac.blogspot.com/

Open Source SOA
http://open.iona.com