-
1. Re: JMS message selector
igarashitm Jan 28, 2016 8:05 AM (in response to ozkin)There's a "selector" field if you open SwitchYard camel-jms binding properties tab in the SwitchYard editor. And "messageSelector" can be specified as a ActivationSpec property on JCA service binding as per JCA spec.
-
2. Re: JMS message selector
ozkin Jan 29, 2016 4:14 AM (in response to igarashitm)Handling of inbound jms messages is more or less clear, just as you said, using "selector" or "messageSelector" fields. If I understood right the selector can contain expressions with message header or message property values.
But what would be the right way to set those values when sending jms messages using either jca-jms or camel-jms reference bindings?
I guess when one needs to set a message header or message property he cannot use the reference defined with @Inject @Reference MyService but rather should use ReferenceInvoker because otherwise there is no access to those fields. Is that correct?
Or should one use the custom MessageComposer instead for setting those values for outgoing jms messages?
Btw, what is the meaning of "Selector" field in JMS reference binding in SY editor?
-
3. Re: JMS message selector
igarashitm Jan 29, 2016 4:24 AM (in response to ozkin)There's no way to specify selector on producer, it's only available for consumer. See JMS spec. The selector field will be ignored for JMS reference binding.
-
4. Re: JMS message selector
ozkin Jan 29, 2016 6:24 AM (in response to igarashitm)Yes, that's what I thought as well... but for me more important is other questions about how to specify values on outbound messages in SY, which are later used in selectors. Any hints?
-
5. Re: JMS message selector
igarashitm Jan 29, 2016 9:00 AM (in response to ozkin)Ah OK so you're looking for a way to set a JMS property when sending via reference binding? Basically the SwitchYard context properties will be mapped into JMS properties, and it requires ReferenceInvoker to do it from bean service. Not sure exactly for now though, I think you can use setHeader from camel route service to do the same.
Message Composition - SwitchYard - Project Documentation Editor
-
6. Re: JMS message selector
ozkin Jan 31, 2016 4:55 PM (in response to igarashitm)Yes. So, two approaches worked for me (when doing this from a Bean).
1) using ReferenceInvoker:
@Inject
@Reference("MyService")
private ReferenceInvoker myService;
@Override
public void foo() throws Exception {
ReferenceInvocation ri = myService.newInvocation();
ri.setProperty("customHeaderName", "customHeaderValue");
ri.invoke(n);
}
2) using custom JMSMessageComposer:
public class MyCustomComposer extends JMSMessageComposer {
@Override
public JMSBindingData decompose(Exchange exchange, JMSBindingData target) throws Exception {
exchange.getContext().setProperty("customHeaderName", "customHeaderValue", Scope.MESSAGE);
target = super.decompose(exchange, target);
return target;
}
}
Any hints which one would be more preferable or is it a matter of personal taste? or what other alternatives exist?
-
7. Re: JMS message selector
igarashitm Feb 2, 2016 5:16 AM (in response to ozkin)That depends - for example if that property is calculated from business logic then that definitely should be done by service implementation. If that property is a common one which is always included in incoming message, then I would choose ContextMapper. I would think the ContextMapper is a tool to get rid of common property processing from business logic.