You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Stephen J <st...@mclaneco.com> on 2008/12/04 15:23:19 UTC
Camel to Websphere MQ communication
Does anyone know how to set the targetClient property to a Websphere MQ
destination? Right now Camel is putting messages on my MQ queue in a JMS
format. This causes extra headers to be appended to the message body, so
when you pull messages off the MQ queue with a regular MQ client all those
extra headers show up in the message body.
The way to fix this is to specify targetClient=1 on the MQ queue you are
sending to, but I can't figure out how to tell Camel to do that.
If I could configure the MQ destination something like this:
<bean id="MQDestQueue" class="com.ibm.mq.jms.MQQueue">
<constructor-arg index="0" value="AMQ.TEST.Q"/>
<property name="targetClient" value="1" />
</bean>
Then have camel route to that queue, I think that would solve the problem.
I can't figure out how to specify queue destinations like the above example.
Does anyone know how to do this, or how to fix this issue with sending to a
Websphere MQ queue?
Thanks.
--
View this message in context: http://www.nabble.com/Camel-to-Websphere-MQ-communication-tp20834360s22882p20834360.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel to Websphere MQ communication
Posted by James Strachan <ja...@gmail.com>.
Good idea!
2008/12/9 Claus Ibsen <cl...@gmail.com>:
> When that is said, I think we should add a cookbook section how to
> configure WebSphere MQ queues with this targetClient option in the
> Camel wiki documentation. And we could link to it from camel-jms
>
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>
>
>
> On Tue, Dec 9, 2008 at 9:47 AM, Claus Ibsen <cl...@gmail.com> wrote:
>> Hi
>>
>> I doubt the patch could depend on IBM WebSphere MQ .jars so it should
>> use reflection
>> ... or just use Camel's IntrospectionProperites that can auto set them.
>>
>> Or am I mistaking?
>>
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>>
>> On Tue, Dec 9, 2008 at 8:55 AM, <ja...@gmail.com> wrote:
>>> Agreed - we should now be able to easily configure any JMS endpoint
>>> with any required settings.
>>>
>>> Having said that - if someone fancies submitting a patch we could add
>>> an MQ based Component & Endpoint to expose all the MQ specific
>>> properties more easily - lettting folks stick to Uris if they prefer.
>>>
>>> On 08/12/2008, Claus Ibsen <cl...@gmail.com> wrote:
>>>> Hi
>>>>
>>>> If you look at the latest commits today from James Strachan I think he
>>>> add to Camel 2.0 a solution to your problem.
>>>> See his comment on CAMEL-505
>>>> http://issues.apache.org/activemq/browse/CAMEL-505
>>>>
>>>> /Claus Ibsen
>>>> Apache Camel Committer
>>>> Blog: http://davsclaus.blogspot.com/
>>>>
>>>>
>>>>
>>>> On Sun, Dec 7, 2008 at 11:20 AM, Tomasz Domzal
>>>> <ca...@rej.tomasz.domzal.pl> wrote:
>>>>>
>>>>> I had exactly same problem few months ago and came up with quick and dirty
>>>>> solution.
>>>>> By default all attributes on Camel JMS URI (ex. targetClient for Websphare
>>>>> MQ) are are passed to camel JmsComponent object. Such behavior is not what
>>>>> we want in case of additional destination attributes (like MS MQ
>>>>> 'targetClient'). But in JmsComponent object there is method:
>>>>>
>>>>> protected String convertPathToActualDestination(String path, Map
>>>>> parameters)
>>>>>
>>>>> which overloaded can modify this behavior. There is extended JmsComponent
>>>>> code. Please find more description in supplied javadoc snippet:
>>>>>
>>>>> // -------------------
>>>>>
>>>>> /**
>>>>> * JMSComponent with modification that allows setting attributes on JMS
>>>>> destination object.<br/>
>>>>> * Attributes enumerated in 'destinationArgs' attribute will be set as
>>>>> attributes on destination URI instead on underlying {@link JmsComponent}
>>>>> object.
>>>>> * For example setting 'targetClient' attribute on Webshere MQ in Camel
>>>>> JMS
>>>>> endpoint URI should look like:
>>>>> *
>>>>> <pre>jmsMqComp:queue:queue://queue_name?destinationArgs=targetClient&targetClient=1</pre>
>>>>> * where jmsMqComp is bean id of {@link
>>>>> JmsComponentWithDestinationAttributes} instance.<br/>
>>>>> * (Please note URI attribute setting method on Websphere MQ works only
>>>>> with
>>>>> URI queue format - thats the reason
>>>>> * there is keyword 'queue' is used twice in this example - first is from
>>>>> Camel URI format, second starts WS MQ queue URI)
>>>>> */
>>>>> public class JmsComponentWithDestinationAttributes extends JmsComponent {
>>>>>
>>>>> private Log log =
>>>>> LogFactory.getLog(JmsComponentWithDestinationAttributes.class);
>>>>>
>>>>> @Override
>>>>> protected String convertPathToActualDestination(String path, Map
>>>>> parameters) {
>>>>> if (log.isDebugEnabled())
>>>>> log.debug("resolve: [path: "+path+"][parameters: "+parameters+"]");
>>>>> String subject = super.convertPathToActualDestination(path,
>>>>> parameters);
>>>>> // attributes enumerated in 'destinationArgs' are removed from map and
>>>>> appended as destination options
>>>>> if (parameters.containsKey("destinationArgs")) {
>>>>> StringBuffer subjectBuf = new StringBuffer(subject);
>>>>> boolean subjectHasOptions = (subject.indexOf('?')!=-1);
>>>>> String destinationArgs = (String)
>>>>> parameters.remove("destinationArgs");
>>>>> String[] args = destinationArgs.split(",");
>>>>> for (String arg : args) {
>>>>> if (subjectHasOptions) {
>>>>> subjectBuf.append("&");
>>>>> } else {
>>>>> subjectBuf.append("?");
>>>>> subjectHasOptions = true;
>>>>> }
>>>>> subjectBuf.append(arg);
>>>>> subjectBuf.append('=');
>>>>> subjectBuf.append((String) parameters.remove(arg));
>>>>> }
>>>>> subject = subjectBuf.toString();
>>>>> }
>>>>> if (log.isDebugEnabled())
>>>>> log.debug("resolved [path: "+subject+"][parameters:
>>>>> "+parameters+"]");
>>>>> return subject;
>>>>> }
>>>>> }
>>>>>
>>>>> // -------------------
>>>>>
>>>>> and assuming Spring bean configuration:
>>>>>
>>>>> <bean id="jmsMqComp"
>>>>> class="com.somecompany.JmsComponentWithDestinationAttributes">
>>>>> <property name="connectionFactory">
>>>>> <bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
>>>>> <property name="transportType">
>>>>> <util:constant
>>>>> static-field="com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP"/>
>>>>> </property>
>>>>> <property name="hostName" value="mq_host"/>
>>>>> <property name="port" value="mq_port" />
>>>>> <property name="queueManager" value="mq_qmanager"/>
>>>>> <property name="channel" value="mq_channel"/>
>>>>> </bean>
>>>>> </property>
>>>>> </bean>
>>>>>
>>>>> JMS URI in Camel:
>>>>>
>>>>>
>>>>> jmsMqComp:queue:queue://queue_name?destinationArgs=targetClient&targetClient=1
>>>>>
>>>>> will set targetClient=1 option on WS MQ destination.
>>>>>
>>>>> It's definitely not best solution. ActiveMQ has dedicated component in
>>>>> Camel
>>>>> which accepts many AMQ dedicated options. Maybe this is way to go for
>>>>> Websphere MQ also ?
>>>>> --
>>>>> View this message in context:
>>>>> http://www.nabble.com/Camel-to-Websphere-MQ-communication-tp20834360s22882p20879636.html
>>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>>
>>>>>
>>>>
>>>
>>>
>>> --
>>> James
>>> -------
>>> http://macstrac.blogspot.com/
>>>
>>> Open Source Integration
>>> http://fusesource.com/
>>>
>>
>
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/
Re: Camel to Websphere MQ communication
Posted by Claus Ibsen <cl...@gmail.com>.
When that is said, I think we should add a cookbook section how to
configure WebSphere MQ queues with this targetClient option in the
Camel wiki documentation. And we could link to it from camel-jms
/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/
On Tue, Dec 9, 2008 at 9:47 AM, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> I doubt the patch could depend on IBM WebSphere MQ .jars so it should
> use reflection
> ... or just use Camel's IntrospectionProperites that can auto set them.
>
> Or am I mistaking?
>
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>
>
>
> On Tue, Dec 9, 2008 at 8:55 AM, <ja...@gmail.com> wrote:
>> Agreed - we should now be able to easily configure any JMS endpoint
>> with any required settings.
>>
>> Having said that - if someone fancies submitting a patch we could add
>> an MQ based Component & Endpoint to expose all the MQ specific
>> properties more easily - lettting folks stick to Uris if they prefer.
>>
>> On 08/12/2008, Claus Ibsen <cl...@gmail.com> wrote:
>>> Hi
>>>
>>> If you look at the latest commits today from James Strachan I think he
>>> add to Camel 2.0 a solution to your problem.
>>> See his comment on CAMEL-505
>>> http://issues.apache.org/activemq/browse/CAMEL-505
>>>
>>> /Claus Ibsen
>>> Apache Camel Committer
>>> Blog: http://davsclaus.blogspot.com/
>>>
>>>
>>>
>>> On Sun, Dec 7, 2008 at 11:20 AM, Tomasz Domzal
>>> <ca...@rej.tomasz.domzal.pl> wrote:
>>>>
>>>> I had exactly same problem few months ago and came up with quick and dirty
>>>> solution.
>>>> By default all attributes on Camel JMS URI (ex. targetClient for Websphare
>>>> MQ) are are passed to camel JmsComponent object. Such behavior is not what
>>>> we want in case of additional destination attributes (like MS MQ
>>>> 'targetClient'). But in JmsComponent object there is method:
>>>>
>>>> protected String convertPathToActualDestination(String path, Map
>>>> parameters)
>>>>
>>>> which overloaded can modify this behavior. There is extended JmsComponent
>>>> code. Please find more description in supplied javadoc snippet:
>>>>
>>>> // -------------------
>>>>
>>>> /**
>>>> * JMSComponent with modification that allows setting attributes on JMS
>>>> destination object.<br/>
>>>> * Attributes enumerated in 'destinationArgs' attribute will be set as
>>>> attributes on destination URI instead on underlying {@link JmsComponent}
>>>> object.
>>>> * For example setting 'targetClient' attribute on Webshere MQ in Camel
>>>> JMS
>>>> endpoint URI should look like:
>>>> *
>>>> <pre>jmsMqComp:queue:queue://queue_name?destinationArgs=targetClient&targetClient=1</pre>
>>>> * where jmsMqComp is bean id of {@link
>>>> JmsComponentWithDestinationAttributes} instance.<br/>
>>>> * (Please note URI attribute setting method on Websphere MQ works only
>>>> with
>>>> URI queue format - thats the reason
>>>> * there is keyword 'queue' is used twice in this example - first is from
>>>> Camel URI format, second starts WS MQ queue URI)
>>>> */
>>>> public class JmsComponentWithDestinationAttributes extends JmsComponent {
>>>>
>>>> private Log log =
>>>> LogFactory.getLog(JmsComponentWithDestinationAttributes.class);
>>>>
>>>> @Override
>>>> protected String convertPathToActualDestination(String path, Map
>>>> parameters) {
>>>> if (log.isDebugEnabled())
>>>> log.debug("resolve: [path: "+path+"][parameters: "+parameters+"]");
>>>> String subject = super.convertPathToActualDestination(path,
>>>> parameters);
>>>> // attributes enumerated in 'destinationArgs' are removed from map and
>>>> appended as destination options
>>>> if (parameters.containsKey("destinationArgs")) {
>>>> StringBuffer subjectBuf = new StringBuffer(subject);
>>>> boolean subjectHasOptions = (subject.indexOf('?')!=-1);
>>>> String destinationArgs = (String)
>>>> parameters.remove("destinationArgs");
>>>> String[] args = destinationArgs.split(",");
>>>> for (String arg : args) {
>>>> if (subjectHasOptions) {
>>>> subjectBuf.append("&");
>>>> } else {
>>>> subjectBuf.append("?");
>>>> subjectHasOptions = true;
>>>> }
>>>> subjectBuf.append(arg);
>>>> subjectBuf.append('=');
>>>> subjectBuf.append((String) parameters.remove(arg));
>>>> }
>>>> subject = subjectBuf.toString();
>>>> }
>>>> if (log.isDebugEnabled())
>>>> log.debug("resolved [path: "+subject+"][parameters:
>>>> "+parameters+"]");
>>>> return subject;
>>>> }
>>>> }
>>>>
>>>> // -------------------
>>>>
>>>> and assuming Spring bean configuration:
>>>>
>>>> <bean id="jmsMqComp"
>>>> class="com.somecompany.JmsComponentWithDestinationAttributes">
>>>> <property name="connectionFactory">
>>>> <bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
>>>> <property name="transportType">
>>>> <util:constant
>>>> static-field="com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP"/>
>>>> </property>
>>>> <property name="hostName" value="mq_host"/>
>>>> <property name="port" value="mq_port" />
>>>> <property name="queueManager" value="mq_qmanager"/>
>>>> <property name="channel" value="mq_channel"/>
>>>> </bean>
>>>> </property>
>>>> </bean>
>>>>
>>>> JMS URI in Camel:
>>>>
>>>>
>>>> jmsMqComp:queue:queue://queue_name?destinationArgs=targetClient&targetClient=1
>>>>
>>>> will set targetClient=1 option on WS MQ destination.
>>>>
>>>> It's definitely not best solution. ActiveMQ has dedicated component in
>>>> Camel
>>>> which accepts many AMQ dedicated options. Maybe this is way to go for
>>>> Websphere MQ also ?
>>>> --
>>>> View this message in context:
>>>> http://www.nabble.com/Camel-to-Websphere-MQ-communication-tp20834360s22882p20879636.html
>>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>>
>>>>
>>>
>>
>>
>> --
>> James
>> -------
>> http://macstrac.blogspot.com/
>>
>> Open Source Integration
>> http://fusesource.com/
>>
>
Re: Camel to Websphere MQ communication
Posted by James Strachan <ja...@gmail.com>.
2008/12/9 Claus Ibsen <cl...@gmail.com>:
> Hi
>
> I doubt the patch could depend on IBM WebSphere MQ .jars so it should
> use reflection
> ... or just use Camel's IntrospectionProperites that can auto set them.
>
> Or am I mistaking?
Great point - we'd have to check what the license is. The MQ component
might have to live outside of Apache due to licensing.
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/
Re: Camel to Websphere MQ communication
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
I doubt the patch could depend on IBM WebSphere MQ .jars so it should
use reflection
... or just use Camel's IntrospectionProperites that can auto set them.
Or am I mistaking?
/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/
On Tue, Dec 9, 2008 at 8:55 AM, <ja...@gmail.com> wrote:
> Agreed - we should now be able to easily configure any JMS endpoint
> with any required settings.
>
> Having said that - if someone fancies submitting a patch we could add
> an MQ based Component & Endpoint to expose all the MQ specific
> properties more easily - lettting folks stick to Uris if they prefer.
>
> On 08/12/2008, Claus Ibsen <cl...@gmail.com> wrote:
>> Hi
>>
>> If you look at the latest commits today from James Strachan I think he
>> add to Camel 2.0 a solution to your problem.
>> See his comment on CAMEL-505
>> http://issues.apache.org/activemq/browse/CAMEL-505
>>
>> /Claus Ibsen
>> Apache Camel Committer
>> Blog: http://davsclaus.blogspot.com/
>>
>>
>>
>> On Sun, Dec 7, 2008 at 11:20 AM, Tomasz Domzal
>> <ca...@rej.tomasz.domzal.pl> wrote:
>>>
>>> I had exactly same problem few months ago and came up with quick and dirty
>>> solution.
>>> By default all attributes on Camel JMS URI (ex. targetClient for Websphare
>>> MQ) are are passed to camel JmsComponent object. Such behavior is not what
>>> we want in case of additional destination attributes (like MS MQ
>>> 'targetClient'). But in JmsComponent object there is method:
>>>
>>> protected String convertPathToActualDestination(String path, Map
>>> parameters)
>>>
>>> which overloaded can modify this behavior. There is extended JmsComponent
>>> code. Please find more description in supplied javadoc snippet:
>>>
>>> // -------------------
>>>
>>> /**
>>> * JMSComponent with modification that allows setting attributes on JMS
>>> destination object.<br/>
>>> * Attributes enumerated in 'destinationArgs' attribute will be set as
>>> attributes on destination URI instead on underlying {@link JmsComponent}
>>> object.
>>> * For example setting 'targetClient' attribute on Webshere MQ in Camel
>>> JMS
>>> endpoint URI should look like:
>>> *
>>> <pre>jmsMqComp:queue:queue://queue_name?destinationArgs=targetClient&targetClient=1</pre>
>>> * where jmsMqComp is bean id of {@link
>>> JmsComponentWithDestinationAttributes} instance.<br/>
>>> * (Please note URI attribute setting method on Websphere MQ works only
>>> with
>>> URI queue format - thats the reason
>>> * there is keyword 'queue' is used twice in this example - first is from
>>> Camel URI format, second starts WS MQ queue URI)
>>> */
>>> public class JmsComponentWithDestinationAttributes extends JmsComponent {
>>>
>>> private Log log =
>>> LogFactory.getLog(JmsComponentWithDestinationAttributes.class);
>>>
>>> @Override
>>> protected String convertPathToActualDestination(String path, Map
>>> parameters) {
>>> if (log.isDebugEnabled())
>>> log.debug("resolve: [path: "+path+"][parameters: "+parameters+"]");
>>> String subject = super.convertPathToActualDestination(path,
>>> parameters);
>>> // attributes enumerated in 'destinationArgs' are removed from map and
>>> appended as destination options
>>> if (parameters.containsKey("destinationArgs")) {
>>> StringBuffer subjectBuf = new StringBuffer(subject);
>>> boolean subjectHasOptions = (subject.indexOf('?')!=-1);
>>> String destinationArgs = (String)
>>> parameters.remove("destinationArgs");
>>> String[] args = destinationArgs.split(",");
>>> for (String arg : args) {
>>> if (subjectHasOptions) {
>>> subjectBuf.append("&");
>>> } else {
>>> subjectBuf.append("?");
>>> subjectHasOptions = true;
>>> }
>>> subjectBuf.append(arg);
>>> subjectBuf.append('=');
>>> subjectBuf.append((String) parameters.remove(arg));
>>> }
>>> subject = subjectBuf.toString();
>>> }
>>> if (log.isDebugEnabled())
>>> log.debug("resolved [path: "+subject+"][parameters:
>>> "+parameters+"]");
>>> return subject;
>>> }
>>> }
>>>
>>> // -------------------
>>>
>>> and assuming Spring bean configuration:
>>>
>>> <bean id="jmsMqComp"
>>> class="com.somecompany.JmsComponentWithDestinationAttributes">
>>> <property name="connectionFactory">
>>> <bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
>>> <property name="transportType">
>>> <util:constant
>>> static-field="com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP"/>
>>> </property>
>>> <property name="hostName" value="mq_host"/>
>>> <property name="port" value="mq_port" />
>>> <property name="queueManager" value="mq_qmanager"/>
>>> <property name="channel" value="mq_channel"/>
>>> </bean>
>>> </property>
>>> </bean>
>>>
>>> JMS URI in Camel:
>>>
>>>
>>> jmsMqComp:queue:queue://queue_name?destinationArgs=targetClient&targetClient=1
>>>
>>> will set targetClient=1 option on WS MQ destination.
>>>
>>> It's definitely not best solution. ActiveMQ has dedicated component in
>>> Camel
>>> which accepts many AMQ dedicated options. Maybe this is way to go for
>>> Websphere MQ also ?
>>> --
>>> View this message in context:
>>> http://www.nabble.com/Camel-to-Websphere-MQ-communication-tp20834360s22882p20879636.html
>>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>>
>>>
>>
>
>
> --
> James
> -------
> http://macstrac.blogspot.com/
>
> Open Source Integration
> http://fusesource.com/
>
Re: Camel to Websphere MQ communication
Posted by ja...@gmail.com.
Agreed - we should now be able to easily configure any JMS endpoint
with any required settings.
Having said that - if someone fancies submitting a patch we could add
an MQ based Component & Endpoint to expose all the MQ specific
properties more easily - lettting folks stick to Uris if they prefer.
On 08/12/2008, Claus Ibsen <cl...@gmail.com> wrote:
> Hi
>
> If you look at the latest commits today from James Strachan I think he
> add to Camel 2.0 a solution to your problem.
> See his comment on CAMEL-505
> http://issues.apache.org/activemq/browse/CAMEL-505
>
> /Claus Ibsen
> Apache Camel Committer
> Blog: http://davsclaus.blogspot.com/
>
>
>
> On Sun, Dec 7, 2008 at 11:20 AM, Tomasz Domzal
> <ca...@rej.tomasz.domzal.pl> wrote:
>>
>> I had exactly same problem few months ago and came up with quick and dirty
>> solution.
>> By default all attributes on Camel JMS URI (ex. targetClient for Websphare
>> MQ) are are passed to camel JmsComponent object. Such behavior is not what
>> we want in case of additional destination attributes (like MS MQ
>> 'targetClient'). But in JmsComponent object there is method:
>>
>> protected String convertPathToActualDestination(String path, Map
>> parameters)
>>
>> which overloaded can modify this behavior. There is extended JmsComponent
>> code. Please find more description in supplied javadoc snippet:
>>
>> // -------------------
>>
>> /**
>> * JMSComponent with modification that allows setting attributes on JMS
>> destination object.<br/>
>> * Attributes enumerated in 'destinationArgs' attribute will be set as
>> attributes on destination URI instead on underlying {@link JmsComponent}
>> object.
>> * For example setting 'targetClient' attribute on Webshere MQ in Camel
>> JMS
>> endpoint URI should look like:
>> *
>> <pre>jmsMqComp:queue:queue://queue_name?destinationArgs=targetClient&targetClient=1</pre>
>> * where jmsMqComp is bean id of {@link
>> JmsComponentWithDestinationAttributes} instance.<br/>
>> * (Please note URI attribute setting method on Websphere MQ works only
>> with
>> URI queue format - thats the reason
>> * there is keyword 'queue' is used twice in this example - first is from
>> Camel URI format, second starts WS MQ queue URI)
>> */
>> public class JmsComponentWithDestinationAttributes extends JmsComponent {
>>
>> private Log log =
>> LogFactory.getLog(JmsComponentWithDestinationAttributes.class);
>>
>> @Override
>> protected String convertPathToActualDestination(String path, Map
>> parameters) {
>> if (log.isDebugEnabled())
>> log.debug("resolve: [path: "+path+"][parameters: "+parameters+"]");
>> String subject = super.convertPathToActualDestination(path,
>> parameters);
>> // attributes enumerated in 'destinationArgs' are removed from map and
>> appended as destination options
>> if (parameters.containsKey("destinationArgs")) {
>> StringBuffer subjectBuf = new StringBuffer(subject);
>> boolean subjectHasOptions = (subject.indexOf('?')!=-1);
>> String destinationArgs = (String)
>> parameters.remove("destinationArgs");
>> String[] args = destinationArgs.split(",");
>> for (String arg : args) {
>> if (subjectHasOptions) {
>> subjectBuf.append("&");
>> } else {
>> subjectBuf.append("?");
>> subjectHasOptions = true;
>> }
>> subjectBuf.append(arg);
>> subjectBuf.append('=');
>> subjectBuf.append((String) parameters.remove(arg));
>> }
>> subject = subjectBuf.toString();
>> }
>> if (log.isDebugEnabled())
>> log.debug("resolved [path: "+subject+"][parameters:
>> "+parameters+"]");
>> return subject;
>> }
>> }
>>
>> // -------------------
>>
>> and assuming Spring bean configuration:
>>
>> <bean id="jmsMqComp"
>> class="com.somecompany.JmsComponentWithDestinationAttributes">
>> <property name="connectionFactory">
>> <bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
>> <property name="transportType">
>> <util:constant
>> static-field="com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP"/>
>> </property>
>> <property name="hostName" value="mq_host"/>
>> <property name="port" value="mq_port" />
>> <property name="queueManager" value="mq_qmanager"/>
>> <property name="channel" value="mq_channel"/>
>> </bean>
>> </property>
>> </bean>
>>
>> JMS URI in Camel:
>>
>>
>> jmsMqComp:queue:queue://queue_name?destinationArgs=targetClient&targetClient=1
>>
>> will set targetClient=1 option on WS MQ destination.
>>
>> It's definitely not best solution. ActiveMQ has dedicated component in
>> Camel
>> which accepts many AMQ dedicated options. Maybe this is way to go for
>> Websphere MQ also ?
>> --
>> View this message in context:
>> http://www.nabble.com/Camel-to-Websphere-MQ-communication-tp20834360s22882p20879636.html
>> Sent from the Camel - Users mailing list archive at Nabble.com.
>>
>>
>
--
James
-------
http://macstrac.blogspot.com/
Open Source Integration
http://fusesource.com/
Re: Camel to Websphere MQ communication
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
If you look at the latest commits today from James Strachan I think he
add to Camel 2.0 a solution to your problem.
See his comment on CAMEL-505
http://issues.apache.org/activemq/browse/CAMEL-505
/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/
On Sun, Dec 7, 2008 at 11:20 AM, Tomasz Domzal
<ca...@rej.tomasz.domzal.pl> wrote:
>
> I had exactly same problem few months ago and came up with quick and dirty
> solution.
> By default all attributes on Camel JMS URI (ex. targetClient for Websphare
> MQ) are are passed to camel JmsComponent object. Such behavior is not what
> we want in case of additional destination attributes (like MS MQ
> 'targetClient'). But in JmsComponent object there is method:
>
> protected String convertPathToActualDestination(String path, Map
> parameters)
>
> which overloaded can modify this behavior. There is extended JmsComponent
> code. Please find more description in supplied javadoc snippet:
>
> // -------------------
>
> /**
> * JMSComponent with modification that allows setting attributes on JMS
> destination object.<br/>
> * Attributes enumerated in 'destinationArgs' attribute will be set as
> attributes on destination URI instead on underlying {@link JmsComponent}
> object.
> * For example setting 'targetClient' attribute on Webshere MQ in Camel JMS
> endpoint URI should look like:
> *
> <pre>jmsMqComp:queue:queue://queue_name?destinationArgs=targetClient&targetClient=1</pre>
> * where jmsMqComp is bean id of {@link
> JmsComponentWithDestinationAttributes} instance.<br/>
> * (Please note URI attribute setting method on Websphere MQ works only with
> URI queue format - thats the reason
> * there is keyword 'queue' is used twice in this example - first is from
> Camel URI format, second starts WS MQ queue URI)
> */
> public class JmsComponentWithDestinationAttributes extends JmsComponent {
>
> private Log log =
> LogFactory.getLog(JmsComponentWithDestinationAttributes.class);
>
> @Override
> protected String convertPathToActualDestination(String path, Map
> parameters) {
> if (log.isDebugEnabled())
> log.debug("resolve: [path: "+path+"][parameters: "+parameters+"]");
> String subject = super.convertPathToActualDestination(path, parameters);
> // attributes enumerated in 'destinationArgs' are removed from map and
> appended as destination options
> if (parameters.containsKey("destinationArgs")) {
> StringBuffer subjectBuf = new StringBuffer(subject);
> boolean subjectHasOptions = (subject.indexOf('?')!=-1);
> String destinationArgs = (String)
> parameters.remove("destinationArgs");
> String[] args = destinationArgs.split(",");
> for (String arg : args) {
> if (subjectHasOptions) {
> subjectBuf.append("&");
> } else {
> subjectBuf.append("?");
> subjectHasOptions = true;
> }
> subjectBuf.append(arg);
> subjectBuf.append('=');
> subjectBuf.append((String) parameters.remove(arg));
> }
> subject = subjectBuf.toString();
> }
> if (log.isDebugEnabled())
> log.debug("resolved [path: "+subject+"][parameters: "+parameters+"]");
> return subject;
> }
> }
>
> // -------------------
>
> and assuming Spring bean configuration:
>
> <bean id="jmsMqComp"
> class="com.somecompany.JmsComponentWithDestinationAttributes">
> <property name="connectionFactory">
> <bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
> <property name="transportType">
> <util:constant
> static-field="com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP"/>
> </property>
> <property name="hostName" value="mq_host"/>
> <property name="port" value="mq_port" />
> <property name="queueManager" value="mq_qmanager"/>
> <property name="channel" value="mq_channel"/>
> </bean>
> </property>
> </bean>
>
> JMS URI in Camel:
>
>
> jmsMqComp:queue:queue://queue_name?destinationArgs=targetClient&targetClient=1
>
> will set targetClient=1 option on WS MQ destination.
>
> It's definitely not best solution. ActiveMQ has dedicated component in Camel
> which accepts many AMQ dedicated options. Maybe this is way to go for
> Websphere MQ also ?
> --
> View this message in context: http://www.nabble.com/Camel-to-Websphere-MQ-communication-tp20834360s22882p20879636.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>
Re: Camel to Websphere MQ communication
Posted by Tomasz Domzal <ca...@rej.tomasz.domzal.pl>.
I had exactly same problem few months ago and came up with quick and dirty
solution.
By default all attributes on Camel JMS URI (ex. targetClient for Websphare
MQ) are are passed to camel JmsComponent object. Such behavior is not what
we want in case of additional destination attributes (like MS MQ
'targetClient'). But in JmsComponent object there is method:
protected String convertPathToActualDestination(String path, Map
parameters)
which overloaded can modify this behavior. There is extended JmsComponent
code. Please find more description in supplied javadoc snippet:
// -------------------
/**
* JMSComponent with modification that allows setting attributes on JMS
destination object.<br/>
* Attributes enumerated in 'destinationArgs' attribute will be set as
attributes on destination URI instead on underlying {@link JmsComponent}
object.
* For example setting 'targetClient' attribute on Webshere MQ in Camel JMS
endpoint URI should look like:
*
<pre>jmsMqComp:queue:queue://queue_name?destinationArgs=targetClient&targetClient=1</pre>
* where jmsMqComp is bean id of {@link
JmsComponentWithDestinationAttributes} instance.<br/>
* (Please note URI attribute setting method on Websphere MQ works only with
URI queue format - thats the reason
* there is keyword 'queue' is used twice in this example - first is from
Camel URI format, second starts WS MQ queue URI)
*/
public class JmsComponentWithDestinationAttributes extends JmsComponent {
private Log log =
LogFactory.getLog(JmsComponentWithDestinationAttributes.class);
@Override
protected String convertPathToActualDestination(String path, Map
parameters) {
if (log.isDebugEnabled())
log.debug("resolve: [path: "+path+"][parameters: "+parameters+"]");
String subject = super.convertPathToActualDestination(path, parameters);
// attributes enumerated in 'destinationArgs' are removed from map and
appended as destination options
if (parameters.containsKey("destinationArgs")) {
StringBuffer subjectBuf = new StringBuffer(subject);
boolean subjectHasOptions = (subject.indexOf('?')!=-1);
String destinationArgs = (String)
parameters.remove("destinationArgs");
String[] args = destinationArgs.split(",");
for (String arg : args) {
if (subjectHasOptions) {
subjectBuf.append("&");
} else {
subjectBuf.append("?");
subjectHasOptions = true;
}
subjectBuf.append(arg);
subjectBuf.append('=');
subjectBuf.append((String) parameters.remove(arg));
}
subject = subjectBuf.toString();
}
if (log.isDebugEnabled())
log.debug("resolved [path: "+subject+"][parameters: "+parameters+"]");
return subject;
}
}
// -------------------
and assuming Spring bean configuration:
<bean id="jmsMqComp"
class="com.somecompany.JmsComponentWithDestinationAttributes">
<property name="connectionFactory">
<bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="transportType">
<util:constant
static-field="com.ibm.mq.jms.JMSC.MQJMS_TP_CLIENT_MQ_TCPIP"/>
</property>
<property name="hostName" value="mq_host"/>
<property name="port" value="mq_port" />
<property name="queueManager" value="mq_qmanager"/>
<property name="channel" value="mq_channel"/>
</bean>
</property>
</bean>
JMS URI in Camel:
jmsMqComp:queue:queue://queue_name?destinationArgs=targetClient&targetClient=1
will set targetClient=1 option on WS MQ destination.
It's definitely not best solution. ActiveMQ has dedicated component in Camel
which accepts many AMQ dedicated options. Maybe this is way to go for
Websphere MQ also ?
--
View this message in context: http://www.nabble.com/Camel-to-Websphere-MQ-communication-tp20834360s22882p20879636.html
Sent from the Camel - Users mailing list archive at Nabble.com.
Re: Camel to Websphere MQ communication
Posted by Claus Ibsen <cl...@gmail.com>.
Hi
Good question. Looks like there is something called DestinationResolver
org.springframework.jms.support.destination.DestinationResolver
Could you check upon this if that could be used? Maybe it could be
used to lookup the MQDestQueue bean id in the application context, to
be used as Destination.
I am wondering if you can inject your own DestinationResolver to the
camel jms endpoint.
If it's the way to get we improve camel to expose a setter so you can
inject your own resolver.
Please research a bit, and write back. Then we can create a ticket in
JIRA so we can get a nice solution in Camel to work with MQ queues.
/Claus Ibsen
Apache Camel Committer
Blog: http://davsclaus.blogspot.com/
On Thu, Dec 4, 2008 at 3:23 PM, Stephen J <st...@mclaneco.com> wrote:
>
> Does anyone know how to set the targetClient property to a Websphere MQ
> destination? Right now Camel is putting messages on my MQ queue in a JMS
> format. This causes extra headers to be appended to the message body, so
> when you pull messages off the MQ queue with a regular MQ client all those
> extra headers show up in the message body.
>
> The way to fix this is to specify targetClient=1 on the MQ queue you are
> sending to, but I can't figure out how to tell Camel to do that.
>
> If I could configure the MQ destination something like this:
> <bean id="MQDestQueue" class="com.ibm.mq.jms.MQQueue">
> <constructor-arg index="0" value="AMQ.TEST.Q"/>
> <property name="targetClient" value="1" />
> </bean>
>
> Then have camel route to that queue, I think that would solve the problem.
> I can't figure out how to specify queue destinations like the above example.
> Does anyone know how to do this, or how to fix this issue with sending to a
> Websphere MQ queue?
>
> Thanks.
> --
> View this message in context: http://www.nabble.com/Camel-to-Websphere-MQ-communication-tp20834360s22882p20834360.html
> Sent from the Camel - Users mailing list archive at Nabble.com.
>
>