Search in sources :

Example 6 with ConsumeMessageDirectlyResultRequestHeader

use of org.apache.rocketmq.common.protocol.header.ConsumeMessageDirectlyResultRequestHeader in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class ClientRemotingProcessor method consumeMessageDirectly.

private RemotingCommand consumeMessageDirectly(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final ConsumeMessageDirectlyResultRequestHeader requestHeader = (ConsumeMessageDirectlyResultRequestHeader) request.decodeCommandCustomHeader(ConsumeMessageDirectlyResultRequestHeader.class);
    final MessageExt msg = MessageDecoder.decode(ByteBuffer.wrap(request.getBody()));
    ConsumeMessageDirectlyResult result = this.mqClientFactory.consumeMessageDirectly(msg, requestHeader.getConsumerGroup(), requestHeader.getBrokerName());
    if (null != result) {
        response.setCode(ResponseCode.SUCCESS);
        response.setBody(result.encode());
    } else {
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark(String.format("The Consumer Group <%s> not exist in this consumer", requestHeader.getConsumerGroup()));
    }
    return response;
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) MessageExt(org.apache.rocketmq.common.message.MessageExt) ConsumeMessageDirectlyResult(org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult) ConsumeMessageDirectlyResultRequestHeader(org.apache.rocketmq.common.protocol.header.ConsumeMessageDirectlyResultRequestHeader)

Aggregations

ConsumeMessageDirectlyResultRequestHeader (org.apache.rocketmq.common.protocol.header.ConsumeMessageDirectlyResultRequestHeader)6 ConsumeMessageDirectlyResult (org.apache.rocketmq.common.protocol.body.ConsumeMessageDirectlyResult)4 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)4 UnknownHostException (java.net.UnknownHostException)2 MQClientException (org.apache.rocketmq.client.exception.MQClientException)2 MessageExt (org.apache.rocketmq.common.message.MessageExt)2 MessageId (org.apache.rocketmq.common.message.MessageId)2 SelectMappedBufferResult (org.apache.rocketmq.store.SelectMappedBufferResult)2