You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@camel.apache.org by unleashed85 <ca...@bradreitmeyer.com> on 2015/04/01 17:51:57 UTC

Re: Adding inOut support to the RabbitMQ component

I have it working (at least for direct exchanges) but I ended up with some
duplicated code from the camel-jms component. A few example are the
CorrelationTimeoutMap, CorrelationListener, QueueReplyHandler classes.  What
is the right thing to?

1) Add camel-jms as a dependency of camel-rabbitmq
2) Move the common classes somewhere else
3) Just copy them
4) ???

Thanks,
Brad




--
View this message in context: http://camel.465427.n5.nabble.com/Adding-inOut-support-to-the-RabbitMQ-component-tp5764656p5765168.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Adding inOut support to the RabbitMQ component

Posted by unleashed85 <ca...@bradreitmeyer.com>.
I went ahead and added the ability for it to natively support sending any
object that implements Serializable. There were several places that were
converting the body of the exchange to a byte[] then calling
channel.basicPublish(...). I combined all of them into this one method. I'm
not a fan of using a try / catch to see if the TypeConverter was able to
convert the body to a byte[] but I think it provides the best backwards
compatibility and flexibility. I could also make it an endpoint option to
always Serialize (defaulted to off).





--
View this message in context: http://camel.465427.n5.nabble.com/Adding-inOut-support-to-the-RabbitMQ-component-tp5764656p5765718.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Adding inOut support to the RabbitMQ component

Posted by unleashed85 <ca...@bradreitmeyer.com>.
I still have some things to clean up and a few more tests to write but I'd
like to start getting some comments:

https://github.com/brreitme/camel/commit/b77e1297f2f8371257a36e56c9cfd096720c39ca



--
View this message in context: http://camel.465427.n5.nabble.com/Adding-inOut-support-to-the-RabbitMQ-component-tp5764656p5766443.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Adding inOut support to the RabbitMQ component

Posted by Willem Jiang <wi...@gmail.com>.
Hi Brad

It's not surprise that RabbitMQ cannot natively send the Serializable
objects, as the server is not wrote in Java.
Please feel free to send a PR if you have something to show us.



Willem Jiang

Red Hat, Inc.

Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
          http://jnn.iteye.com  (Chinese)
Twitter: willemjiang
Weibo: 姜宁willem

On Fri, Apr 10, 2015 at 11:32 PM, unleashed85 <ca...@bradreitmeyer.com>
wrote:

> Williem,
> Would you like me to go ahead and move those classes? If so is it fine for
> the tests to stay in the components or would I also need a set of tests in
> camel-core?
>
>
> I'm running into another issue I could use some advice on. I'm trying to
> make the functionally equivalent to the camel-jms component which includes
> passing exceptions through. For example if the consumer side throws a
> NullPointerException I want the consumer to serialize the exception so the
> NullPointerException gets set on the exchange after the reply. My problem
> is
> that the com.rabbitmq.client only accepts byte[] and camel's
> DefaultTypeConverter wont convert a Serializable object to a byte[]. Thus
> it
> throws a NoTypeConversionAvailableException.
>
> 1) It seems odd that the camel-rabbitmq component cant natively send
> objects
> that implement Serializable. Am I missing a simple setting somewhere?
> 2) To make throwing exceptions work I ended up just writing the exception
> out to a byte[] with a ByteArrayOutputStream / ObjectOutputStream and
> setting a header to indicate there was an exception. Then when it gets a
> reply it checks that header and uses a ByteArrayInputStream /
> ObjectInputStream to deserialize. While this seems to work well, I assume
> there is a more generic way to do this?
>
> Thanks,
> Brad
>
>
>
> --
> View this message in context:
> http://camel.465427.n5.nabble.com/Adding-inOut-support-to-the-RabbitMQ-component-tp5764656p5765607.html
> Sent from the Camel Development mailing list archive at Nabble.com.
>

Re: Adding inOut support to the RabbitMQ component

Posted by unleashed85 <ca...@bradreitmeyer.com>.
Williem,
Would you like me to go ahead and move those classes? If so is it fine for
the tests to stay in the components or would I also need a set of tests in
camel-core?


I'm running into another issue I could use some advice on. I'm trying to
make the functionally equivalent to the camel-jms component which includes
passing exceptions through. For example if the consumer side throws a
NullPointerException I want the consumer to serialize the exception so the
NullPointerException gets set on the exchange after the reply. My problem is
that the com.rabbitmq.client only accepts byte[] and camel's
DefaultTypeConverter wont convert a Serializable object to a byte[]. Thus it
throws a NoTypeConversionAvailableException.

1) It seems odd that the camel-rabbitmq component cant natively send objects
that implement Serializable. Am I missing a simple setting somewhere?
2) To make throwing exceptions work I ended up just writing the exception
out to a byte[] with a ByteArrayOutputStream / ObjectOutputStream and
setting a header to indicate there was an exception. Then when it gets a
reply it checks that header and uses a ByteArrayInputStream /
ObjectInputStream to deserialize. While this seems to work well, I assume
there is a more generic way to do this?

Thanks,
Brad



--
View this message in context: http://camel.465427.n5.nabble.com/Adding-inOut-support-to-the-RabbitMQ-component-tp5764656p5765607.html
Sent from the Camel Development mailing list archive at Nabble.com.

Re: Adding inOut support to the RabbitMQ component

Posted by Willem Jiang <wi...@gmail.com>.
Maybe we can consider to move these code to the camel-core.

--  
Willem Jiang

Red Hat, Inc.
Web: http://www.redhat.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.iteye.com (Chinese)
Twitter: willemjiang  
Weibo: 姜宁willem



On April 2, 2015 at 2:26:53 PM, unleashed85 (camel@bradreitmeyer.com) wrote:
> I have it working (at least for direct exchanges) but I ended up with some
> duplicated code from the camel-jms component. A few example are the
> CorrelationTimeoutMap, CorrelationListener, QueueReplyHandler classes. What  
> is the right thing to?
>  
> 1) Add camel-jms as a dependency of camel-rabbitmq
> 2) Move the common classes somewhere else
> 3) Just copy them
> 4) ???
>  
> Thanks,
> Brad
>  
>  
>  
>  
> --
> View this message in context: http://camel.465427.n5.nabble.com/Adding-inOut-support-to-the-RabbitMQ-component-tp5764656p5765168.html  
> Sent from the Camel Development mailing list archive at Nabble.com.
>