Search in sources :

Example 1 with EndTransactionRequestHeader

use of com.yanghui.elephant.common.protocol.header.EndTransactionRequestHeader in project elephant by yanghuijava.

the class DefaultMQProducerImpl method endTransaction.

private void endTransaction(SendResult sendResult, LocalTransactionState localState, Throwable localException) throws InterruptedException, RemotingSendRequestException, RemotingTimeoutException, RemotingConnectException {
    EndTransactionRequestHeader requestHeader = new EndTransactionRequestHeader();
    requestHeader.setMsgId(sendResult.getMsgId());
    requestHeader.setProducerGroup(this.defaultMQProducer.getProducerGroup());
    requestHeader.setCommitOrRollback(localState.name());
    RemotingCommand request = RemotingCommand.buildRequestCmd(requestHeader, RequestCode.END_TRANSACTION);
    if (localException != null) {
        request.setRemark("executeLocalTransactionBranch exception: " + localException.toString());
    }
    this.mqProducerFactory.getRemotingClient().invokeOneway(choiceOneServer(), request, this.defaultMQProducer.getSendMsgTimeout());
}
Also used : RemotingCommand(com.yanghui.elephant.remoting.procotol.RemotingCommand) EndTransactionRequestHeader(com.yanghui.elephant.common.protocol.header.EndTransactionRequestHeader)

Example 2 with EndTransactionRequestHeader

use of com.yanghui.elephant.common.protocol.header.EndTransactionRequestHeader in project elephant by yanghuijava.

the class EndTransactionMessageProcessor method processRequest.

@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
    log.info("处理结束事务消息:{}", request);
    try {
        EndTransactionRequestHeader requestHeader = (EndTransactionRequestHeader) request.decodeCommandCustomHeader(EndTransactionRequestHeader.class);
        super.handleTransactionState(requestHeader.getMsgId(), requestHeader.getCommitOrRollback());
    } catch (Exception e) {
        log.error("EndTransaction message processor exception:{}", e);
    }
    return null;
}
Also used : EndTransactionRequestHeader(com.yanghui.elephant.common.protocol.header.EndTransactionRequestHeader)

Aggregations

EndTransactionRequestHeader (com.yanghui.elephant.common.protocol.header.EndTransactionRequestHeader)2 RemotingCommand (com.yanghui.elephant.remoting.procotol.RemotingCommand)1