-
1. Re: Simple forward from file the queue
jorgemoralespou_2 Sep 28, 2014 7:04 AM (in response to erhard)I guess that depending on your contracts your message body needs to be converted. For jms, you should see camel jms component documentation.
You can specify your component contact to expect a string, so the massage gets implicitly converted.
Documentation for switchyard is not very good so feel free to add a JIRA for whatever you think should be documented.
-
2. Re: Re: Simple forward from file the queue
erhard Oct 11, 2014 2:33 PM (in response to jorgemoralespou_2)Thanks for the answer. I tried to add the property
<jms:additionalUriParameters>
<jms:parameter name="jmsMessageType" value="Text"/>
</jms:additionalUriParameters>
with no success. I also attached a test-case.
-
fsw-forward-file-to-queue.zip 15.5 KB
-
-
3. Re: Simple forward from file the queue
jorgemoralespou_2 Oct 16, 2014 5:14 AM (in response to erhard)1 of 1 people found this helpfulHi Erhard,
Your main problem is with the contracts you are using. It would simplify everything if you just use an interface of:
"void write(String content)" as then the contents of the file would get converted to String before hitting the camel route, and then to the JMS as Text.
Read this: http://unpoucode.blogspot.com.es/2014/10/switchyard-contracts.html
PS: You can also use a ESB interface, which doesn't tie you to a physical class for the interface.
PS2: In this other entry (http://unpoucode.blogspot.com.es/2014/10/copy-files-with-switchyard.html) you have a link to a github project where you can see at least left side of things (file binding with String contract) To adapt to your example, just replace the reference with the JMS binding you have (use the String example).
Cheers, and I hope it helps,
-
4. Re: Simple forward from file the queue
erhard Oct 17, 2014 6:01 AM (in response to jorgemoralespou_2)Hi Jorge,
These are really interesting posts on your blog. Thanks! The reason why I'm hesitant to use String is the following:
The real use cases are not simple copying of messages, but something like reading a XML-message, transforming it with JAXB to a Java object and do further manipulation. See e.g. sy-poc/switchyard.xml at master · Gepardec/sy-poc · GitHub for a little proof of concept we did. When I use WSDL -> Java-Interface (XML->MyMessage) I can use a JAXB transformer easily. However, when I tried String->MyMessage I couldn't find a way to do it with JAXB.
The File->JMS is only one occasion when I had to use a explicit conversion in Camel. Another is in sy-poc/ResultRoute.java at master · Gepardec/sy-poc · GitHub where I get a org.apache.camel.component.exec.ExecResult.
As I see it, on hand there is the interface to define the content-type of the message like Person or Order for example as XML. On the other hand this XML is "carried" on a String, a Stream, a File or in a ExecResult. The problem seem to be that for example on the JMS-component there is no (easy?) way to say "The message should be a Order as String". Therefore the JMS-Component gets an ExecResult-object or a File-object and doesn't know how to handle it properly.
Best regards
Erhard
-
5. Re: Re: Simple forward from file the queue
jorgemoralespou_2 Oct 17, 2014 6:14 AM (in response to erhard)Hi,
Understood your point here. I guess that what you require is to the JMS binding do a conversion, from the pojo/XML type to String, so set a transformer there. If you instead need the XML representation of the object to be there, you need to instruct the implicit transform, like this:
public interface OrderService { @OperationTypes(in = "{urn:switchyard-quickstart:bean-service:1.0}submitOrder") void submitOrder(String orderXML); }
This way you'll get into the submitOrder:
<urn:submitOrder xmlns:urn="urn:switchyard-quickstart:bean-service:1.0"> <order> <orderId>1</orderId> <itemId>1</itemId> <quantity>100</quantity> </order> </urn:submitOrder>
I hope this does the trick for you. That tip is in: http://unpoucode.blogspot.com.es/2014/10/switchyard-development-guidelines.html when talking about @OperationTypes.