org.apache.rocketmq.store.MessageExtBrokerInner Java Examples
The following examples show how to use
org.apache.rocketmq.store.MessageExtBrokerInner.
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: TransactionalMessageBridge.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
public MessageExtBrokerInner renewHalfMessageInner(MessageExt msgExt) { MessageExtBrokerInner msgInner = new MessageExtBrokerInner(); msgInner.setTopic(msgExt.getTopic()); msgInner.setBody(msgExt.getBody()); msgInner.setQueueId(msgExt.getQueueId()); msgInner.setMsgId(msgExt.getMsgId()); msgInner.setSysFlag(msgExt.getSysFlag()); msgInner.setTags(msgExt.getTags()); msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(msgInner.getTags())); MessageAccessor.setProperties(msgInner, msgExt.getProperties()); msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties())); msgInner.setBornTimestamp(msgExt.getBornTimestamp()); msgInner.setBornHost(msgExt.getBornHost()); msgInner.setStoreHost(msgExt.getStoreHost()); msgInner.setWaitStoreMsgOK(false); return msgInner; }
Example #2
Source File: DefaultTransactionalMessageCheckListener.java From rocketmq with Apache License 2.0 | 6 votes |
private MessageExtBrokerInner toMessageExtBrokerInner(MessageExt msgExt) { TopicConfig topicConfig = this.getBrokerController().getTopicConfigManager().createTopicOfTranCheckMaxTime(TCMT_QUEUE_NUMS, PermName.PERM_READ | PermName.PERM_WRITE); int queueId = Math.abs(random.nextInt() % 99999999) % TCMT_QUEUE_NUMS; MessageExtBrokerInner inner = new MessageExtBrokerInner(); inner.setTopic(topicConfig.getTopicName()); inner.setBody(msgExt.getBody()); inner.setFlag(msgExt.getFlag()); MessageAccessor.setProperties(inner, msgExt.getProperties()); inner.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties())); inner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(msgExt.getTags())); inner.setQueueId(queueId); inner.setSysFlag(msgExt.getSysFlag()); inner.setBornHost(msgExt.getBornHost()); inner.setBornTimestamp(msgExt.getBornTimestamp()); inner.setStoreHost(msgExt.getStoreHost()); inner.setReconsumeTimes(msgExt.getReconsumeTimes()); inner.setMsgId(msgExt.getMsgId()); inner.setWaitStoreMsgOK(false); return inner; }
Example #3
Source File: MessageStoreWithFilterTest.java From DDMQ with Apache License 2.0 | 6 votes |
protected List<MessageExtBrokerInner> filtered(List<MessageExtBrokerInner> msgs, ConsumerFilterData filterData) { List<MessageExtBrokerInner> filteredMsgs = new ArrayList<MessageExtBrokerInner>(); for (MessageExtBrokerInner messageExtBrokerInner : msgs) { if (!messageExtBrokerInner.getTopic().equals(filterData.getTopic())) { continue; } try { Object evlRet = filterData.getCompiledExpression().evaluate(new MessageEvaluationContext(messageExtBrokerInner.getProperties())); if (evlRet == null || !(evlRet instanceof Boolean) || (Boolean) evlRet) { filteredMsgs.add(messageExtBrokerInner); } } catch (Exception e) { e.printStackTrace(); assertThat(true).isFalse(); } } return filteredMsgs; }
Example #4
Source File: MessageStoreWithFilterTest.java From DDMQ with Apache License 2.0 | 6 votes |
protected List<MessageExtBrokerInner> putMsg(DefaultMessageStore master, int topicCount, int msgCountPerTopic) throws Exception { List<MessageExtBrokerInner> msgs = new ArrayList<MessageExtBrokerInner>(); for (int i = 0; i < topicCount; i++) { String realTopic = topic + i; for (int j = 0; j < msgCountPerTopic; j++) { MessageExtBrokerInner msg = buildMessage(); msg.setTopic(realTopic); msg.putUserProperty("a", String.valueOf(j * 10 + 5)); msg.setPropertiesString(MessageDecoder.messageProperties2String(msg.getProperties())); PutMessageResult result = master.putMessage(msg); msg.setMsgId(result.getAppendMessageResult().getMsgId()); msgs.add(msg); } } return msgs; }
Example #5
Source File: MessageStoreWithFilterTest.java From DDMQ with Apache License 2.0 | 6 votes |
public MessageExtBrokerInner buildMessage() { MessageExtBrokerInner msg = new MessageExtBrokerInner(); msg.setTopic(topic); msg.setTags(System.currentTimeMillis() + "TAG"); msg.setKeys("Hello"); msg.setBody(msgBody); msg.setKeys(String.valueOf(System.currentTimeMillis())); msg.setQueueId(queueId); msg.setSysFlag(0); msg.setBornTimestamp(System.currentTimeMillis()); msg.setStoreHost(StoreHost); msg.setBornHost(BornHost); for (int i = 1; i < 3; i++) { msg.putUserProperty(String.valueOf(i), "imagoodperson" + i); } msg.setPropertiesString(MessageDecoder.messageProperties2String(msg.getProperties())); return msg; }
Example #6
Source File: MessageStoreWithFilterTest.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
public MessageExtBrokerInner buildMessage() { MessageExtBrokerInner msg = new MessageExtBrokerInner(); msg.setTopic(topic); msg.setTags(System.currentTimeMillis() + "TAG"); msg.setKeys("Hello"); msg.setBody(msgBody); msg.setKeys(String.valueOf(System.currentTimeMillis())); msg.setQueueId(queueId); msg.setSysFlag(0); msg.setBornTimestamp(System.currentTimeMillis()); msg.setStoreHost(StoreHost); msg.setBornHost(BornHost); for (int i = 1; i < 3; i++) { msg.putUserProperty(String.valueOf(i), "imagoodperson" + i); } msg.setPropertiesString(MessageDecoder.messageProperties2String(msg.getProperties())); return msg; }
Example #7
Source File: SendMessageProcessorTest.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Test public void testProcessRequest_Transaction() throws RemotingCommandException { brokerController.setTransactionalMessageService(transactionMsgService); when(brokerController.getTransactionalMessageService().prepareMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.PUT_OK, new AppendMessageResult(AppendMessageStatus.PUT_OK))); RemotingCommand request = createSendTransactionMsgCommand(RequestCode.SEND_MESSAGE); final RemotingCommand[] response = new RemotingCommand[1]; doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { response[0] = invocation.getArgument(0); return null; } }).when(handlerContext).writeAndFlush(any(Object.class)); RemotingCommand responseToReturn = sendMessageProcessor.processRequest(handlerContext, request); if (responseToReturn != null) { assertThat(response[0]).isNull(); response[0] = responseToReturn; } assertThat(response[0].getCode()).isEqualTo(ResponseCode.SUCCESS); }
Example #8
Source File: EndTransactionProcessor.java From rocketmq with Apache License 2.0 | 6 votes |
private MessageExtBrokerInner endMessageTransaction(MessageExt msgExt) { MessageExtBrokerInner msgInner = new MessageExtBrokerInner(); msgInner.setTopic(msgExt.getUserProperty(MessageConst.PROPERTY_REAL_TOPIC)); msgInner.setQueueId(Integer.parseInt(msgExt.getUserProperty(MessageConst.PROPERTY_REAL_QUEUE_ID))); msgInner.setBody(msgExt.getBody()); msgInner.setFlag(msgExt.getFlag()); msgInner.setBornTimestamp(msgExt.getBornTimestamp()); msgInner.setBornHost(msgExt.getBornHost()); msgInner.setStoreHost(msgExt.getStoreHost()); msgInner.setReconsumeTimes(msgExt.getReconsumeTimes()); msgInner.setWaitStoreMsgOK(false); msgInner.setTransactionId(msgExt.getUserProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX)); msgInner.setSysFlag(msgExt.getSysFlag()); TopicFilterType topicFilterType = (msgInner.getSysFlag() & MessageSysFlag.MULTI_TAGS_FLAG) == MessageSysFlag.MULTI_TAGS_FLAG ? TopicFilterType.MULTI_TAG : TopicFilterType.SINGLE_TAG; long tagsCodeValue = MessageExtBrokerInner.tagsString2tagsCode(topicFilterType, msgInner.getTags()); msgInner.setTagsCode(tagsCodeValue); MessageAccessor.setProperties(msgInner, msgExt.getProperties()); msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties())); MessageAccessor.clearProperty(msgInner, MessageConst.PROPERTY_REAL_TOPIC); MessageAccessor.clearProperty(msgInner, MessageConst.PROPERTY_REAL_QUEUE_ID); return msgInner; }
Example #9
Source File: MessageStoreWithFilterTest.java From rocketmq-read with Apache License 2.0 | 6 votes |
protected List<MessageExtBrokerInner> filtered(List<MessageExtBrokerInner> msgs, ConsumerFilterData filterData) { List<MessageExtBrokerInner> filteredMsgs = new ArrayList<MessageExtBrokerInner>(); for (MessageExtBrokerInner messageExtBrokerInner : msgs) { if (!messageExtBrokerInner.getTopic().equals(filterData.getTopic())) { continue; } try { Object evlRet = filterData.getCompiledExpression().evaluate(new MessageEvaluationContext(messageExtBrokerInner.getProperties())); if (evlRet == null || !(evlRet instanceof Boolean) || (Boolean) evlRet) { filteredMsgs.add(messageExtBrokerInner); } } catch (Exception e) { e.printStackTrace(); assertThat(true).isFalse(); } } return filteredMsgs; }
Example #10
Source File: PullMessageProcessor.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
private void generateOffsetMovedEvent(final OffsetMovedEvent event) { try { MessageExtBrokerInner msgInner = new MessageExtBrokerInner(); msgInner.setTopic(MixAll.OFFSET_MOVED_EVENT); msgInner.setTags(event.getConsumerGroup()); msgInner.setDelayTimeLevel(0); msgInner.setKeys(event.getConsumerGroup()); msgInner.setBody(event.encode()); msgInner.setFlag(0); msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgInner.getProperties())); msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(TopicFilterType.SINGLE_TAG, msgInner.getTags())); msgInner.setQueueId(0); msgInner.setSysFlag(0); msgInner.setBornTimestamp(System.currentTimeMillis()); msgInner.setBornHost(RemotingUtil.string2SocketAddress(this.brokerController.getBrokerAddr())); msgInner.setStoreHost(msgInner.getBornHost()); msgInner.setReconsumeTimes(0); PutMessageResult putMessageResult = this.brokerController.getMessageStore().putMessage(msgInner); } catch (Exception e) { LOG.warn(String.format("GenerateOffsetMovedEvent Exception, %s", event.toString()), e); } }
Example #11
Source File: TransactionalMessageBridge.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
private MessageExtBrokerInner makeOpMessageInner(Message message, MessageQueue messageQueue) { MessageExtBrokerInner msgInner = new MessageExtBrokerInner(); msgInner.setTopic(message.getTopic()); msgInner.setBody(message.getBody()); msgInner.setQueueId(messageQueue.getQueueId()); msgInner.setTags(message.getTags()); msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(msgInner.getTags())); msgInner.setSysFlag(0); MessageAccessor.setProperties(msgInner, message.getProperties()); msgInner.setPropertiesString(MessageDecoder.messageProperties2String(message.getProperties())); msgInner.setBornTimestamp(System.currentTimeMillis()); msgInner.setBornHost(this.storeHost); msgInner.setStoreHost(this.storeHost); msgInner.setWaitStoreMsgOK(false); MessageClientIDSetter.setUniqID(msgInner); return msgInner; }
Example #12
Source File: MessageStoreWithFilterTest.java From rocketmq with Apache License 2.0 | 6 votes |
protected List<MessageExtBrokerInner> filtered(List<MessageExtBrokerInner> msgs, ConsumerFilterData filterData) { List<MessageExtBrokerInner> filteredMsgs = new ArrayList<MessageExtBrokerInner>(); for (MessageExtBrokerInner messageExtBrokerInner : msgs) { if (!messageExtBrokerInner.getTopic().equals(filterData.getTopic())) { continue; } try { Object evlRet = filterData.getCompiledExpression().evaluate(new MessageEvaluationContext(messageExtBrokerInner.getProperties())); if (evlRet == null || !(evlRet instanceof Boolean) || (Boolean) evlRet) { filteredMsgs.add(messageExtBrokerInner); } } catch (Exception e) { e.printStackTrace(); assertThat(true).isFalse(); } } return filteredMsgs; }
Example #13
Source File: TransactionalMessageBridge.java From rocketmq-read with Apache License 2.0 | 6 votes |
public MessageExtBrokerInner renewHalfMessageInner(MessageExt msgExt) { MessageExtBrokerInner msgInner = new MessageExtBrokerInner(); msgInner.setTopic(msgExt.getTopic()); msgInner.setBody(msgExt.getBody()); msgInner.setQueueId(msgExt.getQueueId()); msgInner.setMsgId(msgExt.getMsgId()); msgInner.setSysFlag(msgExt.getSysFlag()); msgInner.setTags(msgExt.getTags()); msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(msgInner.getTags())); MessageAccessor.setProperties(msgInner, msgExt.getProperties()); msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties())); msgInner.setBornTimestamp(msgExt.getBornTimestamp()); msgInner.setBornHost(msgExt.getBornHost()); msgInner.setStoreHost(msgExt.getStoreHost()); msgInner.setWaitStoreMsgOK(false); return msgInner; }
Example #14
Source File: MessageStoreWithFilterTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 6 votes |
protected List<MessageExtBrokerInner> putMsg(DefaultMessageStore master, int topicCount, int msgCountPerTopic) throws Exception { List<MessageExtBrokerInner> msgs = new ArrayList<MessageExtBrokerInner>(); for (int i = 0; i < topicCount; i++) { String realTopic = topic + i; for (int j = 0; j < msgCountPerTopic; j++) { MessageExtBrokerInner msg = buildMessage(); msg.setTopic(realTopic); msg.putUserProperty("a", String.valueOf(j * 10 + 5)); msg.setPropertiesString(MessageDecoder.messageProperties2String(msg.getProperties())); PutMessageResult result = master.putMessage(msg); msg.setMsgId(result.getAppendMessageResult().getMsgId()); msgs.add(msg); } } return msgs; }
Example #15
Source File: TransactionalMessageServiceImplTest.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Test public void testCheck_withCheck() { when(bridge.fetchMessageQueues(MixAll.RMQ_SYS_TRANS_HALF_TOPIC)).thenReturn(createMessageQueueSet(MixAll.RMQ_SYS_TRANS_HALF_TOPIC)); when(bridge.getHalfMessage(0, 0, 1)).thenReturn(createPullResult(MixAll.RMQ_SYS_TRANS_HALF_TOPIC, 5, "hello", 1)); when(bridge.getHalfMessage(0, 1, 1)).thenReturn(createPullResult(MixAll.RMQ_SYS_TRANS_HALF_TOPIC, 6, "hellp", 0)); when(bridge.getOpMessage(anyInt(), anyLong(), anyInt())).thenReturn(createPullResult(MixAll.RMQ_SYS_TRANS_OP_HALF_TOPIC, 1, "5", 0)); when(bridge.getBrokerController()).thenReturn(this.brokerController); when(bridge.renewHalfMessageInner(any(MessageExtBrokerInner.class))).thenReturn(createMessageBrokerInner()); when(bridge.putMessageReturnResult(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult (PutMessageStatus.PUT_OK, new AppendMessageResult(AppendMessageStatus.PUT_OK))); long timeOut = this.brokerController.getBrokerConfig().getTransactionTimeOut(); final int checkMax = this.brokerController.getBrokerConfig().getTransactionCheckMax(); final AtomicInteger checkMessage = new AtomicInteger(0); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) { checkMessage.addAndGet(1); return checkMessage; } }).when(listener).resolveHalfMsg(any(MessageExt.class)); queueTransactionMsgService.check(timeOut, checkMax, listener); assertThat(checkMessage.get()).isEqualTo(1); }
Example #16
Source File: PullMessageProcessor.java From DDMQ with Apache License 2.0 | 6 votes |
private void generateOffsetMovedEvent(final OffsetMovedEvent event) { try { MessageExtBrokerInner msgInner = new MessageExtBrokerInner(); msgInner.setTopic(MixAll.OFFSET_MOVED_EVENT); msgInner.setTags(event.getConsumerGroup()); msgInner.setDelayTimeLevel(0); msgInner.setKeys(event.getConsumerGroup()); msgInner.setBody(event.encode()); msgInner.setFlag(0); msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgInner.getProperties())); msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(TopicFilterType.SINGLE_TAG, msgInner.getTags())); msgInner.setQueueId(0); msgInner.setSysFlag(0); msgInner.setBornTimestamp(System.currentTimeMillis()); msgInner.setBornHost(RemotingUtil.string2SocketAddress(this.brokerController.getBrokerAddr())); msgInner.setStoreHost(msgInner.getBornHost()); msgInner.setReconsumeTimes(0); PutMessageResult putMessageResult = this.brokerController.getMessageStore().putMessage(msgInner); } catch (Exception e) { log.warn(String.format("generateOffsetMovedEvent Exception, %s", event.toString()), e); } }
Example #17
Source File: TransactionalMessageServiceImpl.java From rocketmq-read with Apache License 2.0 | 5 votes |
/** * Write messageExt to Half topic again * * @param messageExt Message will be write back to queue * @return Put result can used to determine the specific results of storage. */ private PutMessageResult putBackToHalfQueueReturnResult(MessageExt messageExt) { PutMessageResult putMessageResult = null; try { MessageExtBrokerInner msgInner = transactionalMessageBridge.renewHalfMessageInner(messageExt); putMessageResult = transactionalMessageBridge.putMessageReturnResult(msgInner); } catch (Exception e) { log.warn("PutBackToHalfQueueReturnResult error", e); } return putMessageResult; }
Example #18
Source File: DefaultTransactionalMessageCheckListenerTest.java From rocketmq with Apache License 2.0 | 5 votes |
private MessageExtBrokerInner createMessageExt() { MessageExtBrokerInner inner = new MessageExtBrokerInner(); MessageAccessor.putProperty(inner, MessageConst.PROPERTY_REAL_QUEUE_ID, "1"); MessageAccessor.putProperty(inner, MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX, "1234255"); MessageAccessor.putProperty(inner, MessageConst.PROPERTY_REAL_TOPIC, "realTopic"); inner.setTransactionId(inner.getProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX)); inner.setBody("check".getBytes()); inner.setMsgId("12344567890"); inner.setQueueId(0); return inner; }
Example #19
Source File: EndTransactionProcessorTest.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
@Test public void testProcessRequest() throws RemotingCommandException { when(transactionMsgService.commitMessage(any(EndTransactionRequestHeader.class))).thenReturn(createResponse(ResponseCode.SUCCESS)); when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult (PutMessageStatus.PUT_OK, new AppendMessageResult(AppendMessageStatus.PUT_OK))); RemotingCommand request = createEndTransactionMsgCommand(MessageSysFlag.TRANSACTION_COMMIT_TYPE, false); RemotingCommand response = endTransactionProcessor.processRequest(handlerContext, request); assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS); }
Example #20
Source File: TransactionalMessageBridgeTest.java From rocketmq-read with Apache License 2.0 | 5 votes |
@Test public void testPutMessageReturnResult() { when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult (PutMessageStatus.PUT_OK, new AppendMessageResult(AppendMessageStatus.PUT_OK))); PutMessageResult result = transactionBridge.putMessageReturnResult(createMessageBrokerInner()); assertThat(result.getPutMessageStatus()).isEqualTo(PutMessageStatus.PUT_OK); }
Example #21
Source File: SendMessageProcessorTest.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
@Test public void testProcessRequest_WithMsgBack() throws RemotingCommandException { when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.PUT_OK, new AppendMessageResult(AppendMessageStatus.PUT_OK))); final RemotingCommand request = createSendMsgBackCommand(RequestCode.CONSUMER_SEND_MSG_BACK); sendMessageProcessor = new SendMessageProcessor(brokerController); final RemotingCommand response = sendMessageProcessor.processRequest(handlerContext, request); assertThat(response).isNotNull(); assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS); }
Example #22
Source File: TransactionalMessageBridgeTest.java From rocketmq-read with Apache License 2.0 | 5 votes |
@Test public void testRenewImmunityHalfMessageInner() { MessageExt messageExt = createMessageBrokerInner(); final String offset = "123456789"; MessageExtBrokerInner msgInner = transactionBridge.renewImmunityHalfMessageInner(messageExt); MessageAccessor.putProperty(msgInner, MessageConst.PROPERTY_TRANSACTION_PREPARED_QUEUE_OFFSET,offset); assertThat(msgInner).isNotNull(); Map<String,String> properties = msgInner.getProperties(); assertThat(properties).isNotNull(); String resOffset = properties.get(MessageConst.PROPERTY_TRANSACTION_PREPARED_QUEUE_OFFSET); assertThat(resOffset).isEqualTo(offset); }
Example #23
Source File: TransactionalMessageBridge.java From rocketmq with Apache License 2.0 | 5 votes |
public boolean putMessage(MessageExtBrokerInner messageInner) { PutMessageResult putMessageResult = store.putMessage(messageInner); if (putMessageResult != null && putMessageResult.getPutMessageStatus() == PutMessageStatus.PUT_OK) { return true; } else { LOGGER.error("Put message failed, topic: {}, queueId: {}, msgId: {}", messageInner.getTopic(), messageInner.getQueueId(), messageInner.getMsgId()); return false; } }
Example #24
Source File: TransactionalMessageBridgeTest.java From rocketmq-read with Apache License 2.0 | 5 votes |
private MessageExtBrokerInner createMessageBrokerInner() { MessageExtBrokerInner inner = new MessageExtBrokerInner(); inner.setTransactionId("12342123444"); inner.setBornTimestamp(System.currentTimeMillis()); inner.setBody("prepare".getBytes()); inner.setMsgId("123456-123"); inner.setQueueId(0); inner.setTopic("hello"); return inner; }
Example #25
Source File: ScheduleMessageService.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
private MessageExtBrokerInner messageTimeup(MessageExt msgExt) { MessageExtBrokerInner msgInner = new MessageExtBrokerInner(); msgInner.setBody(msgExt.getBody()); msgInner.setFlag(msgExt.getFlag()); MessageAccessor.setProperties(msgInner, msgExt.getProperties()); TopicFilterType topicFilterType = MessageExt.parseTopicFilterType(msgInner.getSysFlag()); long tagsCodeValue = MessageExtBrokerInner.tagsString2tagsCode(topicFilterType, msgInner.getTags()); msgInner.setTagsCode(tagsCodeValue); msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties())); msgInner.setSysFlag(msgExt.getSysFlag()); msgInner.setBornTimestamp(msgExt.getBornTimestamp()); msgInner.setBornHost(msgExt.getBornHost()); msgInner.setStoreHost(msgExt.getStoreHost()); msgInner.setReconsumeTimes(msgExt.getReconsumeTimes()); msgInner.setWaitStoreMsgOK(false); MessageAccessor.clearProperty(msgInner, MessageConst.PROPERTY_DELAY_TIME_LEVEL); msgInner.setTopic(msgInner.getProperty(MessageConst.PROPERTY_REAL_TOPIC)); String queueIdStr = msgInner.getProperty(MessageConst.PROPERTY_REAL_QUEUE_ID); int queueId = Integer.parseInt(queueIdStr); msgInner.setQueueId(queueId); return msgInner; }
Example #26
Source File: DefaultTransactionalMessageCheckListenerTest.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
private MessageExtBrokerInner createMessageExt() { MessageExtBrokerInner inner = new MessageExtBrokerInner(); MessageAccessor.putProperty(inner,MessageConst.PROPERTY_REAL_QUEUE_ID,"1"); MessageAccessor.putProperty(inner,MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX,"1234255"); MessageAccessor.putProperty(inner,MessageConst.PROPERTY_REAL_TOPIC,"realTopic"); inner.setTransactionId(inner.getProperty(MessageConst.PROPERTY_UNIQ_CLIENT_MESSAGE_ID_KEYIDX)); inner.setBody("check".getBytes()); inner.setMsgId("12344567890"); inner.setQueueId(0); return inner; }
Example #27
Source File: TransactionalMessageBridgeTest.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
@Test public void testPutMessageReturnResult() { when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult (PutMessageStatus.PUT_OK, new AppendMessageResult(AppendMessageStatus.PUT_OK))); PutMessageResult result = transactionBridge.putMessageReturnResult(createMessageBrokerInner()); assertThat(result.getPutMessageStatus()).isEqualTo(PutMessageStatus.PUT_OK); }
Example #28
Source File: TransactionalMessageBridgeTest.java From rocketmq-4.3.0 with Apache License 2.0 | 5 votes |
@Test public void testPutHalfMessage() { when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult (PutMessageStatus.PUT_OK, new AppendMessageResult(AppendMessageStatus.PUT_OK))); PutMessageResult result = transactionBridge.putHalfMessage(createMessageBrokerInner()); assertThat(result.getPutMessageStatus()).isEqualTo(PutMessageStatus.PUT_OK); }
Example #29
Source File: ScheduleMessageService.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
private MessageExtBrokerInner messageTimeup(MessageExt msgExt) { MessageExtBrokerInner msgInner = new MessageExtBrokerInner(); msgInner.setBody(msgExt.getBody()); msgInner.setFlag(msgExt.getFlag()); MessageAccessor.setProperties(msgInner, msgExt.getProperties()); TopicFilterType topicFilterType = MessageExt.parseTopicFilterType(msgInner.getSysFlag()); long tagsCodeValue = MessageExtBrokerInner.tagsString2tagsCode(topicFilterType, msgInner.getTags()); msgInner.setTagsCode(tagsCodeValue); msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties())); msgInner.setSysFlag(msgExt.getSysFlag()); msgInner.setBornTimestamp(msgExt.getBornTimestamp()); msgInner.setBornHost(msgExt.getBornHost()); msgInner.setStoreHost(msgExt.getStoreHost()); msgInner.setReconsumeTimes(msgExt.getReconsumeTimes()); msgInner.setWaitStoreMsgOK(false); MessageAccessor.clearProperty(msgInner, MessageConst.PROPERTY_DELAY_TIME_LEVEL); msgInner.setTopic(msgInner.getProperty(MessageConst.PROPERTY_REAL_TOPIC)); String queueIdStr = msgInner.getProperty(MessageConst.PROPERTY_REAL_QUEUE_ID); int queueId = Integer.parseInt(queueIdStr); msgInner.setQueueId(queueId); return msgInner; }
Example #30
Source File: EndTransactionProcessor.java From DDMQ with Apache License 2.0 | 5 votes |
private MessageExtBrokerInner endMessageTransaction(MessageExt msgExt) { MessageExtBrokerInner msgInner = new MessageExtBrokerInner(); msgInner.setBody(msgExt.getBody()); msgInner.setFlag(msgExt.getFlag()); MessageAccessor.setProperties(msgInner, msgExt.getProperties()); TopicFilterType topicFilterType = (msgInner.getSysFlag() & MessageSysFlag.MULTI_TAGS_FLAG) == MessageSysFlag.MULTI_TAGS_FLAG ? TopicFilterType.MULTI_TAG : TopicFilterType.SINGLE_TAG; long tagsCodeValue = MessageExtBrokerInner.tagsString2tagsCode(topicFilterType, msgInner.getTags()); msgInner.setTagsCode(tagsCodeValue); msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgExt.getProperties())); msgInner.setSysFlag(msgExt.getSysFlag()); msgInner.setBornTimestamp(msgExt.getBornTimestamp()); msgInner.setBornHost(msgExt.getBornHost()); msgInner.setStoreHost(msgExt.getStoreHost()); msgInner.setReconsumeTimes(msgExt.getReconsumeTimes()); msgInner.setWaitStoreMsgOK(false); MessageAccessor.clearProperty(msgInner, MessageConst.PROPERTY_DELAY_TIME_LEVEL); msgInner.setTopic(msgExt.getTopic()); msgInner.setQueueId(msgExt.getQueueId()); return msgInner; }