camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ebergner <emil.berg...@gmail.com>
Subject Re: Asynchronous Remoting with Futures
Date Fri, 21 Oct 2011 15:58:32 GMT
Actually it turns out that it is not working. So the original question is
still valid. I've stepped through the code a little and I notice that when
it gets here (in JmsBinding):

protected JmsMessageType getJMSMessageTypeForBody(Exchange exchange, Object
body, Map<String, Object> headers, Session session, CamelContext context) {
    JmsMessageType type = null;
    // let body determine the type
    if (body instanceof Node || body instanceof String) {
        type = Text;
    } else if (body instanceof byte[] || body instanceof GenericFile || body
instanceof File || body instanceof Reader
            || body instanceof InputStream || body instanceof ByteBuffer ||
body instanceof StreamCache) {
        type = Bytes;
    } else if (body instanceof Map) {
        type = Map;
    } else if (body instanceof Serializable) {
        type = Object;            
    } else if
(exchange.getContext().getTypeConverter().convertTo(File.class, body) !=
null 
            ||
exchange.getContext().getTypeConverter().convertTo(InputStream.class, body)
!= null) {
        type = Bytes;
    }
    return type;
}

because Future is not Serializable, it will try to convert it to either a
File or an InputStream. Then it discovers that it is actually a future
object and gets the result. It is still trying to convert to either File or
Inputstream though, so this is what I tries to convert the Future result to
as well. Since my Response class does not have a TypeConverter to neither
File nor InputStream, the conversion results in Void.

Right now I have solved this by implementing a fallback TypeConverter on the
server that converts from a Serializable object to InputStream and byte[].
And a fallback TypeConverter on the client that converts from byte[] to a
Serializable object.

Should that be necessary or am I missing something? Any help would be very
much appreciated.

Thanks,
Emil



--
View this message in context: http://camel.465427.n5.nabble.com/Asynchronous-Remoting-with-Futures-tp3606370p4925187.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Mime
View raw message