Return-Path: Delivered-To: apmail-cxf-dev-archive@www.apache.org Received: (qmail 48081 invoked from network); 16 Apr 2010 13:48:45 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 16 Apr 2010 13:48:45 -0000 Received: (qmail 15749 invoked by uid 500); 16 Apr 2010 13:48:45 -0000 Delivered-To: apmail-cxf-dev-archive@cxf.apache.org Received: (qmail 15712 invoked by uid 500); 16 Apr 2010 13:48:45 -0000 Mailing-List: contact dev-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list dev@cxf.apache.org Received: (qmail 15704 invoked by uid 99); 16 Apr 2010 13:48:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Apr 2010 13:48:45 +0000 X-ASF-Spam-Status: No, hits=-0.8 required=10.0 tests=AWL,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of willem.jiang@gmail.com designates 209.85.219.211 as permitted sender) Received: from [209.85.219.211] (HELO mail-ew0-f211.google.com) (209.85.219.211) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 16 Apr 2010 13:48:37 +0000 Received: by ewy3 with SMTP id 3so571824ewy.6 for ; Fri, 16 Apr 2010 06:48:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from :user-agent:mime-version:to:subject:references:in-reply-to :content-type:content-transfer-encoding; bh=SAMW4zuBJ0txoJdZ6HaSIFSm/4Vh/SzsfI/6b+H7q58=; b=DiBtfWN5CJFCqpkDNNxELXl+IGXyYSCleUHPComqi9aVa1C6x9FrXm1HN0l2B6SKIx TC3rhOSziA3rtn5U1dN5Y8t0TJANJI1NiSnbim6/giJtHlKP8bdVMrvnl2JfQegDaPdc JbG1cEtBIbfRJ7p9n4m1ETqyo6fQY6OkjOROg= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding; b=dzlVBw1zhTONrFSlvKii2ImQVuFbUynACUFDYfjFLn35DXxLy/lr0kO/iTLeOZXO39 iwfiTvJolqtScVtVXzHSULMETqBsh/PHPheVASUSSivqb3sqkxeqTei7O8KreKI7lq0T nU1OHuDtlccNJAfdQLslz73YR7dh2vl+8EQeg= Received: by 10.213.55.71 with SMTP id t7mr363321ebg.93.1271425694887; Fri, 16 Apr 2010 06:48:14 -0700 (PDT) Received: from [192.168.0.158] ([125.34.9.180]) by mx.google.com with ESMTPS id 16sm1749197ewy.3.2010.04.16.06.48.11 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 16 Apr 2010 06:48:13 -0700 (PDT) Message-ID: <4BC86A96.2040108@gmail.com> Date: Fri, 16 Apr 2010 21:48:06 +0800 From: Willem Jiang User-Agent: Thunderbird 2.0.0.24 (Macintosh/20100228) MIME-Version: 1.0 To: dev@cxf.apache.org Subject: Re: Support for using JMS MessageID as CorrelationID References: ,<4BC7CA5B.3050905@gmail.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit If the JMSListener is the Spring DefaultMessageListenerContainer, I doubt you can change the listener's message selector at the runtime. So I suggest to create a receive task with jms message selector to receive the response, and use a thread pool to run these receive task. Willem Seumas Soltysik wrote: > Hi Willem, > One more thing. With respect to using a workqueue I don't think it really solves the issue. The JMSListener essentially already uses its own workqueue to listen asynchronously for replies. The real issue is to minimize the number of JMSListeners required to handle the asynch scenario. As opposed to having a listener per thread, it would be better to have a pool of listeners which could be allocated as individual threads make asych calls. A workqueue is not going to help with this issue. > Regards, > Seumas > ________________________________________ > From: Willem Jiang [willem.jiang@gmail.com] > Sent: Thursday, April 15, 2010 10:24 PM > To: dev@cxf.apache.org > Subject: Re: Support for using JMS MessageID as CorrelationID > > Hi Seumas, > > Please see my comments in the mail. > Seumas Soltysik wrote: >> I am trying to get support for using the JMS MessageID as the JMS CorrelationID as specified in https://issues.apache.org/jira/browse/CXF-2760 . After putting some work/thought into this issue, I became aware that this feature is available on the trunk but was not back-merged to the 2.1.x and 2.2.x branches. I am in the process of trying take what is done on trunk implement something similar on 2.1 and 2.2. However I have a couple of issues with the implementation on trunk that I want to sort out before back-porting. >> >> 1)There is no attribute in the clientConfig schema to specify that the user wants to use the MessageID in lieu of the CorrelationID. Currently the logic for deciding whether to use the MessageID instead of a generated CorrelationID looks like this: >> >> } else if (!jmsConfig.isSetConduitSelectorPrefix() >> && (exchange.isSynchronous() || exchange.isOneWay()) >> && (!jmsConfig.isSetUseConduitIdSelector() >> || !jmsConfig.isUseConduitIdSelector())) { >> messageIdPattern = true; >> >> This is quite a bit of mumbo-jumbo which could be sorted out by specifying a config attribute. > Yes, a simple config attribute could help us. > >> 2)There is a bit of code which seem left over from a previous implementation that has no value: >> >> if (exchange.isSynchronous()) { >> synchronized (exchange) { >> exchange.put(CORRELATED, Boolean.TRUE); >> exchange.notifyAll(); >> } >> } >> >> I don't see the current purpose of this as I don't see any code which has another thread waiting on the exchange mutex. >> > It's useless, >> 3)The biggest issue with the current implementation on the trunk is the fact that using the MessageID as CorrelationID is not supported for asynchronous calls. I don't know if this was purposeful or not but the MessageID as CorrelationID paradigm is only implemented for synchronous calls. Here is the source of the problem: >> >> if (!exchange.isOneWay()) { >> synchronized (exchange) { >> jmsTemplate.send(jmsConfig.getTargetDestination(), messageCreator); >> if (messageIdPattern) { >> correlationId = messageCreator.getMessageID(); >> } >> headers.setJMSMessageID(messageCreator.getMessageID()); >> >> final String messageSelector = "JMSCorrelationID = '" + correlationId + "'"; >> if (exchange.isSynchronous()) { >> javax.jms.Message replyMessage = jmsTemplate.receiveSelected(replyToDestination, >> messageSelector); >> if (replyMessage == null) { >> throw new RuntimeException("Timeout receiving message with correlationId " >> + correlationId); >> } else { >> doReplyMessage(exchange, replyMessage); >> } >> } >> } >> >> In this situation the MessageID is never put into the correlationMap for future correlation in onMessage(). Furthermore if the call is async, there is no JMSListener set up to receive the reply using a selector which selects for the CorrrelationID equal to the MessageID. So the JMSConduit will never receive the async callback. In order to support the async scenario, the JMSListener needs to dynamically set the MessageSelector after the message is sent and the MessageID is available. Furthermore, in a multi-threaded environment, there has to be one of these listeners per thread so that threads don't modify the same message selector when making concurrent calls. >> > I recalled we make the JMSConduit simple and also want to support the > messageIdPattern last summer, we changed the code like this and we don't > support the async call for the messageIdPattern. > > If you take a look at the first huge if condition checking again, you > can see that. > I don't like the way to implement the listener per thread to the async > call with the messageIdPattern by using the thread local, it looks a > litter mass. How about a using a work queue to take the response > receiving job ? > >> Feedback on these issues is appreciated so that I can move ahead with modifying trunk/2.2.x/2.1.x. >> >> Regards, >> Seumas >> >> >> >> >> > Willem > >