-
1. Re: How to invoke a Camel Component from a Bean Component
trohovsky Mar 6, 2014 10:36 AM (in response to jorgemoralespou_2)Hi Jorge,
your Bean and Camel component seems to be correct. Can you show us your switchyard.xml? And yes, the ${body} will be the passed instance of DownloadDetails. Invocation of Camel components does not differ from invocation of Bean components.
Tomas
-
2. Re: How to invoke a Camel Component from a Bean Component
rcernich Mar 6, 2014 10:45 AM (in response to jorgemoralespou_2)Make sure you've defined the reference on the bean component in the switchyard.xml file. If you're using the SwitchYard tools, you should have seen an error in the project saying a reference was used by the bean, but not declared in the switchyard.xml.
Hope that helps,
Rob
-
3. Re: How to invoke a Camel Component from a Bean Component
jorgemoralespou_2 Mar 6, 2014 11:10 AM (in response to jorgemoralespou_2)<?xml version="1.0" encoding="UTF-8"?> <sy:switchyard xmlns:bean="urn:switchyard-component-bean:config:1.1" xmlns:camel="urn:switchyard-component-camel:config:1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:soap="urn:switchyard-component-soap:config:1.1" xmlns:sy="urn:switchyard-config:switchyard:1.1" xmlns:transform="urn:switchyard-config:transform:1.1" name="jorge-switchyard-example1" targetNamespace="urn:com.example.switchyard:jorge-switchyard-example1:1.0"> <sca:composite name="jorge-switchyard-example1" targetNamespace="urn:com.example.switchyard:jorge-switchyard-example1:1.0"> <sca:component name="VideoDownloaderBean"> <bean:implementation.bean class="com.example.switchyard.jorge.VideoDownloaderBean"/> <sca:service name="VideoDownloader"> <sca:interface.java interface="com.example.switchyard.jorge.VideoDownloader"/> </sca:service> <sca:reference name="LoggingRoute"> <sca:interface.java interface="com.example.switchyard.jorge.LoggingRoute"/> </sca:reference> </sca:component> .... <sca:component name="LoggingRouteContextBuilder"> <camel:implementation.camel> <camel:java class="com.example.switchyard.jorge.LoggingRouteContextBuilder"/> </camel:implementation.camel> <sca:service name="LoggingRoute"> <sca:interface.java interface="com.example.switchyard.jorge.LoggingRoute"/> </sca:service> </sca:component> </sca:composite> .... </sy:switchyard>
This is my switchyard.xml. In the graphical tools, I don't see any errors. And looking deeply to the composite, I don't see any obvious error.
I also have beans.xml so that CDI works.
-
4. Re: How to invoke a Camel Component from a Bean Component
jorgemoralespou_2 Mar 6, 2014 11:15 AM (in response to jorgemoralespou_2)One thing that I see different, is that when I have a Bean Component, I have to add a @Service, but not for a Camel COmponent. How does it know it is a Service? From the composite definition?
-
5. Re: How to invoke a Camel Component from a Bean Component
rcernich Mar 6, 2014 11:54 AM (in response to jorgemoralespou_2)Hey Jorge,
Everything you have looks correct to me.
SwitchYard knows about the Camel service based on the component service declared in the switchyard.xml file (i.e. LoggingRoute).
How are you invoking the bean service? Are you sending a message in through a binding on a composite service, or are you accessing the bean in another manner?
You should be able to write a JUnit test for the service declared on the bean component that will exercise the component appropriately. Right-click the component service, and select new service test (or use the button pad). Edit the generated test to initialize the object, then run the test.
Sorry I couldn't be of more help.
Rob
-
6. Re: How to invoke a Camel Component from a Bean Component
jorgemoralespou_2 Mar 6, 2014 12:26 PM (in response to rcernich)I have created the test case, and debugging, I see that the LoggingRoute doesn't get injected. As this is a Camel interface, and not a Bean interface, where I add a @Service annotation. How does CDI/Weld pick it up? Don't I have to add annything to beans.xml to get it registered as a CDI bean?
Regards,
-
7. Re: How to invoke a Camel Component from a Bean Component
kcbabo Mar 6, 2014 12:30 PM (in response to jorgemoralespou_2)It should work as specified in your original post. Can you attach the app?
-
8. Re: Re: How to invoke a Camel Component from a Bean Component
jorgemoralespou_2 Mar 6, 2014 12:34 PM (in response to kcbabo)Here's the App. Thanks Keith
-
jorge-switchyard-example1.tar.gz 20.4 KB
-
-
9. Re: Re: How to invoke a Camel Component from a Bean Component
jorgemoralespou_2 Mar 6, 2014 12:35 PM (in response to jorgemoralespou_2)Also, to mention, using FSW 6.0.0 GA.
-
10. Re: How to invoke a Camel Component from a Bean Component
jorgemoralespou_2 Mar 6, 2014 1:09 PM (in response to jorgemoralespou_2)1 of 1 people found this helpfulHi,
I found my error. My %$&# eclipse imported com.google.inject instead of javax.inject.Inject.
Sorry for the time taken.
-
11. Re: How to invoke a Camel Component from a Bean Component
rcernich Mar 6, 2014 1:21 PM (in response to jorgemoralespou_2)No worries. Glad it was something simple.