}
private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request)
throws RemotingCommandException {
final ConsumeMessageDirectlyResultRequestHeader requestHeader =
(ConsumeMessageDirectlyResultRequestHeader) request
.decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);
request.getExtFields().put("brokerName", this.brokerController.getBrokerConfig().getBrokerName());
SelectMapedBufferResult selectMapedBufferResult = null;
try {
MessageId messageId = MessageDecoder.decodeMessageId(requestHeader.getMsgId());
selectMapedBufferResult =
this.brokerController.getMessageStore().selectOneMessageByOffset(messageId.getOffset());
byte[] body = new byte[selectMapedBufferResult.getSize()];
selectMapedBufferResult.getByteBuffer().get(body);
request.setBody(body);
}
catch (UnknownHostException e) {
}
finally {
if (selectMapedBufferResult != null) {
selectMapedBufferResult.release();
}
}
return this.callConsumer(RequestCode.CONSUME_MESSAGE_DIRECTLY, request,
requestHeader.getConsumerGroup(), requestHeader.getClientId());
}