You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by Barrie Treloar <ba...@gmail.com> on 2009/09/25 09:09:54 UTC

How to guides for NormalizedMessage and creating your own protocol adapaters?

I'm trying to map a proprietary protocol to JMS and back.

I've managed to get it working by hacking at extensions to
DefaultConsumerMarshaler and DefaultProviderMarshaler.
But the use of PhaseInterceptorChain to convert to/from
NormalizedMessages is a black art.

Is there anything that documents NormalizedMessages and explains this?

I see a few dead threads that others have asked.
http://cwiki.apache.org/SM/discussion-forums.html#nabble-td6287735|a6287735
http://cwiki.apache.org/SM/discussion-forums.html#nabble-td9064300|a9064300
http://cwiki.apache.org/SM/discussion-forums.html#nabble-td18479629|a18479629
http://cwiki.apache.org/SM/discussion-forums.html#nabble-td19065392|a19101831

Any help appreciated.

Re: How to guides for NormalizedMessage and creating your own protocol adapaters?

Posted by Barrie Treloar <ba...@gmail.com>.
On Fri, Sep 25, 2009 at 8:31 PM, Lars Heinemann <lh...@apache.org> wrote:

> There is no real magic with NormalizedMessage. Just have a look at the
> JBI spec. It's explained there very detailed.
> I think you did the right thing with doing a custom marshaler for your
> protocol. So now it depends what you got when de-serializing your
> object message. I think if its a pure object you can just put that
> object to the headers map of the inMsg. Another way would be to use
> xstream for serializing / deserializing objects which would give you a
> perfect XML you can directly put into the content of the normalized
> message. I don't know your stuff good enough to give you better hints
> ;)
>
>
The JBI spec is here?
jbi-1_0-fr-spec.pdf -
http://jcp.org/aboutJava/communityprocess/final/jsr208/index.html

I went down the xstream path, since we already use xstream to send messages
over a wireless network.

I'll read the spec and wait for enlightenment.

Thanks very much for the hints.

Re: How to guides for NormalizedMessage and creating your own protocol adapaters?

Posted by Lars Heinemann <lh...@apache.org>.
There is no real magic with NormalizedMessage. Just have a look at the
JBI spec. It's explained there very detailed.
I think you did the right thing with doing a custom marshaler for your
protocol. So now it depends what you got when de-serializing your
object message. I think if its a pure object you can just put that
object to the headers map of the inMsg. Another way would be to use
xstream for serializing / deserializing objects which would give you a
perfect XML you can directly put into the content of the normalized
message. I don't know your stuff good enough to give you better hints
;)

Lars


2009/9/25 Barrie Treloar <ba...@gmail.com>:
> On Fri, Sep 25, 2009 at 4:53 PM, Lars Heinemann <lh...@apache.org> wrote:
>> So you fill the JMS queue from outside SMX and process them inside SMX?
>> Well you always have to use Normalized messages inside the bus. Thats
>> the way JBI works.
>>
>> If you read a topic or queue from within ServiceMix you will always
>> get a MessageExchange containing a normalized message.
>> Where exactly is the problem?
>
> The problem is my understanding of how a NormalizedMessage is filled.
>
> The default marshalers only support TextMessages and I have ObjectMessages
> being published on the Queue and consumed from the Topic.
> SMX is doing the publishing (Queue) and consuming (Topic) and another
> service outside of SMX is consuming the request (Queue) and publishing the
> response (Topic).
>
> To get this to work I have written my own Marshaler, extending the
> DefaultConsumerMarshaler and DefaultProviderMarshaler and hacked the code
> that uses
> PhaseInterceptorChain to convert to/from NormalizedMessages.
>
> I couldn't find documentation that explains how you work with
> NormalizedMessages.
>
> All this is very new, so I expect I am doing something wrong.
>
> The next step after this proof of concept would be to create a binding
> component for another protocol.
> And I expect that will require understanding NormalizedMessages in greater
> details.
>
> Thanks
>



-- 
http://lhein.blogspot.com

Re: How to guides for NormalizedMessage and creating your own protocol adapaters?

Posted by Barrie Treloar <ba...@gmail.com>.
On Fri, Sep 25, 2009 at 4:53 PM, Lars Heinemann <lh...@apache.org> wrote:
> So you fill the JMS queue from outside SMX and process them inside SMX?
> Well you always have to use Normalized messages inside the bus. Thats
> the way JBI works.
>
> If you read a topic or queue from within ServiceMix you will always
> get a MessageExchange containing a normalized message.
> Where exactly is the problem?

The problem is my understanding of how a NormalizedMessage is filled.

The default marshalers only support TextMessages and I have ObjectMessages
being published on the Queue and consumed from the Topic.
SMX is doing the publishing (Queue) and consuming (Topic) and another
service outside of SMX is consuming the request (Queue) and publishing the
response (Topic).

To get this to work I have written my own Marshaler, extending the
DefaultConsumerMarshaler and DefaultProviderMarshaler and hacked the code
that uses
PhaseInterceptorChain to convert to/from NormalizedMessages.

I couldn't find documentation that explains how you work with
NormalizedMessages.

All this is very new, so I expect I am doing something wrong.

The next step after this proof of concept would be to create a binding
component for another protocol.
And I expect that will require understanding NormalizedMessages in greater
details.

Thanks

Re: How to guides for NormalizedMessage and creating your own protocol adapaters?

Posted by Lars Heinemann <lh...@apache.org>.
So you fill the JMS queue from outside SMX and process them inside SMX?
Well you always have to use Normalized messages inside the bus. Thats
the way JBI works.

If you read a topic or queue from within ServiceMix you will always
get a MessageExchange containing a normalized message.
Where exactly is the problem?

Lars


2009/9/25 Barrie Treloar <ba...@gmail.com>:
> On Fri, Sep 25, 2009 at 4:43 PM, Lars Heinemann <lh...@apache.org> wrote:
>> Barrie,
>>
>> what you explained here make me think you should write your own
>> binding component if there isn't already
>> an existing one for your protocol. Could you explain it a bit more detailed?
>
> I'm placing ObjectMessages (serialized Java objects) onto a Queue and
> then reading ObjectMessage responses from a Topic.
>
> I'm using the servicemix-jms component as a Provider to publish the
> messages onto a Queue using my own ProducerMarshaler (extending
> DefaultProviderMarshaler), likewise I have a Consumer for the Topic
> using my own ConsumerMarshaler (extending DefaultConsumerMarshaler).
>
> The marsharler's know how to transform between Protocol and JMS messages.
>
> But even if I am creating my own binding component, dont I still have
> to use NormalizedMessages?
>
> Cheers
>



-- 
http://lhein.blogspot.com

Re: How to guides for NormalizedMessage and creating your own protocol adapaters?

Posted by Barrie Treloar <ba...@gmail.com>.
On Fri, Sep 25, 2009 at 4:43 PM, Lars Heinemann <lh...@apache.org> wrote:
> Barrie,
>
> what you explained here make me think you should write your own
> binding component if there isn't already
> an existing one for your protocol. Could you explain it a bit more detailed?

I'm placing ObjectMessages (serialized Java objects) onto a Queue and
then reading ObjectMessage responses from a Topic.

I'm using the servicemix-jms component as a Provider to publish the
messages onto a Queue using my own ProducerMarshaler (extending
DefaultProviderMarshaler), likewise I have a Consumer for the Topic
using my own ConsumerMarshaler (extending DefaultConsumerMarshaler).

The marsharler's know how to transform between Protocol and JMS messages.

But even if I am creating my own binding component, dont I still have
to use NormalizedMessages?

Cheers

Re: How to guides for NormalizedMessage and creating your own protocol adapaters?

Posted by Lars Heinemann <lh...@apache.org>.
Barrie,

what you explained here make me think you should write your own
binding component if there isn't already
an existing one for your protocol. Could you explain it a bit more detailed?

Lars



2009/9/25 Barrie Treloar <ba...@gmail.com>:
> I'm trying to map a proprietary protocol to JMS and back.
>
> I've managed to get it working by hacking at extensions to
> DefaultConsumerMarshaler and DefaultProviderMarshaler.
> But the use of PhaseInterceptorChain to convert to/from
> NormalizedMessages is a black art.
>
> Is there anything that documents NormalizedMessages and explains this?
>
> I see a few dead threads that others have asked.
> http://cwiki.apache.org/SM/discussion-forums.html#nabble-td6287735|a6287735
> http://cwiki.apache.org/SM/discussion-forums.html#nabble-td9064300|a9064300
> http://cwiki.apache.org/SM/discussion-forums.html#nabble-td18479629|a18479629
> http://cwiki.apache.org/SM/discussion-forums.html#nabble-td19065392|a19101831
>
> Any help appreciated.
>



-- 
http://lhein.blogspot.com