Java Code Examples for org.apache.rocketmq.client.producer.SendResult#setRegionId()
The following examples show how to use
org.apache.rocketmq.client.producer.SendResult#setRegionId() .
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: DefaultMQProducerWithTraceTest.java From rocketmq with Apache License 2.0 | 5 votes |
private SendResult createSendResult(SendStatus sendStatus) { SendResult sendResult = new SendResult(); sendResult.setMsgId("123"); sendResult.setOffsetMsgId("123"); sendResult.setQueueOffset(456); sendResult.setSendStatus(sendStatus); sendResult.setRegionId("HZ"); return sendResult; }
Example 2
Source File: DefaultMQConsumerWithTraceTest.java From rocketmq with Apache License 2.0 | 5 votes |
private SendResult createSendResult(SendStatus sendStatus) { SendResult sendResult = new SendResult(); sendResult.setMsgId("123"); sendResult.setOffsetMsgId("123"); sendResult.setQueueOffset(456); sendResult.setSendStatus(sendStatus); sendResult.setRegionId("HZ"); return sendResult; }
Example 3
Source File: MQClientAPIImpl.java From rocketmq with Apache License 2.0 | 4 votes |
private SendResult processSendResponse( final String brokerName, final Message msg, final RemotingCommand response ) throws MQBrokerException, RemotingCommandException { SendStatus sendStatus; switch (response.getCode()) { case ResponseCode.FLUSH_DISK_TIMEOUT: { sendStatus = SendStatus.FLUSH_DISK_TIMEOUT; break; } case ResponseCode.FLUSH_SLAVE_TIMEOUT: { sendStatus = SendStatus.FLUSH_SLAVE_TIMEOUT; break; } case ResponseCode.SLAVE_NOT_AVAILABLE: { sendStatus = SendStatus.SLAVE_NOT_AVAILABLE; break; } case ResponseCode.SUCCESS: { sendStatus = SendStatus.SEND_OK; break; } default: { throw new MQBrokerException(response.getCode(), response.getRemark()); } } SendMessageResponseHeader responseHeader = (SendMessageResponseHeader) response.decodeCommandCustomHeader(SendMessageResponseHeader.class); //If namespace not null , reset Topic without namespace. String topic = msg.getTopic(); if (StringUtils.isNotEmpty(this.clientConfig.getNamespace())) { topic = NamespaceUtil.withoutNamespace(topic, this.clientConfig.getNamespace()); } MessageQueue messageQueue = new MessageQueue(topic, brokerName, responseHeader.getQueueId()); String uniqMsgId = MessageClientIDSetter.getUniqID(msg); if (msg instanceof MessageBatch) { StringBuilder sb = new StringBuilder(); for (Message message : (MessageBatch) msg) { sb.append(sb.length() == 0 ? "" : ",").append(MessageClientIDSetter.getUniqID(message)); } uniqMsgId = sb.toString(); } SendResult sendResult = new SendResult(sendStatus, uniqMsgId, responseHeader.getMsgId(), messageQueue, responseHeader.getQueueOffset()); sendResult.setTransactionId(responseHeader.getTransactionId()); String regionId = response.getExtFields().get(MessageConst.PROPERTY_MSG_REGION); String traceOn = response.getExtFields().get(MessageConst.PROPERTY_TRACE_SWITCH); if (regionId == null || regionId.isEmpty()) { regionId = MixAll.DEFAULT_TRACE_REGION_ID; } if (traceOn != null && traceOn.equals("false")) { sendResult.setTraceOn(false); } else { sendResult.setTraceOn(true); } sendResult.setRegionId(regionId); return sendResult; }