Java Code Examples for com.alibaba.rocketmq.common.message.MessageDecoder#decodeMessageId()
The following examples show how to use
com.alibaba.rocketmq.common.message.MessageDecoder#decodeMessageId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AdminBrokerProcessor.java From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 | 6 votes |
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()); }
Example 2
Source File: AdminBrokerProcessor.java From rocketmq with Apache License 2.0 | 6 votes |
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()); }
Example 3
Source File: DefaultMQPullConsumer.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public MessageExt viewMessage(String topic, String uniqKey) throws RemotingException, MQBrokerException, InterruptedException, MQClientException { try { MessageDecoder.decodeMessageId(uniqKey); return this.viewMessage(uniqKey); } catch (Exception e) { } return this.defaultMQPullConsumerImpl.queryMessageByUniqKey(topic, uniqKey); }
Example 4
Source File: DefaultMQPushConsumer.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public MessageExt viewMessage(String topic, String msgId) throws RemotingException, MQBrokerException, InterruptedException, MQClientException { try { MessageDecoder.decodeMessageId(msgId); return this.viewMessage(msgId); } catch (Exception e) { } return this.defaultMQPushConsumerImpl.queryMessageByUniqKey(topic, msgId); }
Example 5
Source File: AdminBrokerProcessor.java From RocketMQ-Master-analyze with Apache License 2.0 | 5 votes |
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()); }