-
1. Re: switchyard monitor directory and filename to jms queue
kcbabo Apr 7, 2014 9:30 AM (in response to stonesoft)You are close. Are you using the tooling? If so, it will create the Camel route with correct endpoints and wiring to the composite service and reference where you are using Camel bindings. Here's an example of what the switchyard.xml would look like followed by the Camel route:
<?xml version="1.0" encoding="UTF-8"?> <sy:switchyard xmlns:camel="urn:switchyard-component-camel:config:1.1" xmlns:file="urn:switchyard-component-camel-file:config:1.1" xmlns:jms="urn:switchyard-component-camel-jms:config:1.1" xmlns:sca="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:sy="urn:switchyard-config:switchyard:1.1" name="filejms" targetNamespace="urn:com.example.switchyard:filejms:1.0"> <sca:composite name="filejms" targetNamespace="urn:com.example.switchyard:filejms:1.0"> <sca:component name="Route"> <camel:implementation.camel> <camel:xml path="route.xml"/> </camel:implementation.camel> <sca:service name="MyService"> <sca:interface.java interface="com.example.switchyard.filejms.MyService"/> </sca:service> <sca:reference name="AnotherService"> <sca:interface.java interface="com.example.switchyard.filejms.AnotherService"/> </sca:reference> </sca:component> <sca:service name="MyService" promote="Route/MyService"> <sca:interface.java interface="com.example.switchyard.filejms.MyService"/> <file:binding.file name="file1"> <file:directory>/opt/INCOMING</file:directory> <file:consume/> </file:binding.file> </sca:service> <sca:reference name="AnotherService" multiplicity="0..1" promote="Route/AnotherService"> <sca:interface.java interface="com.example.switchyard.filejms.AnotherService"/> <jms:binding.jms name="jms1"> <jms:queue>SomeQueue</jms:queue> <jms:connectionFactory>#ConnectionFactory</jms:connectionFactory> </jms:binding.jms> </sca:reference> </sca:composite> </sy:switchyard>
Camel route:
<?xml version="1.0" encoding="ASCII"?> <routes xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="switchyard://MyService"/> <log message="MyService - message received: ${body}"/> <to uri="switchyard://AnotherService"/> </route> </routes>
I have attached a copy of the project I created to generate this config in case you want to work from it as a template. FWIW, it took me < 60 secs to create this in the editor. I point this out merely to highlight how the editor can be a bit productivity booster.
-
filejms.zip 6.7 KB
-
-
2. Re: switchyard monitor directory and filename to jms queue
stonesoft Apr 7, 2014 10:19 PM (in response to kcbabo)Thanks Keith. Although I can't get your example to work, I'm sure it is the right way to go. Perhaps my problem is that I am on switchyard 0.8 or that we still use ant and not maven. Not sure. And yes, I did download the tooling zip and installed it into Eclipse but I really didn't have time to learn how to use the tool (at the time I thought I could just create it by hand - my bad),
-
3. Re: Re: switchyard monitor directory and filename to jms queue
bhaskarsk May 6, 2014 4:51 AM (in response to stonesoft)Hi Keith,
I had a similar scenario, and i had followed the same approach as you have mentioned. But iam wondering( checking with log messages), will that be a async call to a JMS switchyard service or it invokes directly the Java interface. ( If this is the case then there is no queuing mechanism?).
Logs are printed in the sequence
message sending
// the request to Mapperservice completes ( all logs )
message sent ( printed after the entire service is done)
==========================================================
<when>
<simple>${body.destination} == 'NSN_2G_Mapper'</simple>
<log message="MyService - message sending ${body}"/>
<to uri="switchyard://MapperService" />
<log message="MyService - message sent"/>
</when>
=======================================
MapperService being a JMS service as below
<sca:service name="MapperService" promote="NSN_2G_Mapper/MapperService">
<sca:interface.java interface="com.alu.ipprd.aor.socket.client.MapperService"/>@
<jms:binding.jms name="MapperServiceQueue">
<jms:queue>MapperServiceQueue</jms:queue>
<jms:connectionFactory>#ConnectionFactory</jms:connectionFactory>
</jms:binding.jms>
</sca:service>