Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id DB1B3200B90 for ; Sun, 25 Sep 2016 21:39:06 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id D98A2160ACE; Sun, 25 Sep 2016 19:39:06 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 00A2F160ABE for ; Sun, 25 Sep 2016 21:39:05 +0200 (CEST) Received: (qmail 2697 invoked by uid 500); 25 Sep 2016 19:39:05 -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 2685 invoked by uid 99); 25 Sep 2016 19:39:04 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 25 Sep 2016 19:39:04 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id EE3621A0681 for ; Sun, 25 Sep 2016 19:39:03 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 3.294 X-Spam-Level: *** X-Spam-Status: No, score=3.294 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, URI_HEX=1.313, WEIRD_PORT=0.001] autolearn=disabled Authentication-Results: spamd2-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=mediadriver-com.20150623.gappssmtp.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id OY0l_FnOuVoO for ; Sun, 25 Sep 2016 19:39:01 +0000 (UTC) Received: from mail-qk0-f199.google.com (mail-qk0-f199.google.com [209.85.220.199]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id 6F6AC60D1F for ; Sun, 25 Sep 2016 19:39:00 +0000 (UTC) Received: by mail-qk0-f199.google.com with SMTP id m184so161148857qkb.1 for ; Sun, 25 Sep 2016 12:39:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mediadriver-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=dY90ZUh0b0VVTjor9XD+yglWqHXuS0ClO+8VPU1sfdI=; b=wm6yFMajziJCE6PQDF++rxkJPadUDljVyOyzUdN3Q74yKmuAvjdAEdO02JBEy6niAP 56XEP/GQJndjzVBYJsBdqA4CIVEIGZ8Q2mWICGRQTU4TwpWT/lOqsCt88xtbIFnBAp5u NjSNTPwIdVLetJDzDT9F7dhjrL3iJugw4DyAphFYRF4HvzD5ppWKSBZ0oI6FJFyPzLuY BXzANLsYJNJxr+GwREJjS0qGCqiU+BQwHAY12tNTgT08RT3CmzoM9IT/G+qJnzc1vDFl WrOPqlAwMFruo3pwzKKJvfZNoe4mjcWPFQWQUEAYmeibxLkyBbRu8ygVPg2gjrk6stZh n4AA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=dY90ZUh0b0VVTjor9XD+yglWqHXuS0ClO+8VPU1sfdI=; b=Hc6RJOvG9JD1FBZFVN5vMR1U6shT+ENbWcAsPmj3Hew6ysokUs5mXCxrhJbfkdrrI0 P7zle7HIFm2jnmn6nMHiP9Qq0ayHVUw1ngtJqvFEhKjgFKPdi2RiGGemNLWqHfSV60F0 Q8YnNVa/CDdOK49ndmGlu2Xll+nBw54Cpc1YutYDcFEBX0OD4hsblq1VAQJFWVjD8+97 /Mfd9rIm+bXJi776tk/uQ0Fkd6qhXEPrU23HlQroy4cJAf6369B5SYj3J5PcZq32mbcE XUQpIKVOp3v2B9J78wHS/3SCH3oOK21vl4oCfBxOKSn54l38O4f1jgiZGFgoASr/NHx4 0c6g== X-Gm-Message-State: AA6/9RmwUPylNbBZ6/KJKye5zkXhzzf5MY8y6qe4FtqSwTrhfRSLfgClFufTajIp1YaYIMZoF4H5+X9wiH84/rh0 X-Received: by 10.237.56.36 with SMTP id j33mr17731755qte.16.1474832332592; Sun, 25 Sep 2016 12:38:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.55.110.2 with HTTP; Sun, 25 Sep 2016 12:38:52 -0700 (PDT) In-Reply-To: References: <1474634960364-5787961.post@n5.nabble.com> <1474638514257-5787966.post@n5.nabble.com> <1474654983335-5787977.post@n5.nabble.com> <1474664319194-5787980.post@n5.nabble.com> <1474698648482-5787986.post@n5.nabble.com> <1474741610781-5787994.post@n5.nabble.com> From: Brad Johnson Date: Sun, 25 Sep 2016 14:38:52 -0500 Message-ID: Subject: Re: Can't understand what inOnly is doing To: users@camel.apache.org Content-Type: multipart/alternative; boundary=001a1141d4c249b453053d5a2962 archived-at: Sun, 25 Sep 2016 19:39:07 -0000 --001a1141d4c249b453053d5a2962 Content-Type: text/plain; charset=UTF-8 The direct is going to return a message regardless of what the upstream components say because at that point you are indicating that you *do *want that route to return something to you. Much like a method with a void return calling a second method that returns a String. Just because the calling method isn't returning anything it doesn't indicate that the second method in the sequence won't return something. Since direct is going to do the request/reply before the rest of your first route finishes why would you expect it to operate differently? InOnly there does not take priority over the call to direct. In the case you show why wouldn't you just say to(direct:BBB) instead. It is amounting to the same thing because because direct: is a request/response and that call is going to happen regardless of what the calling route indicates. I'm not even sure what an InOnly to a direct endpoint means quite frankly as you are telling Camel two different things. The InOnly indicates a fire and forget and the direct indicates a request/response. Switch that around, what would an .InOut("seda:BBB") indicate? It's possible that Camel would return something to you InOut but that's a bit of a head scratcher since your making a request/response call to a fire and forget endpoint. I guess I should have phrased it differently as Matt did and as the Camel documents in the links indicate. But if you are doing InOnly then I've found little point in using a direct or any synchronous component. Perhaps there is one I just don't think about it that way. In fact, I don't recall ever using InOnly or InOut explicitly since most endpoints are one or the other. So endpoints that are InOnly like SEDA are by their nature running asynchronously from the calling route. What I have done many times is something like receiving a list of records or POJOs on an incoming synchronous web service call, spin through the elements validating them, and then drop them onto an asynchronous processing endpoint like the SEDA queue, and when done spinning through the records return an OK or some other acknowledgement message. But I'm not waiting for or expecting anything back from the SEDA queue. But I really can't think of a need or reason why I'd set InOnly/InOut explicitly. The best definition I guess is as the camel docs in the link I sent calling them request/reply and event message. On Sun, Sep 25, 2016 at 10:25 AM, Matt Sicker wrote: > The direct component is synchronous (it's implemented by simply executing > the next Processor in the route). If you want to do it asynchronously, you > can use the seda component which uses a BlockingQueue and a thread pool or > one of the non-core components like disruptor, activemq, amqp, etc. > > The InOnly pattern is more of a one-way communication than it is > asynchronous. > > On 24 September 2016 at 13:26, sim085 wrote: > > > If InOnly works asynchronous then why does it wait for "direct:BBB" to > > finish > > before the next step is executed? > > For example take the following code: > > > > [code] > > from("jetty:http://localhost:8282/") > > .log("Hello From A") > > .inOnly("direct:BBB") // asynchronous? > > .log("Goodbye From A"); > > > > from("direct:BBB") > > .log("Hello From B") > > .delay(5000) > > .log("Goodbye From B"); > > [/code] > > > > If the [.inOnly("direct:BBB")] was asynchronous then the console should > > print "GoodBye From A" before "Goodbye from B" because of the > > [.delay(5000)] > > in route "direct:BBB". However what happens is that the console prints > > "Hello From A", "Hello From B", (waits 5 seconds), "Good Bye From B", > > "Goodbye From A". (screenshot1 attached). > > > > However beside this there is the fact that the message is not being > thrown > > away even though I am using the "inOnly" exchange patter. Take the > > following: > > > > [code] > > from("jetty:http://localhost:8282/") > > .transform(constant("AAA")) // Change body of OUT > > Message. > > .inOnly("direct:BBB") // Calling route > > direct:BBB using inOnly MEP. > > .log("I was waiting 'AAA' and got '${in.body}'"); > > > > from("direct:BBB") > > .transform(constant("BBB")); // Change body of OUT > > Message. > > // But this should be "thrown away" as MEP is > > inOnly. > > [/code] > > > > The above code prints in the logs "I was waiting 'AAA' and got 'BBB'" > > (screenshot2 attached). However based on "If it is an InOnly then if > > there's > > a message at the end it is thrown away." shouldn't I have got "I was > > waiting > > 'AAA' and got 'AAA'"? Shouldn't the message at the end of route > > "direct:BBB" > > have been thrown away? > > > > Screenshot1: > > > > > > Screenshot2: > > > > > > > > Ranx wrote > > > InOnly is a fire-and-forget, asynchronous style of messaging. InOut > is a > > > synchronous or pseudo-synchronous* request-reply messaging as Matt > points > > > out. > > > > > > Part of the confusion is about the pattern set on the exchange to > > indicate > > > whether the data flow is InOut or InOnly. The other In/Out on the > > > Exchange > > > is about the data coming in and going out and is pretty much invariant > in > > > its existence and data structure. Unfortunately even that's a bit > > > misleading terminology as the data is always on the in except when an > In > > > data on the Exchange follows the route all the way "In" to the last > > > endpoint and then if it is an InOut route the Out is what is returned. > If > > > it is an InOnly then if there's a message at the end it is thrown away. > > > > > > InOut/InOnly are message flow patterns to set on the exchange. In/Out > are > > > the data elements associated with the exchange at any given moment in > the > > > route. > > > > > > *When I say pseudo-synchronous it is because Jetty continuations do not > > > hold the calling thread but make callbacks. JMS InOut/request-reply > > > actually set up two queues under the covers, one to send the request > and > > > one to send the reply. I'd have to check again on whether the calling > > > thread waits or if a callback mechanism is deployed. Obviously the > > latter > > > is preferable in terms of threading and performance. > > > > > > http://camel.apache.org/request-reply.html > > > http://camel.apache.org/event-message.html > > > > > > Brad > > > > > > > > > > > > -- > > View this message in context: http://camel.465427.n5.nabble. > > com/Can-t-understand-what-inOnly-is-doing-tp5787961p5787994.html > > Sent from the Camel - Users mailing list archive at Nabble.com. > > > > > > -- > Matt Sicker > --001a1141d4c249b453053d5a2962--