Return-Path: X-Original-To: apmail-camel-users-archive@www.apache.org Delivered-To: apmail-camel-users-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 2A3667F70 for ; Mon, 15 Aug 2011 03:02:58 +0000 (UTC) Received: (qmail 78833 invoked by uid 500); 15 Aug 2011 03:02:57 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 78663 invoked by uid 500); 15 Aug 2011 03:02:54 -0000 Mailing-List: contact users-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@camel.apache.org Delivered-To: mailing list users@camel.apache.org Received: (qmail 78655 invoked by uid 99); 15 Aug 2011 03:02:53 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Aug 2011 03:02:53 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=FREEMAIL_FROM,HTML_MESSAGE,NORMAL_HTTP_TO_IP,RCVD_IN_DNSWL_LOW,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL,WEIRD_PORT X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of davidkarlsen@gmail.com designates 209.85.210.175 as permitted sender) Received: from [209.85.210.175] (HELO mail-iy0-f175.google.com) (209.85.210.175) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Aug 2011 03:02:49 +0000 Received: by mail-iy0-f175.google.com with SMTP id 15so7044530iyn.34 for ; Sun, 14 Aug 2011 20:02:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=GGYebbBfcRZa56GeZxZk0OtVOM82oZSAYxRRlfAXOL0=; b=NVD8eKjNxOXXplGi57wwah14rAk8YYg28PvMvcHF7ZAzC2LYHKy9WLnjLxvoRH/ksd VEj7k9mdnxJtK3sUseoSc7zYgeVhEqbuAc29R0iYRFcJgJrNbwCqQTi2Rd1xpWFt5+Ro zOduvnPyH22PGzeXnvRbWFgj67DvbW6Nhs3oU= MIME-Version: 1.0 Received: by 10.42.154.131 with SMTP id q3mr3377366icw.312.1313377349112; Sun, 14 Aug 2011 20:02:29 -0700 (PDT) Received: by 10.42.241.74 with HTTP; Sun, 14 Aug 2011 20:02:29 -0700 (PDT) In-Reply-To: References: <4E165B00.200@referentia.com> Date: Mon, 15 Aug 2011 05:02:29 +0200 Message-ID: Subject: Re: slow reply for jms component when url contains replyTo From: David Karlsen To: users@camel.apache.org Content-Type: multipart/alternative; boundary=90e6ba6e8bbe59929a04aa827ea2 --90e6ba6e8bbe59929a04aa827ea2 Content-Type: text/plain; charset=ISO-8859-1 Because each receiver listens for a distinct correclationid this is not a problem. 2011/8/14 Claus Ibsen > On Sat, Aug 13, 2011 at 8:06 PM, David Karlsen > wrote: > > Hi - I would be very interested in this (and willing to test). > > We had to back out from using camel for our req/res jms (we now use > > jmstemplate directly) - especially because the persistentrelyqueuemanager > > (or something like that) seemed to use the same connection - so > eventually > > the fw closed that connection during hours with little traffic. > > > > Another positive effect of switching to using jmstemplate directly is > that > > the same thread is handling the response and the request - and we have a > > thread scoped state object attached to it. > > > > We are running in a cluster - but because we use correlationid this is > not a > > problem as you say. > > > > btw since you run in a clustered environment. Do you use the same > persistent reply queues for all nodes in the cluster? > If so how is your strategy to ensure the reply messages get consumed > by the right node? > > > > The underlying MOM is WebSphere MQ. > > > > BTW: "vinning" in my rely was supposted to spell "common" - I blame my > phone > > for that ;-) > > > > 2011/8/13 Claus Ibsen > > > >> Hi Jim, others > >> > >> I got some code for supporting exclusive replyTo queues. I just want > >> to know if you run in a clustered environment. > >> As the replyTo queue would be exclusive to each CamelContext (eg each > >> node). So if you have 2 nodes running with Camel then each node would > >> have to use an unique replyTo queue. > >> > >> If you run in a single instance of CamelContext then there is of > >> course no problem. > >> > >> Alternative you can always use shared queues in a cluster, as each > >> CamelContext (each node) will only pickup intended reply message for > >> it (using a JMS selector), which is also the case why its slower. You > >> can tweak the performance with the receiveTimeout. That is default 1 > >> sec. If you set it lower, then it will potential react faster to new > >> replies coming back. > >> > >> > >> > >> On Fri, Jul 8, 2011 at 3:18 AM, Jim Newsham > >> wrote: > >> > > >> > I'm using Camel 2.7.1 on top of ActiveMQ 5.5.0. For some reason, when > I > >> > specify a custom replyTo destination on the endpoint url, the time it > >> takes > >> > for the producer to receive a reply increases drastically. The > curious > >> > thing is that the time to receive a reply is almost exactly 1 second. > >> When > >> > I remove the replyTo from the url, everything's fast again. > >> > > >> > I created a very simple, stand-alone test to demonstrate what I'm > seeing. > >> > There is a server class [4] which runs an embedded instance of > ActiveMQ > >> and > >> > simply replies to messages as they arrive; and a client [3] class > which > >> > simply sends messages to the server, and prints the elapsed time. The > >> > USE_REPLY_TO symbolic constant in the client determines whether a > replyTo > >> > value is added to the url or not. > >> > > >> > The client output when USE_REPLY_TO is false is shown as [1]. The > client > >> > output when USE_REPLY_TO is true is shown as [2]. The code is pretty > >> > trivial. Am I doing something wrong, or is this a Camel and/or > ActiveMQ > >> > issue? > >> > > >> > Thanks! > >> > Jim > >> > > >> > > >> > [1] USE_REPLY_TO = false > >> > > >> > received reply in: 0.476 s > >> > received reply in: 0.006 s > >> > received reply in: 0.006 s > >> > received reply in: 0.006 s > >> > received reply in: 0.006 s > >> > ... > >> > > >> > > >> > [2] USE_REPLY_TO = true > >> > > >> > received reply in: 1.524 s > >> > received reply in: 1.002 s > >> > received reply in: 1.003 s > >> > received reply in: 1.003 s > >> > received reply in: 1.002 s > >> > ... > >> > > >> > > >> > [3] TestReplyToClient.java > >> > > >> > package test; > >> > > >> > import org.apache.activemq.ActiveMQConnectionFactory; > >> > import org.apache.activemq.camel.component.ActiveMQComponent; > >> > import org.apache.camel.CamelContext; > >> > import org.apache.camel.ProducerTemplate; > >> > import org.apache.camel.impl.DefaultCamelContext; > >> > > >> > public class TestReplyToClient { > >> > > >> > private static final boolean USE_REPLY_TO = false; > >> > > >> > public static void main(String... args) throws Exception { > >> > // create camel context; configure activemq component for > >> > tcp://localhost:7001 > >> > CamelContext context = new DefaultCamelContext(); > >> > ActiveMQComponent activemqComponent = > >> > ActiveMQComponent.activeMQComponent(); > >> > activemqComponent.setConnectionFactory(new > ActiveMQConnectionFactory( > >> > null, null, "tcp://localhost:7001")); > >> > context.addComponent("activemq", activemqComponent); > >> > context.start(); > >> > > >> > // define url to send requests to > >> > String sendUrl = "activemq:queue:dest"; > >> > if (USE_REPLY_TO) { > >> > sendUrl += "?replyTo=replyQueue"; > >> > } > >> > System.err.println("sending to url: " + sendUrl); > >> > > >> > // repeatedly send requests; measure elapsed time > >> > ProducerTemplate template = context.createProducerTemplate(); > >> > while (true) { > >> > long startNanos = System.nanoTime(); > >> > template.requestBody(sendUrl, "abc"); > >> > long elapsedNanos = System.nanoTime() - startNanos; > >> > System.err.println(String.format("received reply in: %.3f s", > >> > elapsedNanos / 1000000000.0)); > >> > } > >> > } > >> > > >> > } > >> > > >> > > >> > [4] TestReplyToServer.java > >> > > >> > package test; > >> > > >> > import org.apache.activemq.broker.BrokerService; > >> > import org.apache.activemq.camel.component.ActiveMQComponent; > >> > import org.apache.camel.CamelContext; > >> > import org.apache.camel.Exchange; > >> > import org.apache.camel.Processor; > >> > import org.apache.camel.builder.RouteBuilder; > >> > import org.apache.camel.impl.DefaultCamelContext; > >> > > >> > public class TestReplyToServer { > >> > > >> > private static final String BROKER_NAME = "thebroker"; > >> > > >> > public static void main(String... args) throws Exception { > >> > startBroker(); > >> > startCamel(); > >> > Thread.sleep(Long.MAX_VALUE); > >> > } > >> > > >> > private static void startBroker() throws Exception { > >> > BrokerService brokerService = new BrokerService(); > >> > brokerService.setBrokerName(BROKER_NAME); > >> > brokerService.setSchedulerSupport(false); > >> > brokerService.setPersistent(false); > >> > brokerService.addConnector("tcp://0.0.0.0:7001"); > >> > brokerService.start(); > >> > brokerService.waitUntilStarted(); > >> > } > >> > > >> > > >> > private static void startCamel() throws Exception { > >> > CamelContext context = new DefaultCamelContext(); > >> > > >> > ActiveMQComponent activemqComponent = > >> > ActiveMQComponent.activeMQComponent(); > >> > > activemqComponent.setBrokerURL(String.format("vm://%s?create=false", > >> > BROKER_NAME)); > >> > context.addComponent("activemq", activemqComponent); > >> > > >> > final String receiveUrl = "activemq:queue:dest"; > >> > context.addRoutes(new RouteBuilder() { > >> > @Override > >> > public void configure() throws Exception { > >> > from(receiveUrl).process(new Processor() { > >> > @Override > >> > public void process(Exchange exchange) throws Exception { > >> > System.err.println("received request"); > >> > exchange.getOut().setBody("reply"); > >> > } > >> > }); > >> > } > >> > }); > >> > > >> > context.start(); > >> > System.err.println("listening on url: " + receiveUrl); > >> > } > >> > > >> > } > >> > > >> > > >> > > >> > > >> > > >> > >> > >> > >> -- > >> Claus Ibsen > >> ----------------- > >> FuseSource > >> Email: cibsen@fusesource.com > >> Web: http://fusesource.com > >> Twitter: davsclaus, fusenews > >> Blog: http://davsclaus.blogspot.com/ > >> Author of Camel in Action: http://www.manning.com/ibsen/ > >> > > > > > > > > -- > > -- > > David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen > > > > > > -- > Claus Ibsen > ----------------- > FuseSource > Email: cibsen@fusesource.com > Web: http://fusesource.com > Twitter: davsclaus, fusenews > Blog: http://davsclaus.blogspot.com/ > Author of Camel in Action: http://www.manning.com/ibsen/ > -- -- David J. M. Karlsen - http://www.linkedin.com/in/davidkarlsen --90e6ba6e8bbe59929a04aa827ea2--