Author |
Message
|
JavaRat |
Posted: Thu Sep 25, 2008 4:20 am Post subject: Spring Property |
|
|
Newbie
Joined: 23 Jun 2008 Posts: 8
|
Hello,
We have setup a Apache Camel Spring JMS application which can put message onto an IBM MQ websphere queue successfully using the following standard setup.
Code: |
<bean id="ibmmq" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory">
<bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="transportType">
<util:constant static-field="com.ibm.mq.jms.JMSC.MQJMS_CLIENT_NONJMS_MQ"/>
</property>
<property name="queueManager" value="MW01"/>
<property name="hostName" value="xxx.xxx.xxx.xxx"/>
<property name="port" value="1414"/>
</bean>
</property>
</bean>
<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="activemq:my.queue.in"/>
<to uri="ibmmq:queue:my.queue.out"/>
</route>
</camelContext>
<bean id="activemq" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://127.0.0.1:61616" />
</bean>
</property>
</bean> |
We now want to set a few properties on our messages such as JMSReplyTo, JMS_IBM_Format, JMS_IBM_MsgType.
Is it possible to set these in spring? In what ways can we solve this?
Thanks in advance!
/JavaRat |
|
Back to top |
|
 |
atheek |
Posted: Thu Sep 25, 2008 5:34 am Post subject: |
|
|
 Partisan
Joined: 01 Jun 2006 Posts: 327 Location: Sydney
|
Hi Javarat,
I have seen your post here:
http://www.nabble.com/Bridging-the-ActiveMQ-with-IBM-Websphere-using-Camel-td19623329s22882.html
Your problem appears to because you are getting the rfh header in the message. The MQ Queue destination object has a property TARGCLIENT which by default takes a value JMS. And in case you will get the RFHeader wrapped around the message..To remove this you need to set targclient to MQ. I have no clue on how you set this on spring..just try to figure out to set this..it may solve your issue |
|
Back to top |
|
 |
JLRowe |
Posted: Thu Sep 25, 2008 5:47 am Post subject: Re: Spring Property |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
Look at the JMS template mechanism in Spring and use of the class org.springframework.jms.core.JmsTemplate, you can set a message converter class that can convert between your domain object and a JMSMessage it can also perform customisation of the message - i.e. setting provider specific properties.
This is all documented in the spring documentation.
JavaRat wrote: |
Hello,
We have setup a Apache Camel Spring JMS application which can put message onto an IBM MQ websphere queue successfully using the following standard setup.
Code: |
<bean id="ibmmq" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory">
<bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="transportType">
<util:constant static-field="com.ibm.mq.jms.JMSC.MQJMS_CLIENT_NONJMS_MQ"/>
</property>
<property name="queueManager" value="MW01"/>
<property name="hostName" value="xxx.xxx.xxx.xxx"/>
<property name="port" value="1414"/>
</bean>
</property>
</bean>
<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring">
<route>
<from uri="activemq:my.queue.in"/>
<to uri="ibmmq:queue:my.queue.out"/>
</route>
</camelContext>
<bean id="activemq" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory">
<bean class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://127.0.0.1:61616" />
</bean>
</property>
</bean> |
We now want to set a few properties on our messages such as JMSReplyTo, JMS_IBM_Format, JMS_IBM_MsgType.
Is it possible to set these in spring? In what ways can we solve this?
Thanks in advance!
/JavaRat |
|
|
Back to top |
|
 |
JavaRat |
Posted: Thu Sep 25, 2008 6:06 am Post subject: |
|
|
Newbie
Joined: 23 Jun 2008 Posts: 8
|
Thank you kindly for your suggestions atheek and JLRowe!
If we find a solution to this I will surely post it here.
targetclient=1 has previously been set through use of the URI but unfortunately we can not do this with ApacheCamel since it does not accept/recognize it as a valid parameter. This might be the key here if it is possible to set it in some other way.
Next step will be to dig deeper into the Spring configuration which we so far have failed to find a solution for. There may be a way here to set it?!
/JavaRat |
|
Back to top |
|
 |
atheek |
Posted: Thu Sep 25, 2008 5:30 pm Post subject: |
|
|
 Partisan
Joined: 01 Jun 2006 Posts: 327 Location: Sydney
|
If you manage to set TARGCLIENT to 1, you may end up in removing the RF Headers, but still you may not be able to set the MQMD headers. Your current configuration sets these in RF headers and not in MQMD, so when you remove rf headers you may remove these properties also..you may require to find ways for setting the mqmd headers |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Sep 25, 2008 6:19 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
javarat wrote: |
We now want to set a few properties on our messages such as JMSReplyTo, JMS_IBM_Format, JMS_IBM_MsgType.
Is it possible to set these in spring? In what ways can we solve this? |
Now this has me somewhat stumped. Color me stupid but I thought that those properties were mostly being set by JMS for you. You need do nothing.
Unless javarat wants to set something different from the standard? And then why use JMS ???  _________________ MQ & Broker admin |
|
Back to top |
|
 |
JLRowe |
Posted: Mon Sep 29, 2008 1:17 am Post subject: |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
I think he wants the code to be non-JMS provider specific, and get all the contact admin JMS provider specific stuff into the spring configuration.
And he may need to set MQ JMS properties because he wants to interact with a non-jms service on the other end of the queue, but still wants to code to the JMS standard.
I recently had a similar situation where I was using WMQ in production, but using the in-memory activeMQ JMS provider for automated unit testing. All the JMS configuration was abstracted away into the spring configuration. |
|
Back to top |
|
 |
fjb_saper |
Posted: Mon Sep 29, 2008 10:24 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
JLRowe wrote: |
I think he wants the code to be non-JMS provider specific, and get all the contact admin JMS provider specific stuff into the spring configuration.
And he may need to set MQ JMS properties because he wants to interact with a non-jms service on the other end of the queue, but still wants to code to the JMS standard.
I recently had a similar situation where I was using WMQ in production, but using the in-memory activeMQ JMS provider for automated unit testing. All the JMS configuration was abstracted away into the spring configuration. |
My point was that you should not have to set the fields he described. JMS will set them behind the scenes for you. The standard works well. Unless he is trying to do something weird with the content of those fields, some combination of values that you would not expect, I see no reason for trying to meddle with this.
To be more specific:
- JMSReplyTo this should be set on the JMS message, I am sure Spring has a way of doing that, so use the standard.
- JMS_IBM_Format: DO NOT SET this field. It gets set depending on the message type you chose: BytesMessage, TextMessage etc...
- JMS_IBM_MsgType: DO NOT SET this field. It gets set behind the scenes. The default is a datagram. However when a JMSReplyTo Destination has been defined it gets changed to request. You have nothing to do.
 _________________ MQ & Broker admin |
|
Back to top |
|
 |
JLRowe |
Posted: Tue Sep 30, 2008 5:49 am Post subject: |
|
|
 Yatiri
Joined: 25 May 2002 Posts: 664 Location: South East London
|
sorry fjb_saper I got the wrong end of the stick, yes he should not need to mess with those fields |
|
Back to top |
|
 |
JavaRat |
Posted: Sun Oct 05, 2008 10:57 pm Post subject: |
|
|
Newbie
Joined: 23 Jun 2008 Posts: 8
|
I am completely dead wrong here in the first place. Even though I completely missunderstood pretty much everything you still managed too grasp my ignorance and came up with a solution too my problem!
Nice work guys!
So the next step here is actually too let the IBM MQ Queue know that the message I intend to put is a JMS-message?!
This is done with the call setTargetClient=1 (as atheek points out)
After some research I found that targetClient may be set using the class com.ibm.mq.jms.MQDestination and com.ibm.mq.jms.MQQueue. Not quite sure which one to use here to be frank.
In spring this will look something like:
<bean id="myBeanName" class=" com.ibm.mq.jms.MQDestination">
<property name="targetClient" value="1"/>
</bean>
How to make this work in spring is not a question for this forum. Still it might be useful too others to learn what I have found so far so I will leave some newbie springattempts here.
There is one mqseries-post close to what we are trying to achieve which might be of help:
http://www.mqseries.net/phpBB2/viewtopic.php?p=226204#226204
(close to the solution?)
I have not got this working yet (as there is no defaultDestination or other destination to use in the org.apache.camel.component.jms.JmsComponent case see http://activemq.apache.org/camel/maven/camel-jms/apidocs/org/apache/camel/component/jms/class-use/JmsComponent.html ) however the solution should look something like this:
Code: |
<bean id="ibmmq" class="org.apache.camel.component.jms.JmsComponent">
<property name="connectionFactory">
<bean class="com.ibm.mq.jms.MQQueueConnectionFactory">
<property name="transportType">
<util:constant static-field="com.ibm.mq.jms.JMSC.MQJMS_CLIENT_NONJMS_MQ"/>
</property>
<property name="queueManager" value="QMgr"/>
<property name="hostName" value="xxx.xxx.xxx.xxx"/>
<property name="port" value="1414"/>
</bean>
</property>
<property name="queue" ref="ibmqueueprop" />
</bean>
<bean id="ibmqueueprop" class=" com.ibm.mq.jms.MQDestination">
<property name="targetClient" value="1"/>
</bean> |
What I think you are trying to tell me in the above posts is to skip out? the bean <bean id="ibmmq" class="org.apache.camel.component.jms.JmsComponent> ? in favor of
org.springframework.jms.core.JmsTemplate?
I will update this post if I find the answear. Thanks again !
 |
|
Back to top |
|
 |
|