Return-Path: Delivered-To: apmail-camel-users-archive@www.apache.org Received: (qmail 81760 invoked from network); 31 Jul 2009 08:54:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 31 Jul 2009 08:54:11 -0000 Received: (qmail 78659 invoked by uid 500); 31 Jul 2009 08:54:12 -0000 Delivered-To: apmail-camel-users-archive@camel.apache.org Received: (qmail 78622 invoked by uid 500); 31 Jul 2009 08:54:11 -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 78612 invoked by uid 99); 31 Jul 2009 08:54:11 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Jul 2009 08:54:11 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of willem.jiang@gmail.com designates 209.85.198.250 as permitted sender) Received: from [209.85.198.250] (HELO rv-out-0708.google.com) (209.85.198.250) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 31 Jul 2009 08:53:59 +0000 Received: by rv-out-0708.google.com with SMTP id c5so703963rvf.56 for ; Fri, 31 Jul 2009 01:53:38 -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=c7rI6Rkel0/fvm6L2u0s6Ed5TQtZNaAGASl8za2JuC0=; b=aIK2/gLqfpnM6vqri4f7F76eJHtSSQuka1yPFQ2qmGJKptwC3P1NQGBPQV7fMkYfGe uMCMpE1LW3eeJqzchPVCZdt1iiqLSG0yXRAHls37cD3/H9khQiiIGYZAW0ELg//tS4/U 7JARkpC8wNaP2FK2JeRkHK6gAYEVww9rJIvtE= 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=L5twGzHFxxbCcR+jOLx7HKq42zQdcblu2ZMeBVhXn0uOZTPLjwUBanQQMIBRKtmVGX OPzJYldemmn9YeUqBBZyWmmORhCwJZe0rmkbux60kr6egYRZrGY8PAhJ7+x94rXlZDgz JGn51czvKVuHAXuMjVTGZQz1e2SCY27k/rVvA= Received: by 10.141.19.9 with SMTP id w9mr1844880rvi.162.1249030418570; Fri, 31 Jul 2009 01:53:38 -0700 (PDT) Received: from ?192.168.0.158? ([222.131.240.212]) by mx.google.com with ESMTPS id c20sm16823980rvf.51.2009.07.31.01.53.36 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 31 Jul 2009 01:53:37 -0700 (PDT) Message-ID: <4A72B10D.3030300@gmail.com> Date: Fri, 31 Jul 2009 16:53:33 +0800 From: Willem Jiang User-Agent: Thunderbird 2.0.0.22 (Macintosh/20090605) MIME-Version: 1.0 To: users@camel.apache.org Subject: Re: JmsMessage headers and body References: <24745828.post@talk.nabble.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Virus-Checked: Checked by ClamAV on apache.org Hi, Why did you need set the message body to be null ? Will you route the message to the other queue ? As you know camel has it's Message wrapper for all the other components' message, we may extend the DefaultMessage to hold the reference of under layer's component message, If you want deal with the JMS Message you can get it from the JMSMessage which extends from the DefaultMessage by using the getJmsMessage() method. Since JMSMessage maps header with under lay's JMS message with the JMS properties, you'd better don't use the getHeaders method. Maybe we need to find way to avoid this kind issue of message header mapping. Willem Zhi Zhou wrote: > Ashwin, > > Thank you very much for the reply. > My further comments below. > > On Fri, Jul 31, 2009 at 3:29 AM, Ashwin Karpe wrote: >> Hi, >> >> There is no need for a fix. Please find the answers to your questions below. >> >>> 1. I can't use setBody(null) to remove the payload of the message. >>> instead, I have to use setBody("") or similar value to represent an >>> empty payload, which can be problematic in some cases, as NULL and >>> non-NULL value will suggest completely different to other components. >> If you wish to use a payload with no body element, please use the Message >> base class.This message type is used for event notification and does not >> have a payload. If you any of the other Message Types (BytesMessage, >> TestMessage, StreamMessage, MapMessage, ObjectMessage) a body object is >> assumed and needed. This is per the JMS spec. >> > > This makes sense. > > In my particular case, I have a route consuming from a jms queue and > sending to another endpoint after removing the payload. forgive me if > it's dumb, but I don't have a chance to use other message class than > JmsMessage during the processing of the route, do I? > > >>> 2. getHeader(key) and getHeaders().get(key) can return different >>> results, because getHeader will look first in the original jms message >>> if the header is available, but the same header in the internal map >>> may be modified as setHeader will only modify the internal map. this >>> is all very confusing and 'inconsistent' if people don't know. Since >>> the original properties of the jms message are copied into the >>> internal map, why do we ever need to have these operations like >>> set/getBody, set/getHeader and removeHeader have to tackle on the >>> original jms message? >> These are APIs to easily parse JMS messages and simply stated needed to >> prevent folks from doing exactly what you have stated above. Directly >> manipulating JMS data structures is not good programming practise. It is >> better accomplished using helper classes. >> > > In fact, what I want to do is not changing the JMS data structure. > what I am trying to process is the camel > message populated from the received JMS message. shouldn't we just > keep the original JMS message as reference inside > the camel's JmsMessage? > >>>From the user point of view, it just surprises me hard when I find > JmsMessage.getHeader(key) and JmsMessage.getHeaders().get("headerA") > can return completely different results. > >> Hope this clarifies things. >> >> Cheers, >> >> Ashwin... >> >> >> Zhi Zhou wrote: >>> Hi, >>> >>> I've been working with camel 2.0-m2 so far. Some behaviors related to >>> getting and setting JmsMessage header and body appear very annoying. >>> >>> Just try to confirm/discuss here if they are like so in design or require >>> a fix: >>> >>> 1. I can't use setBody(null) to remove the payload of the message. >>> instead, I have to use setBody("") or similar value to represent an >>> empty payload, which can be problematic in some cases, as NULL and >>> non-NULL value will suggest completely different to other components. >>> >>> 2. getHeader(key) and getHeaders().get(key) can return different >>> results, because getHeader will look first in the original jms message >>> if the header is available, but the same header in the internal map >>> may be modified as setHeader will only modify the internal map. this >>> is all very confusing and 'inconsistent' if people don't know. Since >>> the original properties of the jms message are copied into the >>> internal map, why do we ever need to have these operations like >>> set/getBody, set/getHeader and removeHeader have to tackle on the >>> original jms message? >>> >>> Thanks! >>> >>> Zhi >>> >>> >> >> ----- >> --- >> Ashwin Karpe, Principal Consultant, PS - Opensource Center of Competence >> Progress Software Corporation >> 14 Oak Park Drive >> Bedford, MA 01730 >> --- >> +1-972-304-9084 (Office) >> +1-972-971-1700 (Mobile) >> ---- >> Blog: http://opensourceknowledge.blogspot.com/ >> >> >> -- >> View this message in context: http://www.nabble.com/JmsMessage-headers-and-body-tp24731110p24745828.html >> Sent from the Camel - Users mailing list archive at Nabble.com. >> >> >