-
Jul 15th, 2012, 12:00 PM
#1
JsonMessageConverter for Generics
Hi,
Our question is around the usage of JsonMessageConverter for objects that uses generics. We have created our own message class that uses generics <T> for the payload. For example:
public class AMQPMessage<T> {
private T payload;
//////// some other stuff...
}
We have tested our generic message class using jackson API directly, something like
objectMapper.readValue(src, new TypeReference<AMQPMessage<CustomerMessage>>());
and is working perfectly fine.
But when we use Spring AMQP provided JsonMessageConverter we get class cast exception, not able to cast Map to our provided message class.
What we understand here is that JsonMessageConverter and other involved Spring AMQP classes are not able to resolve generics <T> and uses Map as default.
We know it is something related to DefaultJavaTypeMapper and MapperClass but we don't know exactly how to use them. Please shed some light on this issue and let us know how to fix it with an example code.
Thanks in advance
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules