protected void handleDelivery(String consumerTag, Envelope envelope, BasicProperties properties, byte[] body) throws IOException
{
String correlationId = properties.getCorrelationId();
String replyTo = properties.getReplyTo();
if (correlationId != null && replyTo != null)
{
T event = this.transcoder.decodeFromBytes(body);
R response = this.handler.handleDevliery(event);
this.channel.basicAck(envelope.getDeliveryTag(), false);
if (response != null)
{
this.channel.basicPublish(
"",
replyTo,
new BasicProperties("application/json", null, null, 1, null, correlationId, null, null, null, null, null, null, null, null),
this.responseTranscoder.encodeAsBytes(response)
);
}
}
else
{
logger.warn("Ignoring request without correlationId or replyTo");
}
}