org.apache.rocketmq.common.sysflag.MessageSysFlag Java Examples
The following examples show how to use
org.apache.rocketmq.common.sysflag.MessageSysFlag.
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: EndTransactionRequestHeader.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
@Override public void checkFields() throws RemotingCommandException { if (MessageSysFlag.TRANSACTION_NOT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) { return; } throw new RemotingCommandException("commitOrRollback field wrong"); }
Example #2
Source File: EndTransactionRequestHeader.java From rocketmq with Apache License 2.0 | 6 votes |
@Override public void checkFields() throws RemotingCommandException { if (MessageSysFlag.TRANSACTION_NOT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) { return; } throw new RemotingCommandException("commitOrRollback field wrong"); }
Example #3
Source File: DefaultMessageStore.java From rocketmq with Apache License 2.0 | 6 votes |
/** * 执行调度请求 * 1. 非事务消息 或 事务提交消息 建立 消息位置信息 到 ConsumeQueue * 2. 建立 索引信息 到 IndexFile * * @param req 调度请求 */ public void doDispatch(DispatchRequest req) { // 非事务消息 或 事务提交消息 建立 消息位置信息 到 ConsumeQueue final int tranType = MessageSysFlag.getTransactionValue(req.getSysFlag()); switch (tranType) { case MessageSysFlag.TRANSACTION_NOT_TYPE: // 非事务消息 case MessageSysFlag.TRANSACTION_COMMIT_TYPE: // 事务消息COMMIT DefaultMessageStore.this.putMessagePositionInfo(req.getTopic(), req.getQueueId(), req.getCommitLogOffset(), req.getMsgSize(), req.getTagsCode(), req.getStoreTimestamp(), req.getConsumeQueueOffset()); break; case MessageSysFlag.TRANSACTION_PREPARED_TYPE: // 事务消息PREPARED case MessageSysFlag.TRANSACTION_ROLLBACK_TYPE: // 事务消息ROLLBACK break; } // 建立 索引信息 到 IndexFile if (DefaultMessageStore.this.getMessageStoreConfig().isMessageIndexEnable()) { DefaultMessageStore.this.indexService.buildIndex(req); } }
Example #4
Source File: DefaultMessageStore.java From rocketmq_trans_message with Apache License 2.0 | 6 votes |
public void doDispatch(DispatchRequest req) { final int tranType = MessageSysFlag.getTransactionValue(req.getSysFlag()); switch (tranType) { case MessageSysFlag.TRANSACTION_NOT_TYPE: case MessageSysFlag.TRANSACTION_COMMIT_TYPE: DefaultMessageStore.this.putMessagePositionInfo(req.getTopic(), req.getQueueId(), req.getCommitLogOffset(), req.getMsgSize(), req.getTagsCode(), req.getStoreTimestamp(), req.getConsumeQueueOffset()); break; case MessageSysFlag.TRANSACTION_PREPARED_TYPE: case MessageSysFlag.TRANSACTION_ROLLBACK_TYPE: break; } this.handingTransactionState(req); if (DefaultMessageStore.this.getMessageStoreConfig().isMessageIndexEnable()) { DefaultMessageStore.this.indexService.buildIndex(req); } }
Example #5
Source File: TransactionalMessageBridge.java From rocketmq-read with Apache License 2.0 | 6 votes |
/** * 解析prepare消息 * @param msgInner ; * @return ; */ private MessageExtBrokerInner parseHalfMessageInner(MessageExtBrokerInner msgInner) { //在属性里添加其真实的topic MessageAccessor.putProperty(msgInner, MessageConst.PROPERTY_REAL_TOPIC, msgInner.getTopic()); //消息原来真实的队列id MessageAccessor.putProperty(msgInner, MessageConst.PROPERTY_REAL_QUEUE_ID, String.valueOf(msgInner.getQueueId())); // msgInner.setSysFlag( MessageSysFlag.resetTransactionValue(msgInner.getSysFlag(), MessageSysFlag.TRANSACTION_NOT_TYPE)); //放入到了buildHalfTopic这个队列里 msgInner.setTopic(TransactionalMessageUtil.buildHalfTopic()); //队列id为0 msgInner.setQueueId(0); //设置原来的属性 msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgInner.getProperties())); return msgInner; }
Example #6
Source File: EndTransactionRequestHeader.java From DDMQ with Apache License 2.0 | 6 votes |
@Override public void checkFields() throws RemotingCommandException { if (MessageSysFlag.TRANSACTION_NOT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) { return; } throw new RemotingCommandException("commitOrRollback field wrong"); }
Example #7
Source File: EndTransactionRequestHeader.java From rocketmq with Apache License 2.0 | 6 votes |
@Override public void checkFields() throws RemotingCommandException { if (MessageSysFlag.TRANSACTION_NOT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) { return; } throw new RemotingCommandException("commitOrRollback field wrong"); }
Example #8
Source File: EndTransactionRequestHeader.java From rocketmq-read with Apache License 2.0 | 6 votes |
@Override public void checkFields() throws RemotingCommandException { if (MessageSysFlag.TRANSACTION_NOT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) { return; } throw new RemotingCommandException("commitOrRollback field wrong"); }
Example #9
Source File: EndTransactionRequestHeader.java From DDMQ with Apache License 2.0 | 6 votes |
@Override public void checkFields() throws RemotingCommandException { if (MessageSysFlag.TRANSACTION_NOT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) { return; } throw new RemotingCommandException("commitOrRollback field wrong"); }
Example #10
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 #11
Source File: EndTransactionProcessor.java From rocketmq-4.3.0 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 #12
Source File: EndTransactionRequestHeader.java From rocketmq-4.3.0 with Apache License 2.0 | 6 votes |
@Override public void checkFields() throws RemotingCommandException { if (MessageSysFlag.TRANSACTION_NOT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) { return; } throw new RemotingCommandException("commitOrRollback field wrong"); }
Example #13
Source File: TransactionalMessageBridge.java From rocketmq with Apache License 2.0 | 5 votes |
private MessageExtBrokerInner parseHalfMessageInner(MessageExtBrokerInner msgInner) { MessageAccessor.putProperty(msgInner, MessageConst.PROPERTY_REAL_TOPIC, msgInner.getTopic()); MessageAccessor.putProperty(msgInner, MessageConst.PROPERTY_REAL_QUEUE_ID, String.valueOf(msgInner.getQueueId())); msgInner.setSysFlag( MessageSysFlag.resetTransactionValue(msgInner.getSysFlag(), MessageSysFlag.TRANSACTION_NOT_TYPE)); msgInner.setTopic(TransactionalMessageUtil.buildHalfTopic()); msgInner.setQueueId(0); msgInner.setPropertiesString(MessageDecoder.messageProperties2String(msgInner.getProperties())); return msgInner; }
Example #14
Source File: DefaultMessageStore.java From rocketmq-read with Apache License 2.0 | 5 votes |
@Override public void dispatch(DispatchRequest request) { final int tranType = MessageSysFlag.getTransactionValue(request.getSysFlag()); switch (tranType) { case MessageSysFlag.TRANSACTION_NOT_TYPE: case MessageSysFlag.TRANSACTION_COMMIT_TYPE: DefaultMessageStore.this.putMessagePositionInfo(request); break; case MessageSysFlag.TRANSACTION_PREPARED_TYPE: case MessageSysFlag.TRANSACTION_ROLLBACK_TYPE: break; default: break; } }
Example #15
Source File: DefaultMessageStore.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
@Override public void dispatch(DispatchRequest request) { final int tranType = MessageSysFlag.getTransactionValue(request.getSysFlag()); switch (tranType) { // 1、分发消息位置信息到ConsumeQueue case MessageSysFlag.TRANSACTION_NOT_TYPE: case MessageSysFlag.TRANSACTION_COMMIT_TYPE: DefaultMessageStore.this.putMessagePositionInfo(request); // 将请求发到具体的Consume Queue break; case MessageSysFlag.TRANSACTION_PREPARED_TYPE: case MessageSysFlag.TRANSACTION_ROLLBACK_TYPE: break; } }
Example #16
Source File: DefaultMessageStore.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public void dispatch(DispatchRequest request) { final int tranType = MessageSysFlag.getTransactionValue(request.getSysFlag()); switch (tranType) { case MessageSysFlag.TRANSACTION_NOT_TYPE: case MessageSysFlag.TRANSACTION_COMMIT_TYPE: DefaultMessageStore.this.putMessagePositionInfo(request); break; case MessageSysFlag.TRANSACTION_PREPARED_TYPE: case MessageSysFlag.TRANSACTION_ROLLBACK_TYPE: break; } }
Example #17
Source File: SendMessageProcessorTest.java From rocketmq with Apache License 2.0 | 5 votes |
private RemotingCommand createSendTransactionMsgCommand(int requestCode) { SendMessageRequestHeader header = createSendMsgRequestHeader(); int sysFlag = header.getSysFlag(); Map<String, String> oriProps = MessageDecoder.string2messageProperties(header.getProperties()); oriProps.put(MessageConst.PROPERTY_TRANSACTION_PREPARED, "true"); header.setProperties(MessageDecoder.messageProperties2String(oriProps)); sysFlag |= MessageSysFlag.TRANSACTION_PREPARED_TYPE; header.setSysFlag(sysFlag); RemotingCommand request = RemotingCommand.createRequestCommand(requestCode, header); request.setBody(new byte[] {'a'}); request.makeCustomHeaderToNet(); return request; }
Example #18
Source File: CheckTransactionStateResponseHeader.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
@Override public void checkFields() throws RemotingCommandException { if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) { return; } throw new RemotingCommandException("commitOrRollback field wrong"); }
Example #19
Source File: MessageExt.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
public static TopicFilterType parseTopicFilterType(final int sysFlag) { if ((sysFlag & MessageSysFlag.MULTI_TAGS_FLAG) == MessageSysFlag.MULTI_TAGS_FLAG) { return TopicFilterType.MULTI_TAG; } return TopicFilterType.SINGLE_TAG; }
Example #20
Source File: AbstractSendMessageProcessor.java From rocketmq-all-4.1.0-incubating with Apache License 2.0 | 5 votes |
protected MessageExtBrokerInner buildInnerMsg(final ChannelHandlerContext ctx, final SendMessageRequestHeader requestHeader, final byte[] body, TopicConfig topicConfig) { int queueIdInt = requestHeader.getQueueId(); if (queueIdInt < 0) { queueIdInt = Math.abs(this.random.nextInt() % 99999999) % topicConfig.getWriteQueueNums(); } int sysFlag = requestHeader.getSysFlag(); if (TopicFilterType.MULTI_TAG == topicConfig.getTopicFilterType()) { sysFlag |= MessageSysFlag.MULTI_TAGS_FLAG; } MessageExtBrokerInner msgInner = new MessageExtBrokerInner(); msgInner.setTopic(requestHeader.getTopic()); msgInner.setBody(body); msgInner.setFlag(requestHeader.getFlag()); MessageAccessor.setProperties(msgInner, MessageDecoder.string2messageProperties(requestHeader.getProperties())); msgInner.setPropertiesString(requestHeader.getProperties()); msgInner.setTagsCode(MessageExtBrokerInner.tagsString2tagsCode(topicConfig.getTopicFilterType(), msgInner.getTags())); msgInner.setQueueId(queueIdInt); msgInner.setSysFlag(sysFlag); msgInner.setBornTimestamp(requestHeader.getBornTimestamp()); msgInner.setBornHost(ctx.channel().remoteAddress()); msgInner.setStoreHost(this.getStoreHost()); msgInner.setReconsumeTimes(requestHeader.getReconsumeTimes() == null ? 0 : requestHeader .getReconsumeTimes()); return msgInner; }
Example #21
Source File: CheckTransactionStateResponseHeader.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public void checkFields() throws RemotingCommandException { if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) { return; } throw new RemotingCommandException("commitOrRollback field wrong"); }
Example #22
Source File: DefaultMQProducerImpl.java From rocketmq with Apache License 2.0 | 5 votes |
/** * 结束事务:提交消息 COMMIT / ROLLBACK * * @param sendResult 发送【Half消息】结果 * @param localTransactionState 【本地事务】状态 * @param localException 执行【本地事务】逻辑产生的异常 * @throws RemotingException 当远程调用发生异常时 * @throws MQBrokerException 当 Broker 发生异常时 * @throws InterruptedException 当线程中断时 * @throws UnknownHostException 当解码消息编号失败是 */ public void endTransaction(final SendResult sendResult, final LocalTransactionState localTransactionState, final Throwable localException) throws RemotingException, MQBrokerException, InterruptedException, UnknownHostException { // 解码消息编号 final MessageId id; if (sendResult.getOffsetMsgId() != null) { id = MessageDecoder.decodeMessageId(sendResult.getOffsetMsgId()); } else { id = MessageDecoder.decodeMessageId(sendResult.getMsgId()); } // 创建请求 String transactionId = sendResult.getTransactionId(); final String brokerAddr = this.mQClientFactory.findBrokerAddressInPublish(sendResult.getMessageQueue().getBrokerName()); EndTransactionRequestHeader requestHeader = new EndTransactionRequestHeader(); requestHeader.setTransactionId(transactionId); requestHeader.setCommitLogOffset(id.getOffset()); switch (localTransactionState) { case COMMIT_MESSAGE: requestHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_COMMIT_TYPE); break; case ROLLBACK_MESSAGE: requestHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_ROLLBACK_TYPE); break; case UNKNOW: requestHeader.setCommitOrRollback(MessageSysFlag.TRANSACTION_NOT_TYPE); break; default: break; } requestHeader.setProducerGroup(this.defaultMQProducer.getProducerGroup()); requestHeader.setTranStateTableOffset(sendResult.getQueueOffset()); requestHeader.setMsgId(sendResult.getMsgId()); String remark = localException != null ? ("executeLocalTransactionBranch exception: " + localException.toString()) : null; // 提交消息 COMMIT / ROLLBACK。!!!通信方式为:Oneway!!! this.mQClientFactory.getMQClientAPIImpl().endTransactionOneway(brokerAddr, requestHeader, remark, this.defaultMQProducer.getSendMsgTimeout()); }
Example #23
Source File: EndTransactionProcessorTest.java From rocketmq 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 #24
Source File: CheckTransactionStateResponseHeader.java From rocketmq with Apache License 2.0 | 5 votes |
@Override public void checkFields() throws RemotingCommandException { if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) { return; } throw new RemotingCommandException("commitOrRollback field wrong"); }
Example #25
Source File: CheckTransactionStateResponseHeader.java From rocketmq-read with Apache License 2.0 | 5 votes |
@Override public void checkFields() throws RemotingCommandException { if (MessageSysFlag.TRANSACTION_COMMIT_TYPE == this.commitOrRollback) { return; } if (MessageSysFlag.TRANSACTION_ROLLBACK_TYPE == this.commitOrRollback) { return; } throw new RemotingCommandException("commitOrRollback field wrong"); }
Example #26
Source File: MessageExt.java From rocketmq-read with Apache License 2.0 | 5 votes |
/** * 解析topicFilter的flagType * @param sysFlag ; * @return ; */ public static TopicFilterType parseTopicFilterType(final int sysFlag) { if ((sysFlag & MessageSysFlag.MULTI_TAGS_FLAG) == MessageSysFlag.MULTI_TAGS_FLAG) { return TopicFilterType.MULTI_TAG; } return TopicFilterType.SINGLE_TAG; }
Example #27
Source File: SendMessageProcessorTest.java From rocketmq-read with Apache License 2.0 | 5 votes |
private RemotingCommand createSendTransactionMsgCommand(int requestCode) { SendMessageRequestHeader header = createSendMsgRequestHeader(); int sysFlag = header.getSysFlag(); Map<String, String> oriProps = MessageDecoder.string2messageProperties(header.getProperties()); oriProps.put(MessageConst.PROPERTY_TRANSACTION_PREPARED, "true"); header.setProperties(MessageDecoder.messageProperties2String(oriProps)); sysFlag |= MessageSysFlag.TRANSACTION_PREPARED_TYPE; header.setSysFlag(sysFlag); RemotingCommand request = RemotingCommand.createRequestCommand(requestCode, header); request.setBody(new byte[] {'a'}); request.makeCustomHeaderToNet(); return request; }
Example #28
Source File: EndTransactionProcessorTest.java From rocketmq-read with Apache License 2.0 | 5 votes |
@Test public void testProcessRequest_RollBack() throws RemotingCommandException { when(transactionMsgService.rollbackMessage(any(EndTransactionRequestHeader.class))).thenReturn(createResponse(ResponseCode.SUCCESS)); RemotingCommand request = createEndTransactionMsgCommand(MessageSysFlag.TRANSACTION_ROLLBACK_TYPE, true); RemotingCommand response = endTransactionProcessor.processRequest(handlerContext, request); assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS); }
Example #29
Source File: EndTransactionProcessorTest.java From rocketmq-read with Apache License 2.0 | 5 votes |
@Test public void testProcessRequest_CheckMessage() 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, true); RemotingCommand response = endTransactionProcessor.processRequest(handlerContext, request); assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS); }
Example #30
Source File: EndTransactionProcessorTest.java From rocketmq with Apache License 2.0 | 5 votes |
@Test public void testProcessRequest_RollBack() throws RemotingCommandException { when(transactionMsgService.rollbackMessage(any(EndTransactionRequestHeader.class))).thenReturn(createResponse(ResponseCode.SUCCESS)); RemotingCommand request = createEndTransactionMsgCommand(MessageSysFlag.TRANSACTION_ROLLBACK_TYPE, true); RemotingCommand response = endTransactionProcessor.processRequest(handlerContext, request); assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS); }