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 628E16DE1 for ; Wed, 1 Jun 2011 05:04:58 +0000 (UTC) Received: (qmail 97932 invoked by uid 500); 1 Jun 2011 05:04:57 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 97912 invoked by uid 500); 1 Jun 2011 05:04:55 -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 97904 invoked by uid 99); 1 Jun 2011 05:04:53 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jun 2011 05:04:53 +0000 X-ASF-Spam-Status: No, hits=-2.3 required=5.0 tests=RCVD_IN_DNSWL_MED,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jnewsham@referentia.com designates 64.18.3.95 as permitted sender) Received: from [64.18.3.95] (HELO exprod8ob108.obsmtp.com) (64.18.3.95) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 01 Jun 2011 05:04:43 +0000 Received: from mail-pz0-f48.google.com ([209.85.210.48]) (using TLSv1) by exprod8ob108.postini.com ([64.18.7.12]) with SMTP ID DSNKTeXIVBNYZ27ocZv+og2GBnKXHZaGe4Rv@postini.com; Tue, 31 May 2011 22:04:22 PDT Received: by pzk10 with SMTP id 10so3122287pzk.21 for ; Tue, 31 May 2011 22:04:20 -0700 (PDT) Received: by 10.68.39.72 with SMTP id n8mr3085201pbk.93.1306904659547; Tue, 31 May 2011 22:04:19 -0700 (PDT) Received: from [172.16.67.78] ([72.235.184.194]) by mx.google.com with ESMTPS id w2sm703249pbg.37.2011.05.31.22.04.18 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 31 May 2011 22:04:19 -0700 (PDT) Message-ID: <4DE5C851.1040302@referentia.com> Date: Tue, 31 May 2011 19:04:17 -1000 From: Jim Newsham User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.17) Gecko/20110414 Lightning/1.0b2 Thunderbird/3.1.10 MIME-Version: 1.0 To: users@camel.apache.org Subject: async send with preserved order Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Is it possible to send asynchronously while preserving order? For example: for (int i = 0; i <= COUNT; i++) { Object body = Integer.valueOf(i); producerTemplate.asyncCallbackRequestBody(URL, body, callback); } Assuming that "URL" is a FIFO queue, is there some way for the recipient to receive the messages in the order that the sender has sent them? I think the answer is no, since async calls just schedule a task on an executor, and it's possible for the thread scheduler to choose/process send tasks out of order. [*] If that's correct, then *if order is important*, all sends must be synchronous, and performance will suffer (transmission will be in serial instead of in parallel, and any network latency will make matters worse since InOut requires round-trip communication). For this case, it really would be useful to be able to async send and guarantee transmission order (for JMS or whatever endpoint being used). [*] One could set a single-threaded executor on the producer template. The call would be asynchronous and transmission in order, however the actual send operations would still be in serial (each InOut message must be completely processed before the next message is sent), so the performance would still suffer. Comments? Jim