You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by "Nagulapalli, Srinivas" <Sr...@wabtec.com> on 2020/11/03 02:53:31 UTC

Help: How to set DestinationResolver (that in turn sets targetClient) in Java DSL

Hi,

Request help for setting JMS provider options on the Destination.

I am trying to follow the workaround mentioned at : https://camel.apache.org/components/latest/jms-component.html
under section: “SETTING JMS PROVIDER OPTIONS ON THE DESTINATION”<
to specify “targetClient=1” using Custom Destination Resolver.

Here are my two steps:
Step 1: Implemented custom DestinationResolver called “MQDestinationResolver.java” like below:
================================
public class MQDestinationResolver implements DestinationResolver
{
    @Override
    public Destination resolveDestinationName( final Session session, final String destinationName,final boolean pubSubDomain) throws JMSException
    {
        if (!( session instanceof MQQueueSession )) {
            final String errorMessage = "Error: session NOT an instance of MQQueueSession!";
            log.error(errorMessage);
            throw new IllegalStateException(errorMessage);
        }
        final MQQueueSession wmqSession = (MQQueueSession) session;
        if (pubSubDomain){
            return wmqSession.createTopic("topic:///" + destinationName + "?targetClient=1");
        } else  {
            return wmqSession.createQueue("queue:///" + destinationName + "?targetClient=1");
        }
    }
}
Step 2: In my custom RouteBuilder called MyRouteBuilder.java below,
attempting to use the custom DestinationResolver created in Step1, like below, but does NOT work. Please tell how!

public class MyRouteBuilder extends RouteBuilder
{
    @Override
    public void configure()
    {
        final String mqOutgoingQueueURI = MisUtil.getMQURIFromQueueName(mqInfo.getOutputQueueName())
                + "?destinationResolver=mqDestinationResolver";

from(“jms:queue:MY_JMS_SOURCE_QUEUE?destinationResolver=MQDestinationResolver”) //•-----  This does NOT work!
            .to("wq-jms:queue:///MY.MQ.TARGET_QUEUE_NAME”);//
}
}
======

I do not know how to specify Camel to use MQDestinationResolver in DSL.
Any help is greatly appreciated.

Thanks
Srini
This email and any attachments are only for use by the intended recipient(s) and may contain legally privileged, confidential, proprietary or otherwise private information. Any unauthorized use, reproduction, dissemination, distribution or other disclosure of the contents of this e-mail or its attachments is strictly prohibited. If you have received this email in error, please notify the sender immediately and delete the original. Neither this information block, the typed name of the sender, nor anything else in this message is intended to constitute an electronic signature unless a specific statement to the contrary is included in this message.

Re: Help: How to set DestinationResolver (that in turn sets targetClient) in Java DSL

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

Use # syntax in URIs to refer to a bean by its id
https://camel.apache.org/manual/latest/faq/how-do-i-configure-endpoints.html

You can also configure the destination resolver directory on the JMS
component (wq-jms) instead of each endpoint
https://camel.apache.org/components/latest/jms-component.html

On Tue, Nov 3, 2020 at 3:53 AM Nagulapalli, Srinivas
<Sr...@wabtec.com> wrote:
>
> Hi,
>
> Request help for setting JMS provider options on the Destination.
>
> I am trying to follow the workaround mentioned at : https://camel.apache.org/components/latest/jms-component.html
> under section: “SETTING JMS PROVIDER OPTIONS ON THE DESTINATION”<
> to specify “targetClient=1” using Custom Destination Resolver.
>
> Here are my two steps:
> Step 1: Implemented custom DestinationResolver called “MQDestinationResolver.java” like below:
> ================================
> public class MQDestinationResolver implements DestinationResolver
> {
>     @Override
>     public Destination resolveDestinationName( final Session session, final String destinationName,final boolean pubSubDomain) throws JMSException
>     {
>         if (!( session instanceof MQQueueSession )) {
>             final String errorMessage = "Error: session NOT an instance of MQQueueSession!";
>             log.error(errorMessage);
>             throw new IllegalStateException(errorMessage);
>         }
>         final MQQueueSession wmqSession = (MQQueueSession) session;
>         if (pubSubDomain){
>             return wmqSession.createTopic("topic:///" + destinationName + "?targetClient=1");
>         } else  {
>             return wmqSession.createQueue("queue:///" + destinationName + "?targetClient=1");
>         }
>     }
> }
> Step 2: In my custom RouteBuilder called MyRouteBuilder.java below,
> attempting to use the custom DestinationResolver created in Step1, like below, but does NOT work. Please tell how!
>
> public class MyRouteBuilder extends RouteBuilder
> {
>     @Override
>     public void configure()
>     {
>         final String mqOutgoingQueueURI = MisUtil.getMQURIFromQueueName(mqInfo.getOutputQueueName())
>                 + "?destinationResolver=mqDestinationResolver";
>
> from(“jms:queue:MY_JMS_SOURCE_QUEUE?destinationResolver=MQDestinationResolver”) //•-----  This does NOT work!
>             .to("wq-jms:queue:///MY.MQ.TARGET_QUEUE_NAME”);//
> }
> }
> ======
>
> I do not know how to specify Camel to use MQDestinationResolver in DSL.
> Any help is greatly appreciated.
>
> Thanks
> Srini
> This email and any attachments are only for use by the intended recipient(s) and may contain legally privileged, confidential, proprietary or otherwise private information. Any unauthorized use, reproduction, dissemination, distribution or other disclosure of the contents of this e-mail or its attachments is strictly prohibited. If you have received this email in error, please notify the sender immediately and delete the original. Neither this information block, the typed name of the sender, nor anything else in this message is intended to constitute an electronic signature unless a specific statement to the contrary is included in this message.



-- 
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2