I have setup basic Request/Reply Messaging via spring amqp using POJOs and these are exchanged over RabbitMQ via a JSON message converter.
My response pojo's payload so far has been simple strings but now I need to reply back with an image at times as well.
Q1) What would be the best way to handle this? Should the image be base64 encoded as the payload string for the JSON message?
Q2) Is it possible to simply return the image as a BytesMessage instead?
Q2.a) Would spring-amqp be able to handle two separate listeners, one that returns POJOs and another that returns BytesMessage? I would think not but here's some pseudo-code around what I'm asking:
<listener-container>
<listener ref="requestHandlerA" method="handleMessage" queue-names="#{requestQueue.name}" />
<listener ref="requestHandlerB" method="handleMessage" queue-names="#{requestQueue.name}" />
</listener-container>
public class RequestHandlerA {
public ResponseDelegatePojo handleMessage(RequestDelegatePojo requestDelegate) {...}
}
public class RequestHandlerB {
public BytesMessage handleMessage(RequestDelegatePojo requestDelegate) {...}
}
Q2.b) OR ... If the MessageListener returns an Object (may be a POJO sometimes, may be a BytesMessage at other times) ... would the spring-amqp framework be able to adjust accordingly at runtime to send back POJO serialized as json sometimes and the BytesMessage as-is at other times?