org.apache.rocketmq.broker.transaction.OperationResult Java Examples

The following examples show how to use org.apache.rocketmq.broker.transaction.OperationResult. 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: EndTransactionProcessorTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private OperationResult createResponse(int status){
    OperationResult response = new OperationResult();
    response.setPrepareMessage(createDefaultMessageExt());
    response.setResponseCode(status);
    response.setResponseRemark(null);
    return response;
}
 
Example #2
Source File: EndTransactionProcessorTest.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
private OperationResult createResponse(int status){
    OperationResult response = new OperationResult();
    response.setPrepareMessage(createDefaultMessageExt());
    response.setResponseCode(status);
    response.setResponseRemark(null);
    return response;
}
 
Example #3
Source File: TransactionalMessageServiceImpl.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
/**
 * 获取halfMessage通过偏移量
 * @param commitLogOffset ;
 * @return ;
 */
private OperationResult getHalfMessageByOffset(long commitLogOffset) {
    OperationResult response = new OperationResult();
    //通过偏移量获取preparemessage
    MessageExt messageExt = this.transactionalMessageBridge.lookMessageByOffset(commitLogOffset);
    if (messageExt != null) {
        response.setPrepareMessage(messageExt);
        response.setResponseCode(ResponseCode.SUCCESS);
    } else {
        response.setResponseCode(ResponseCode.SYSTEM_ERROR);
        response.setResponseRemark("Find prepared transaction message failed");
    }
    return response;
}
 
Example #4
Source File: TransactionalMessageServiceImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
private OperationResult getHalfMessageByOffset(long commitLogOffset) {
    OperationResult response = new OperationResult();
    MessageExt messageExt = this.transactionalMessageBridge.lookMessageByOffset(commitLogOffset);
    if (messageExt != null) {
        response.setPrepareMessage(messageExt);
        response.setResponseCode(ResponseCode.SUCCESS);
    } else {
        response.setResponseCode(ResponseCode.SYSTEM_ERROR);
        response.setResponseRemark("Find prepared transaction message failed");
    }
    return response;
}
 
Example #5
Source File: TransactionalMessageServiceImpl.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
private OperationResult getHalfMessageByOffset(long commitLogOffset) {
        OperationResult response = new OperationResult();
//        根据offset查询消息=》
        MessageExt messageExt = this.transactionalMessageBridge.lookMessageByOffset(commitLogOffset);
        if (messageExt != null) {
            response.setPrepareMessage(messageExt);
            response.setResponseCode(ResponseCode.SUCCESS);
        } else {
            response.setResponseCode(ResponseCode.SYSTEM_ERROR);
            response.setResponseRemark("Find prepared transaction message failed");
        }
        return response;
    }
 
Example #6
Source File: EndTransactionProcessorTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
private OperationResult createResponse(int status){
    OperationResult response = new OperationResult();
    response.setPrepareMessage(createDefaultMessageExt());
    response.setResponseCode(status);
    response.setResponseRemark(null);
    return response;
}
 
Example #7
Source File: TransactionalMessageServiceImplTest.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
@Test
public void testRollbackMessage() {
    when(bridge.lookMessageByOffset(anyLong())).thenReturn(createMessageBrokerInner());
    OperationResult result = queueTransactionMsgService.commitMessage(createEndTransactionRequestHeader(MessageSysFlag.TRANSACTION_ROLLBACK_TYPE));
    assertThat(result.getResponseCode()).isEqualTo(ResponseCode.SUCCESS);
}
 
Example #8
Source File: TransactionalMessageServiceImpl.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Override
public OperationResult rollbackMessage(EndTransactionRequestHeader requestHeader) {
    return null;
}
 
Example #9
Source File: TransactionalMessageServiceImpl.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Override
public OperationResult commitMessage(EndTransactionRequestHeader requestHeader) {
    return null;
}
 
Example #10
Source File: TransactionalMessageServiceImplTest.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Test
public void testRollbackMessage() {
    when(bridge.lookMessageByOffset(anyLong())).thenReturn(createMessageBrokerInner());
    OperationResult result = queueTransactionMsgService.commitMessage(createEndTransactionRequestHeader(MessageSysFlag.TRANSACTION_ROLLBACK_TYPE));
    assertThat(result.getResponseCode()).isEqualTo(ResponseCode.SUCCESS);
}
 
Example #11
Source File: TransactionalMessageServiceImplTest.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Test
public void testCommitMessage() {
    when(bridge.lookMessageByOffset(anyLong())).thenReturn(createMessageBrokerInner());
    OperationResult result = queueTransactionMsgService.commitMessage(createEndTransactionRequestHeader(MessageSysFlag.TRANSACTION_COMMIT_TYPE));
    assertThat(result.getResponseCode()).isEqualTo(ResponseCode.SUCCESS);
}
 
Example #12
Source File: TransactionalMessageServiceImpl.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Override
public OperationResult rollbackMessage(EndTransactionRequestHeader requestHeader) {
    return getHalfMessageByOffset(requestHeader.getCommitLogOffset());
}
 
Example #13
Source File: TransactionalMessageServiceImpl.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
@Override
public OperationResult commitMessage(EndTransactionRequestHeader requestHeader) {
    return getHalfMessageByOffset(requestHeader.getCommitLogOffset());
}
 
Example #14
Source File: TransactionalMessageServiceImpl.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
@Override
public OperationResult rollbackMessage(EndTransactionRequestHeader requestHeader) {
    return null;
}
 
Example #15
Source File: TransactionalMessageServiceImpl.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
@Override
public OperationResult commitMessage(EndTransactionRequestHeader requestHeader) {
    return null;
}
 
Example #16
Source File: TransactionalMessageServiceImplTest.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
@Test
public void testCommitMessage() {
    when(bridge.lookMessageByOffset(anyLong())).thenReturn(createMessageBrokerInner());
    OperationResult result = queueTransactionMsgService.commitMessage(createEndTransactionRequestHeader(MessageSysFlag.TRANSACTION_COMMIT_TYPE));
    assertThat(result.getResponseCode()).isEqualTo(ResponseCode.SUCCESS);
}
 
Example #17
Source File: TransactionalMessageServiceImpl.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
@Override
public OperationResult rollbackMessage(EndTransactionRequestHeader requestHeader) {
    return null;
}
 
Example #18
Source File: TransactionalMessageServiceImpl.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
@Override
public OperationResult commitMessage(EndTransactionRequestHeader requestHeader) {
    return null;
}
 
Example #19
Source File: TransactionalMessageServiceImplTest.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
@Test
public void testRollbackMessage() {
    when(bridge.lookMessageByOffset(anyLong())).thenReturn(createMessageBrokerInner());
    OperationResult result = queueTransactionMsgService.commitMessage(createEndTransactionRequestHeader(MessageSysFlag.TRANSACTION_ROLLBACK_TYPE));
    assertThat(result.getResponseCode()).isEqualTo(ResponseCode.SUCCESS);
}
 
Example #20
Source File: TransactionalMessageServiceImplTest.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
@Test
public void testCommitMessage() {
    when(bridge.lookMessageByOffset(anyLong())).thenReturn(createMessageBrokerInner());
    OperationResult result = queueTransactionMsgService.commitMessage(createEndTransactionRequestHeader(MessageSysFlag.TRANSACTION_COMMIT_TYPE));
    assertThat(result.getResponseCode()).isEqualTo(ResponseCode.SUCCESS);
}
 
Example #21
Source File: TransactionalMessageServiceImpl.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
@Override
public OperationResult rollbackMessage(EndTransactionRequestHeader requestHeader) {
    return getHalfMessageByOffset(requestHeader.getCommitLogOffset());
}
 
Example #22
Source File: TransactionalMessageServiceImpl.java    From rocketmq-4.3.0 with Apache License 2.0 4 votes vote down vote up
@Override
public OperationResult commitMessage(EndTransactionRequestHeader requestHeader) {
    return getHalfMessageByOffset(requestHeader.getCommitLogOffset());
}
 
Example #23
Source File: TransactionalMessageServiceImpl.java    From rocketmq-read with Apache License 2.0 2 votes vote down vote up
/**
 * 回滚消息,和提交消息是一致的,其实就是查询prepareMessage
 * @param requestHeader Prepare message request header.
 * @return ;
 */
@Override
public OperationResult rollbackMessage(EndTransactionRequestHeader requestHeader) {
    return getHalfMessageByOffset(requestHeader.getCommitLogOffset());
}
 
Example #24
Source File: TransactionalMessageServiceImpl.java    From rocketmq-read with Apache License 2.0 2 votes vote down vote up
/**
 * 提交消息,和回滚消息的一致,其实就是查询prepareMessage
 * @param requestHeader Commit message request header.
 * @return ;
 */
@Override
public OperationResult commitMessage(EndTransactionRequestHeader requestHeader) {
    return getHalfMessageByOffset(requestHeader.getCommitLogOffset());
}