-
1. Re: Camel JMS reference binding
ozkin Mar 22, 2015 3:53 PM (in response to ozkin)Does anyone have any working example of using Camel JMS reference binding? Such that Java operation takes non-String argument (as in the example above).
-
2. Re: Camel JMS reference binding
igarashitm Mar 22, 2015 10:01 PM (in response to ozkin)Hi Max,
What should I do in order to be able to send POJO to JMS queue? Well, actually I need to send a JSON representation of this POJO.
I tried to add a transformer from Customer to String but it didn't help.
So You want to send a String message in JSON format, right? then you would need to use String type as a parameter. If you use Customer object as a parameter, then it means you want to send Customer object into JMS queue, and because of the Customer class doesn't implements Serializable, it can't be sent to JMS queue. Please remember SwitchYard transformer is applied when it checks the service contract and find a gap in input/output type.
One another option would be to add your own camel converter from Customer to String, so camel would internally convert it at the last stage of the exchange. It's out of SwitchYard managed transformation though. See messageConverter option:
hth,
Tomo
-
3. Re: Camel JMS reference binding
ozkin Mar 23, 2015 4:25 AM (in response to igarashitm)Thanks Tomo. It is clear now that SY's Transformers won't help here.
Could you pls provide one clarification on messageConverter option.. if I don't use Camel components (so I have no from()/to()) but use only Bean component and invoke composite reference, how/where do I specify custom converter as a Camel JMS option?
-
4. Re: Camel JMS reference binding
igarashitm Mar 23, 2015 4:50 AM (in response to ozkin)You should be able to use additionalUriParameters in binding.jms config. I would recommend to use SY transformer in this case to show the message type as a contract though.
-
5. Re: Camel JMS reference binding
ozkin Mar 24, 2015 6:39 PM (in response to igarashitm)I tried to use additionalUriParameters and set "messageConverter" property into the name of my transformer class. But at runtime it threw exception:
Caused by: java.lang.IllegalArgumentException: Could not find a suitable setter for property: messageConverter as there isn't a setter method with same type: java.lang.String nor type conversion possible: No type converter available to convert from type: java.lang.String to the required type: org.springframework.jms.support.converter.MessageConverter with value my.test.Transformers.
What should be actually the value of "messageConverter" property? is it a class name? if so, what class it should point to?
You mentioned SY transformer.. I used my transformer which basically has a method with "@Transformer" annotation..
What is missing?
-
6. Re: Camel JMS reference binding
igarashitm Mar 24, 2015 7:27 PM (in response to ozkin)I meant to change the parameter type to String and let SwitchYard transformer transform it. SwitchYard transformer is not a camel converter. Please see my first comment.
-
7. Re: Camel JMS reference binding
ozkin Mar 27, 2015 3:05 PM (in response to igarashitm)If I would use "String" as the parameter type then why would I need a transformer at all? It is already String and can be sent as such. And the calling bean would have to send the string to the composite reference instead of POJO, but that was the whole point that I want my bean to send POJO and let SY to transform it to String before sending to JMS.
Thus I tried to explore the alternative approach with messageConverter, but couldn't make it work.
-
8. Re: Camel JMS reference binding
igarashitm Mar 27, 2015 6:44 PM (in response to ozkin)If you just change the parameter of composite reference to String and keep the parameter of component reference as Customer, now you have a gap between them. Then SwitchYard transformer is picked up if Customer->String transformer exists. You can still send Customer object if parameter for component reference is Customer. For example, jca-inflow-hornetq quickstart uses this technique in its service binding, composite service has GreetingGateway interface with named JSON String parameter and component service has GreetingService interface with Person POJO. It triggers JSON->Person transformer.
-
9. Re: Camel JMS reference binding
igarashitm Mar 27, 2015 7:14 PM (in response to ozkin)1 of 1 people found this helpfulYou would need to add @Named("myCustomerConverter") on your camel converter and specify messageConverter=#myCustomerConverter. But again, IMHO the first option for this usecase is to use SwitchYard transformer, so that you can see the type difference on the service contract.
-
10. Re: Camel JMS reference binding
ozkin Mar 27, 2015 7:15 PM (in response to igarashitm)Thanks. This way it works (with SY transformers).
I just had one Java interface for both component reference and composite reference. Now when I split it and created two interfaces (one accepting Customer and another accepting String), it works fine.