Unable to set JMS_IBM_MQMD_ApplIdentityData using camel

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Unable to set JMS_IBM_MQMD_ApplIdentityData using camel

santhoshks
We are trying to read the JMS_IBM_MQMD_ApplIdentityData message property and set it on the response message. We are using IBM MQ. The code I have implemented is not reading or writing this property on IBM MQ. Application runs on tomcat. Our MQ connection information is in the context.xml. Here is the code we are trying to write the property on the way out.

from("direct:toIBMMQ")
               
                .setExchangePattern(ExchangePattern.InOnly)
                .process(new Processor() {
                   
                    @Override
                    public void process(Exchange exchange) throws Exception {
                        exchange.getOut().setHeader("JMS_IBM_MQMD_ApplIdentityData","MyApplIdentityData");    
                       
                    }
                })
                .to("myJms:queue:myQueue?maxConcurrentConsumers=30&testConnectionOnStartup=true&transacted=false");

We are using org.apache.camel.component.jms.JmsComponent. spring config
<bean id="myJms" class="org.apache.camel.component.jms.JmsComponent">
                <property name="connectionFactory" ref="bxCredentialsConnectionFactory" />
               
        </bean>
Reply | Threaded
Open this post in threaded view
|

Re: Unable to set JMS_IBM_MQMD_ApplIdentityData using camel

Zoran Regvart-2
Hi Santhosh,
in your Processor set the header on the In message, but also, if
you're not doing anything else in the Processor but setting the header
value to a constant value, you can use the setHeader method of the
Java DSL.

From the IBMMQ side, make sure that you've understand the
prerequisites for setting ApplIdentityData[1]

zoran

[1] https://www.ibm.com/support/knowledgecenter/SSFKSJ_9.0.0/com.ibm.mq.dev.doc/q032350_.htm

On Fri, Feb 10, 2017 at 10:19 PM, santhoshks <[hidden email]> wrote:

> We are trying to read the JMS_IBM_MQMD_ApplIdentityData message property and
> set it on the response message. We are using IBM MQ. The code I have
> implemented is not reading or writing this property on IBM MQ. Application
> runs on tomcat. Our MQ connection information is in the context.xml. Here is
> the code we are trying to write the property on the way out.
>
> from("direct:toIBMMQ")
>                 .bean(WorkFlowLogger.class,
>                         "logInfo('"
>                                 + className
>                                 +
> "|ROUTE=toBXQueuePitchTransaction;STATE=OPERATION_BEGIN')")
>                 .setExchangePattern(ExchangePattern.InOnly)
>                 .process(new Processor() {
>
>                     @Override
>                     public void process(Exchange exchange) throws Exception
> {
>
> exchange.getOut().setHeader("JMS_IBM_MQMD_ApplIdentityData","MyApplIdentityData");
>
>                     }
>                 })
>
> .to("myJms:queue:myQueue?maxConcurrentConsumers=30&testConnectionOnStartup=true&transacted=false");
>
> We are using org.apache.camel.component.jms.JmsComponent. spring config
> <bean id="myJms" class="org.apache.camel.component.jms.JmsComponent">
>                 <property name="connectionFactory" ref="bxCredentialsConnectionFactory" />
>
>         </bean>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Unable-to-set-JMS-IBM-MQMD-ApplIdentityData-using-camel-tp5793780.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Zoran Regvart
Reply | Threaded
Open this post in threaded view
|

Re: Unable to set JMS_IBM_MQMD_ApplIdentityData using camel

santhoshks
Thank you Zoran...

This is only the sample code which tries to publish message to IBM MQ and sets the header. Actual application has much more in it.

As per IBM specification, we need to do following but I am not sure how to set MQMD properties in Camel.

// Enable MQMD write
  dest.setBooleanProperty(WMQConstants.WMQ_MQMD_WRITE_ENABLED, true);
 
  // Optionally, set a message context if applicable for this MD field
  dest.setIntProperty(WMQConstants.WMQ_MQMD_MESSAGE_CONTEXT,
    WMQConstants.WMQ_MDCTX_SET_IDENTITY_CONTEXT);

  // On the message, set property to provide custom appIdentityData
  jmsMessage.setStringProperty("JMS_IBM_MQMD_ApplIdentityData",
    "MyApplIdentityData");
Reply | Threaded
Open this post in threaded view
|

Re: Unable to set JMS_IBM_MQMD_ApplIdentityData using camel

Zoran Regvart-2
Hi Santhosh,
the JMS component lets you set `javax.jms.Destination` via the
`destination` property on the endpoint; or you can use
`destinationResolver` property on the endpoint or `JMSDestination`
header value and implement
`org.springframework.jms.support.destination.DestinationResolver`
interface in which you would create the Destination and set the needed
properties on it.

I don't believe, and the docs state this as well[1], that you can set
destination properties via `CamelJmsDestinationName` header so I think
that for your use case it would be best to go down the
DestinationResolver route (check the docs for example).

As I stated in the previous message, make sure that you set the
headers on exchange.in message -- nice way of reasoning about it is
that that is the _input_ to the JMS component, and check if any of the
rules mentioned in the component documentation[2] might affect the
value of your JMS property.

You might also want to check if you've set a custom
`headerFilterStrategy` on the endpoint, that might filter out the
headers.

zoran

[1] http://camel.apache.org/jms.html#JMS-SettingJMSProviderOptionsontheDestination
[2] http://camel.apache.org/jms.html#JMS-MessageFormatWhenSending

On Fri, Feb 10, 2017 at 10:50 PM, santhoshks <[hidden email]> wrote:

> Thank you Zoran...
>
> This is only the sample code which tries to publish message to IBM MQ and
> sets the header. Actual application has much more in it.
>
> As per IBM specification, we need to do following but I am not sure how to
> set MQMD properties in Camel.
>
> // Enable MQMD write
>   dest.setBooleanProperty(WMQConstants.WMQ_MQMD_WRITE_ENABLED, true);
>
>   // Optionally, set a message context if applicable for this MD field
>   dest.setIntProperty(WMQConstants.WMQ_MQMD_MESSAGE_CONTEXT,
>     WMQConstants.WMQ_MDCTX_SET_IDENTITY_CONTEXT);
>
>   // On the message, set property to provide custom appIdentityData
>   jmsMessage.setStringProperty("JMS_IBM_MQMD_ApplIdentityData",
>     "MyApplIdentityData");
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Unable-to-set-JMS-IBM-MQMD-ApplIdentityData-using-camel-tp5793781p5793783.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Zoran Regvart
Reply | Threaded
Open this post in threaded view
|

Re: Unable to set JMS_IBM_MQMD_ApplIdentityData using camel

santhoshks
Hi Zoran,

  Using the destinationResolver may be my option. The example in the link gives on how to create the destinationResolver. Will you be able to guide me on how will I use that in route. Will I be putting that in process or will it be a separate bean and call that bean in the route? I am new to camel :)
If there is any example with some implementation to read or write to the IBM queue that helps me.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to set JMS_IBM_MQMD_ApplIdentityData using camel

Zoran Regvart-2
Hi Santhosh,
There should not be great difference between the code example in the
documentation and the code you need.

In your first message you have `myJms`, that would be your
JmsComponent, so look in your code where you have defined the `myJms`
component, and there you just need to set the DestinationResolver,
which is as easy as calling `setDestinationResolver` on the component
instance.

I would suggest that you perhaps look into obtaining one of the great
Camel books out there, for example Camel in Action has a chapter on
JMS component, and I'm sure Claus wont mind me plugging it :)

zoran

On Tue, Feb 14, 2017 at 5:53 PM, santhoshks <[hidden email]> wrote:

> Hi Zoran,
>
>   Using the destinationResolver may be my option. The example in the link
> gives on how to create the destinationResolver. Will you be able to guide me
> on how will I use that in route. Will I be putting that in process or will
> it be a separate bean and call that bean in the route? I am new to camel :)
> If there is any example with some implementation to read or write to the IBM
> queue that helps me.
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Unable-to-set-JMS-IBM-MQMD-ApplIdentityData-using-camel-tp5793781p5793885.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



--
Zoran Regvart
Reply | Threaded
Open this post in threaded view
|

Re: Unable to set JMS_IBM_MQMD_ApplIdentityData using camel

santhoshks
Thank you Zoran.. using the destinationResolver did work for me.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to set JMS_IBM_MQMD_ApplIdentityData using camel

ravi21588
Hi Santhosh,
Can you please let me know how did you use destination resolver with Apache camel.
Iam using Jboss fuse service works 6.0,in which iam using switchyard as service delivery framework and camel as implementation.
Reply | Threaded
Open this post in threaded view
|

RE: [EXTERNAL] Re: Unable to set JMS_IBM_MQMD_ApplIdentityData using camel

Vanshul.Chawla
Use this code

import org.springframework.jms.support.destination.DestinationResolver
import org.springframework.stereotype.Component

import javax.jms.Destination
import javax.jms.JMSException
import javax.jms.Session

@Component
class JmsDestinationResolver implements DestinationResolver {

    @Override
    Destination resolveDestinationName(Session session, String destinationName, boolean pubSubDomain) throws JMSException {
         session.createQueue("queue:///" + destinationName + "?targetClient=1")
    }
}


And set destination resolver wherever you create jms component

@Bean
    JmsComponent queueManager1(){

        JmsComponentBuilder jmsComponentBuilder = new JmsComponentBuilder(channel: wmqProperties.channel1,hostName: wmqProperties.hostName1, port: wmqProperties.port1,
                transportType: wmqProperties.transportType, username: wmqProperties.username, password: wmqProperties.password, logStatus: wmqProperties.logStatus, queueManager: wmqProperties.queueManager1)
        JmsComponent jmsComponent = jmsComponentBuilder.build()
        jmsComponent.setDestinationResolver(jmsDestinationResolver)
        jmsComponent
    }

-----Original Message-----
From: ravi21588 [mailto:[hidden email]]
Sent: Monday, March 13, 2017 9:44 AM
To: [hidden email]
Subject: [EXTERNAL] Re: Unable to set JMS_IBM_MQMD_ApplIdentityData using camel

Hi Santhosh,
Can you please let me know how did you use destination resolver with Apache camel.
Iam using Jboss fuse service works 6.0,in which iam using switchyard as service delivery framework and camel as implementation.



--
View this message in context: http://camel.465427.n5.nabble.com/Unable-to-set-JMS-IBM-MQMD-ApplIdentityData-using-camel-tp5793781p5795366.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

RE: [EXTERNAL] Re: Unable to set JMS_IBM_MQMD_ApplIdentityData using camel

ravi21588
Hi Vanshul,
Thanks for the reply.
Iam using Jboss eap 6.1 and i have configured the connection factory and MQ adapter as mentioned in below.I have setup SSL configuration etc.

https://access.redhat.com/documentation/en-US/JBoss_Enterprise_Application_Platform/6/html/Administration_and_Configuration_Guide/Deploy_the_WebSphere_MQ_Resource_Adapter.html

and iam using  switchyard jms component
https://docs.jboss.org/author/display/SWITCHYARD/JMS which is build upon camel JMS.

I would like to the feasibility of enhancing the existing code to use destination resolver.

in advance options in camel there is a possibility to set destinationResolver.

Do you know how to use it?