You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@qpid.apache.org by Matt Stevenson <ma...@gmail.com> on 2011/07/21 09:48:05 UTC

Setting BytesMessage content type

Hi,

I'm sending a BytesMessage from Java to C++ and I ran into a little trouble
with content type.
In my Java client code I am using a javax.jms.BytesMessage from the
geronimo-jms_1.1 library.
The BytesMessage only has methods for get/setJMSType( ), and not
get/setContentType( ).
If I set the JMSType in Java, it does not change the contentType in C++.

I can work around this by casting the BytesMessage to a qpid
JMSBytesMessage.  Then I can use setContentType( ), which shows up on on the
C++ side.

>From the documentation I was expecting setJMSType to set the contentType.
Looking at the code, it sets the "x-jms-type" message header.

Should setJMSType actually set the contentType?

Thanks.

-- 
Matt Stevenson.

Re: Setting BytesMessage content type

Posted by Matt Stevenson <ma...@gmail.com>.
Hey Rajith,

Sorry, I don't understand #2
Where would I use "x-amqp.content-type"?

Here's the issue I have:
If I have a javax.jms.Message, I have no way to set the content type which
will be received in a C++ qpid::messaging::Message
I have to explicitly cast it to an org.apache.qpid.client.message.Message
first.
I think there should be a way to set the content type from a
javax.jms.Message.

Thanks,

On Fri, Jul 22, 2011 at 10:30 AM, Rajith Attapattu <ra...@gmail.com>wrote:

> Sorry for the late reply. I did notice this a few days ago when
> debugging for an unrelated issue.
> However reading the JMS API doc, it seems the 'type' has a different
> meaning than merely content-type.
> In other words a particular type of message could support several
> content-types.
> For example "text/plain", "text/html" and "text/xml" could be valid
> content-types  for a particular message "type".
>
> Therefore I believe we should do the following.
> 1) If an application sets a value using setJMSType, then we carry it
> using "x-jms-type" and allow it be retrieve on the consumer side using
> getJMSType (if the consumer is a jms application).
>
> 2) Use "x-amqp-0-10.content-type" to get/set the content type.
>    Since content type is really not tied to particular AMQP version
> we could use "x-amqp.content-type" instead. This gives a clear
> indication that the content type will be set in the underlying AMQP
> message.
>
> Regards,
>
> Rajith
>
> On Thu, Jul 21, 2011 at 4:33 PM, Matt Stevenson
> <ma...@gmail.com> wrote:
> > The "x-jms-type" header looks like some sort of placeholder.  I couldn't
> > find it in the specs or used by other projects.
> > This can easily be fixed by having get/setJMSType(..) call
> > get/setContentType(..) in AMQMessageDelegate_0_10.java.
> >
> > Should I submit a patch?
> >
> > On Thu, Jul 21, 2011 at 12:32 PM, Gordon Sim <gs...@redhat.com> wrote:
> >
> >> On 07/21/2011 08:48 AM, Matt Stevenson wrote:
> >>
> >>> Hi,
> >>>
> >>> I'm sending a BytesMessage from Java to C++ and I ran into a little
> >>> trouble
> >>> with content type.
> >>> In my Java client code I am using a javax.jms.BytesMessage from the
> >>> geronimo-jms_1.1 library.
> >>> The BytesMessage only has methods for get/setJMSType( ), and not
> >>> get/setContentType( ).
> >>> If I set the JMSType in Java, it does not change the contentType in
> C++.
> >>>
> >>> I can work around this by casting the BytesMessage to a qpid
> >>> JMSBytesMessage.  Then I can use setContentType( ), which shows up on
> on
> >>> the
> >>> C++ side.
> >>>
> >>>  From the documentation I was expecting setJMSType to set the
> contentType.
> >>>>
> >>> Looking at the code, it sets the "x-jms-type" message header.
> >>>
> >>> Should setJMSType actually set the contentType?
> >>>
> >>
> >> That does sound reasonable to me.
> >>
> >>
> ------------------------------**------------------------------**---------
> >> Apache Qpid - AMQP Messaging Implementation
> >> Project:      http://qpid.apache.org
> >> Use/Interact: mailto:users-subscribe@qpid.**apache.org<
> users-subscribe@qpid.apache.org>
> >>
> >>
> >
> >
> > --
> > Matt Stevenson.
> >
>
> ---------------------------------------------------------------------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.apache.org
>
>


-- 
Matt Stevenson.

Re: Setting BytesMessage content type

Posted by Rajith Attapattu <ra...@gmail.com>.
Sorry for the late reply. I did notice this a few days ago when
debugging for an unrelated issue.
However reading the JMS API doc, it seems the 'type' has a different
meaning than merely content-type.
In other words a particular type of message could support several content-types.
For example "text/plain", "text/html" and "text/xml" could be valid
content-types  for a particular message "type".

Therefore I believe we should do the following.
1) If an application sets a value using setJMSType, then we carry it
using "x-jms-type" and allow it be retrieve on the consumer side using
getJMSType (if the consumer is a jms application).

2) Use "x-amqp-0-10.content-type" to get/set the content type.
    Since content type is really not tied to particular AMQP version
we could use "x-amqp.content-type" instead. This gives a clear
indication that the content type will be set in the underlying AMQP
message.

Regards,

Rajith

On Thu, Jul 21, 2011 at 4:33 PM, Matt Stevenson
<ma...@gmail.com> wrote:
> The "x-jms-type" header looks like some sort of placeholder.  I couldn't
> find it in the specs or used by other projects.
> This can easily be fixed by having get/setJMSType(..) call
> get/setContentType(..) in AMQMessageDelegate_0_10.java.
>
> Should I submit a patch?
>
> On Thu, Jul 21, 2011 at 12:32 PM, Gordon Sim <gs...@redhat.com> wrote:
>
>> On 07/21/2011 08:48 AM, Matt Stevenson wrote:
>>
>>> Hi,
>>>
>>> I'm sending a BytesMessage from Java to C++ and I ran into a little
>>> trouble
>>> with content type.
>>> In my Java client code I am using a javax.jms.BytesMessage from the
>>> geronimo-jms_1.1 library.
>>> The BytesMessage only has methods for get/setJMSType( ), and not
>>> get/setContentType( ).
>>> If I set the JMSType in Java, it does not change the contentType in C++.
>>>
>>> I can work around this by casting the BytesMessage to a qpid
>>> JMSBytesMessage.  Then I can use setContentType( ), which shows up on on
>>> the
>>> C++ side.
>>>
>>>  From the documentation I was expecting setJMSType to set the contentType.
>>>>
>>> Looking at the code, it sets the "x-jms-type" message header.
>>>
>>> Should setJMSType actually set the contentType?
>>>
>>
>> That does sound reasonable to me.
>>
>> ------------------------------**------------------------------**---------
>> Apache Qpid - AMQP Messaging Implementation
>> Project:      http://qpid.apache.org
>> Use/Interact: mailto:users-subscribe@qpid.**apache.org<us...@qpid.apache.org>
>>
>>
>
>
> --
> Matt Stevenson.
>

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org


Re: Setting BytesMessage content type

Posted by Matt Stevenson <ma...@gmail.com>.
The "x-jms-type" header looks like some sort of placeholder.  I couldn't
find it in the specs or used by other projects.
This can easily be fixed by having get/setJMSType(..) call
get/setContentType(..) in AMQMessageDelegate_0_10.java.

Should I submit a patch?

On Thu, Jul 21, 2011 at 12:32 PM, Gordon Sim <gs...@redhat.com> wrote:

> On 07/21/2011 08:48 AM, Matt Stevenson wrote:
>
>> Hi,
>>
>> I'm sending a BytesMessage from Java to C++ and I ran into a little
>> trouble
>> with content type.
>> In my Java client code I am using a javax.jms.BytesMessage from the
>> geronimo-jms_1.1 library.
>> The BytesMessage only has methods for get/setJMSType( ), and not
>> get/setContentType( ).
>> If I set the JMSType in Java, it does not change the contentType in C++.
>>
>> I can work around this by casting the BytesMessage to a qpid
>> JMSBytesMessage.  Then I can use setContentType( ), which shows up on on
>> the
>> C++ side.
>>
>>  From the documentation I was expecting setJMSType to set the contentType.
>>>
>> Looking at the code, it sets the "x-jms-type" message header.
>>
>> Should setJMSType actually set the contentType?
>>
>
> That does sound reasonable to me.
>
> ------------------------------**------------------------------**---------
> Apache Qpid - AMQP Messaging Implementation
> Project:      http://qpid.apache.org
> Use/Interact: mailto:users-subscribe@qpid.**apache.org<us...@qpid.apache.org>
>
>


-- 
Matt Stevenson.

Re: Setting BytesMessage content type

Posted by Gordon Sim <gs...@redhat.com>.
On 07/21/2011 08:48 AM, Matt Stevenson wrote:
> Hi,
>
> I'm sending a BytesMessage from Java to C++ and I ran into a little trouble
> with content type.
> In my Java client code I am using a javax.jms.BytesMessage from the
> geronimo-jms_1.1 library.
> The BytesMessage only has methods for get/setJMSType( ), and not
> get/setContentType( ).
> If I set the JMSType in Java, it does not change the contentType in C++.
>
> I can work around this by casting the BytesMessage to a qpid
> JMSBytesMessage.  Then I can use setContentType( ), which shows up on on the
> C++ side.
>
>> From the documentation I was expecting setJMSType to set the contentType.
> Looking at the code, it sets the "x-jms-type" message header.
>
> Should setJMSType actually set the contentType?

That does sound reasonable to me.

---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:users-subscribe@qpid.apache.org