You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@servicemix.apache.org by johper <ka...@hotmail.com> on 2006/09/06 14:50:53 UTC

JMS-message -> JMS-consumer -> JMS-provider

Hi

Sending a JMS-message (TextMessage) from a client into SM JMS-consumer and
route it to another queue via JMS-provider is ok we do that.

In real life our JMS-message client can send either a MapMessage or an
ObjectMessage to same JMS-consumer (queue) in SM. Can the NMR
translate/parse there messages or is there an api I can use to hook into the
message exchange in SM ?

In worse case I can preprocess these messages by creating an MDB in JBoss
but would like to use Servicemix if possible?

Any ideas?

/Johan

-- 
View this message in context: http://www.nabble.com/JMS-message--%3E-JMS-consumer--%3E-JMS-provider-tf2226788.html#a6170831
Sent from the ServiceMix - User forum at Nabble.com.


Re: MapMessage and/or ObjectMessage

Posted by Guillaume Nodet <gn...@gmail.com>.
You should be able to embed a custom jms endpoint inside your SU
along with your serialized object class.  In the SU, you will need
to add a <classpath><location>.</location></classpath> tag
which will include the SU in the classpath.

To override the default behavior, you can
  * create a custom processor and register it using
     META-INF/services/org/apache/servicemix/jms/custom
    and reference it
        <jms:endpoint processorName="custom" ... />
    The custom file is a property file which should include:
      consumer=org.apache.servicemix.jms.jca.JcaConsumerProcessor

  * create a class derived from the JmsEndpoint and use it
        instead of the <jbi:endpoint /> tag.  Remember that
        the xbean.xml file is just an enhanced spring file,
       so you can just use plain spring.

The other way is to use the lightweight jms component and
provide a custom org.apache.servicemix.components.jms.JmsMarshaler
implementation.  This will be easier.  The marshaler layer has not
been backported to servicemix-jms yet :(

On 9/7/06, mwhs <ma...@t-online.de> wrote:
>
>
> In my case, I must integrate an out-of-house component which occasionally
> sends object messages to a JMS topic. No chance to marshal this inside the
> component.
>
> Is there a best practice for that?
>
>
> gnodet wrote:
> >
> > The problem with this solution is that you tie the jms BC to
> > the marshalling layer, which is not a good thing, imho.
> >
> > You could use xstream to marshal your pojo to xml in
> > your component instead.
> >
> > Note that I do understand that for performance reasons,
> > one would not want to marshal / unmarshal pojos
> > between SE invocations and keep the pojo form.
> > ServiceMix has some features to support that, but
> > they are not used by standard jbi components.
> >
> > On 9/7/06, mwhs <ma...@t-online.de> wrote:
> >>
> >>
> >>
> >> Wouldn't it be possible to marshal the payload of an object message to
> an
> >> xml structure using xstream for instance?
> >>
> >> A feature I am definitly missing is the possibility to operate on my
> >> pojos/beans when I transform or enrich a message. Is this planned in a
> >> future version?
> >>
> >> Best regards,
> >> Martin
> >>
> >>
> >> gnodet wrote:
> >> >
> >> > Do you have any idea how you would map a
> >> > MapMessage / ObjectMessage to a JBI
> >> > normalized message.  I haven't thought
> >> > about it yet ...
> >> >
> >> > On 9/7/06, johper <ka...@hotmail.com> wrote:
> >> >>
> >> >>
> >> >> Tried sending MapMessage to Servicemix for routing it from
> JBoss-queue
> >> to
> >> >> another JBoss-queue with ServiceMix jms consumer/provider pair,
> >> getting:
> >> >> 2006-09-07 10:33:30,363 ERROR
> >> >> [
> org.apache.servicemix.jms.multiplexing.MultiplexingConsumerProcessor]
> >> >> [...]
> >> >
> >> > --
> >> > Cheers,
> >> > Guillaume Nodet
> >> >
> >> >
> >>
> >> --
> >> View this message in context:
> >>
> http://www.nabble.com/MapMessage-and-or-ObjectMessage-tf2226788.html#a6187531
> >> Sent from the ServiceMix - User forum at Nabble.com.
> >>
> >>
> >
> >
> > --
> > Cheers,
> > Guillaume Nodet
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/MapMessage-and-or-ObjectMessage-tf2226788.html#a6187726
> Sent from the ServiceMix - User forum at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet

Re: MapMessage and/or ObjectMessage

Posted by mwhs <ma...@t-online.de>.
In my case, I must integrate an out-of-house component which occasionally
sends object messages to a JMS topic. No chance to marshal this inside the
component.

Is there a best practice for that?


gnodet wrote:
> 
> The problem with this solution is that you tie the jms BC to
> the marshalling layer, which is not a good thing, imho.
> 
> You could use xstream to marshal your pojo to xml in
> your component instead.
> 
> Note that I do understand that for performance reasons,
> one would not want to marshal / unmarshal pojos
> between SE invocations and keep the pojo form.
> ServiceMix has some features to support that, but
> they are not used by standard jbi components.
> 
> On 9/7/06, mwhs <ma...@t-online.de> wrote:
>>
>>
>>
>> Wouldn't it be possible to marshal the payload of an object message to an
>> xml structure using xstream for instance?
>>
>> A feature I am definitly missing is the possibility to operate on my
>> pojos/beans when I transform or enrich a message. Is this planned in a
>> future version?
>>
>> Best regards,
>> Martin
>>
>>
>> gnodet wrote:
>> >
>> > Do you have any idea how you would map a
>> > MapMessage / ObjectMessage to a JBI
>> > normalized message.  I haven't thought
>> > about it yet ...
>> >
>> > On 9/7/06, johper <ka...@hotmail.com> wrote:
>> >>
>> >>
>> >> Tried sending MapMessage to Servicemix for routing it from JBoss-queue
>> to
>> >> another JBoss-queue with ServiceMix jms consumer/provider pair,
>> getting:
>> >> 2006-09-07 10:33:30,363 ERROR
>> >> [org.apache.servicemix.jms.multiplexing.MultiplexingConsumerProcessor]
>> >> [...]
>> >
>> > --
>> > Cheers,
>> > Guillaume Nodet
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/MapMessage-and-or-ObjectMessage-tf2226788.html#a6187531
>> Sent from the ServiceMix - User forum at Nabble.com.
>>
>>
> 
> 
> -- 
> Cheers,
> Guillaume Nodet
> 
> 

-- 
View this message in context: http://www.nabble.com/MapMessage-and-or-ObjectMessage-tf2226788.html#a6187726
Sent from the ServiceMix - User forum at Nabble.com.


Re: MapMessage and/or ObjectMessage

Posted by Guillaume Nodet <gn...@gmail.com>.
The problem with this solution is that you tie the jms BC to
the marshalling layer, which is not a good thing, imho.

You could use xstream to marshal your pojo to xml in
your component instead.

Note that I do understand that for performance reasons,
one would not want to marshal / unmarshal pojos
between SE invocations and keep the pojo form.
ServiceMix has some features to support that, but
they are not used by standard jbi components.

On 9/7/06, mwhs <ma...@t-online.de> wrote:
>
>
>
> Wouldn't it be possible to marshal the payload of an object message to an
> xml structure using xstream for instance?
>
> A feature I am definitly missing is the possibility to operate on my
> pojos/beans when I transform or enrich a message. Is this planned in a
> future version?
>
> Best regards,
> Martin
>
>
> gnodet wrote:
> >
> > Do you have any idea how you would map a
> > MapMessage / ObjectMessage to a JBI
> > normalized message.  I haven't thought
> > about it yet ...
> >
> > On 9/7/06, johper <ka...@hotmail.com> wrote:
> >>
> >>
> >> Tried sending MapMessage to Servicemix for routing it from JBoss-queue
> to
> >> another JBoss-queue with ServiceMix jms consumer/provider pair,
> getting:
> >> 2006-09-07 10:33:30,363 ERROR
> >> [org.apache.servicemix.jms.multiplexing.MultiplexingConsumerProcessor]
> >> [...]
> >
> > --
> > Cheers,
> > Guillaume Nodet
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/MapMessage-and-or-ObjectMessage-tf2226788.html#a6187531
> Sent from the ServiceMix - User forum at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet

Re: MapMessage and/or ObjectMessage

Posted by mwhs <ma...@t-online.de>.

Wouldn't it be possible to marshal the payload of an object message to an
xml structure using xstream for instance?

A feature I am definitly missing is the possibility to operate on my
pojos/beans when I transform or enrich a message. Is this planned in a
future version?

Best regards,
Martin


gnodet wrote:
> 
> Do you have any idea how you would map a
> MapMessage / ObjectMessage to a JBI
> normalized message.  I haven't thought
> about it yet ...
> 
> On 9/7/06, johper <ka...@hotmail.com> wrote:
>>
>>
>> Tried sending MapMessage to Servicemix for routing it from JBoss-queue to
>> another JBoss-queue with ServiceMix jms consumer/provider pair, getting:
>> 2006-09-07 10:33:30,363 ERROR
>> [org.apache.servicemix.jms.multiplexing.MultiplexingConsumerProcessor]
>> [...]
> 
> -- 
> Cheers,
> Guillaume Nodet
> 
> 

-- 
View this message in context: http://www.nabble.com/MapMessage-and-or-ObjectMessage-tf2226788.html#a6187531
Sent from the ServiceMix - User forum at Nabble.com.


Re: MapMessage and/or ObjectMessage

Posted by Guillaume Nodet <gn...@gmail.com>.
Do you have any idea how you would map a
MapMessage / ObjectMessage to a JBI
normalized message.  I haven't thought
about it yet ...

On 9/7/06, johper <ka...@hotmail.com> wrote:
>
>
> Tried sending MapMessage to Servicemix for routing it from JBoss-queue to
> another JBoss-queue with ServiceMix jms consumer/provider pair, getting:
> 2006-09-07 10:33:30,363 ERROR
> [org.apache.servicemix.jms.multiplexing.MultiplexingConsumerProcessor]
> Error
> while handling jms message
> java.lang.IllegalArgumentException: JMS message should be a text or bytes
> message
>         at
> org.apache.servicemix.jms.AbstractJmsProcessor.toNMS(
> AbstractJmsProcessor.java:187)
>         at
>
> org.apache.servicemix.jms.multiplexing.MultiplexingConsumerProcessor.access$300
> (MultiplexingConsumerProcessor.java:41)
>         at
> org.apache.servicemix.jms.multiplexing.MultiplexingConsumerProcessor$1.run
> (MultiplexingConsumerProcessor.java:95)
>         at
>
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask
> (ThreadPoolExecutor.java:650)
>         at
>
> edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run
> (ThreadPoolExecutor.java:675)
>         at java.lang.Thread.run(Thread.java:595)
>
> This is because Servicemix only handles/supports TextMessage and
> BytesMessage types .
>
> See sourcefile
> org.apache.servicemix.jms.multiplexing.MultiplexingProviderProcessor.java
> method onMessage() :
> if (message instanceof TextMessage) {
>                                 is = new
> ByteArrayInputStream(((TextMessage)
> message).getText().getBytes());
>                             } else if (message instanceof BytesMessage) {
>                                 int length = (int) ((BytesMessage)
> message).getBodyLength();
>                                 byte[] bytes = new byte[length];
>                                 ((BytesMessage) message).readBytes(bytes);
>                                 is = new ByteArrayInputStream(bytes);
>                             } else {
>                                 throw new IllegalArgumentException("JMS
> message should be a text or bytes message");
>                             }
>
> Is support for MapMessage and ObjectMessage planned in future release?
>
> tia
> johan
>
>
> johper wrote:
> >
> > Hi
> >
> > Sending a JMS-message (TextMessage) from a client into SM JMS-consumer
> and
> > route it to another queue via JMS-provider is ok we do that.
> >
> > In real life our JMS-message client can send either a MapMessage or an
> > ObjectMessage to same JMS-consumer (queue) in SM. Can the NMR
> > translate/parse there messages or is there an api I can use to hook into
> > the message exchange in SM ?
> >
> > In worse case I can preprocess these messages by creating an MDB in
> JBoss
> > but would like to use Servicemix if possible?
> >
> > Any ideas?
> >
> > /Johan
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/MapMessage-and-or-ObjectMessage-tf2226788.html#a6186746
> Sent from the ServiceMix - User forum at Nabble.com.
>
>


-- 
Cheers,
Guillaume Nodet

Re: MapMessage and/or ObjectMessage

Posted by johper <ka...@hotmail.com>.
Tried sending MapMessage to Servicemix for routing it from JBoss-queue to
another JBoss-queue with ServiceMix jms consumer/provider pair, getting:
2006-09-07 10:33:30,363 ERROR
[org.apache.servicemix.jms.multiplexing.MultiplexingConsumerProcessor] Error
while handling jms message
java.lang.IllegalArgumentException: JMS message should be a text or bytes
message
	at
org.apache.servicemix.jms.AbstractJmsProcessor.toNMS(AbstractJmsProcessor.java:187)
	at
org.apache.servicemix.jms.multiplexing.MultiplexingConsumerProcessor.access$300(MultiplexingConsumerProcessor.java:41)
	at
org.apache.servicemix.jms.multiplexing.MultiplexingConsumerProcessor$1.run(MultiplexingConsumerProcessor.java:95)
	at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
	at
edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
	at java.lang.Thread.run(Thread.java:595)

This is because Servicemix only handles/supports TextMessage and
BytesMessage types .

See sourcefile
org.apache.servicemix.jms.multiplexing.MultiplexingProviderProcessor.java
method onMessage() :
if (message instanceof TextMessage) {
                                is = new ByteArrayInputStream(((TextMessage)
message).getText().getBytes());
                            } else if (message instanceof BytesMessage) {
                                int length = (int) ((BytesMessage)
message).getBodyLength();
                                byte[] bytes = new byte[length];
                                ((BytesMessage) message).readBytes(bytes);
                                is = new ByteArrayInputStream(bytes);
                            } else {
                                throw new IllegalArgumentException("JMS
message should be a text or bytes message");
                            }

Is support for MapMessage and ObjectMessage planned in future release?

tia
johan


johper wrote:
> 
> Hi
> 
> Sending a JMS-message (TextMessage) from a client into SM JMS-consumer and
> route it to another queue via JMS-provider is ok we do that.
> 
> In real life our JMS-message client can send either a MapMessage or an
> ObjectMessage to same JMS-consumer (queue) in SM. Can the NMR
> translate/parse there messages or is there an api I can use to hook into
> the message exchange in SM ?
> 
> In worse case I can preprocess these messages by creating an MDB in JBoss
> but would like to use Servicemix if possible?
> 
> Any ideas?
> 
> /Johan
> 
> 

-- 
View this message in context: http://www.nabble.com/MapMessage-and-or-ObjectMessage-tf2226788.html#a6186746
Sent from the ServiceMix - User forum at Nabble.com.


Re: MapMessage and/or ObjectMessage

Posted by johper <ka...@hotmail.com>.
I think this will work for TextMessage message type:

org.apache.servicemix.components.util.TransformComponent

But what happens when a MapMessage or ObjectMessage comes in??
(trial'n'error to be continued...)


johper wrote:
> 
> Hi
> 
> Sending a JMS-message (TextMessage) from a client into SM JMS-consumer and
> route it to another queue via JMS-provider is ok we do that.
> 
> In real life our JMS-message client can send either a MapMessage or an
> ObjectMessage to same JMS-consumer (queue) in SM. Can the NMR
> translate/parse there messages or is there an api I can use to hook into
> the message exchange in SM ?
> 
> In worse case I can preprocess these messages by creating an MDB in JBoss
> but would like to use Servicemix if possible?
> 
> Any ideas?
> 
> /Johan
> 
> 

-- 
View this message in context: http://www.nabble.com/MapMessage-and-or-ObjectMessage-tf2226788.html#a6185440
Sent from the ServiceMix - User forum at Nabble.com.