Search in sources :

Example 1 with CheckTransactionStateResponseHeader

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

the class CheckTransactionStateResponseProcessor method processRequest.

@Override
public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) {
    log.info("处理回查事务消息状态回应消息:{}", request);
    try {
        CheckTransactionStateResponseHeader header = (CheckTransactionStateResponseHeader) request.decodeCommandCustomHeader(CheckTransactionStateResponseHeader.class);
        super.handleTransactionState(header.getMessageId(), header.getCommitOrRollback());
    } catch (Exception e) {
        log.error("Check Transaction State Response processor exception:{}", e);
    }
    return null;
}
Also used : CheckTransactionStateResponseHeader(com.yanghui.elephant.common.protocol.header.CheckTransactionStateResponseHeader)

Example 2 with CheckTransactionStateResponseHeader

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

the class DefaultMQProducerImpl method checkTransactionState.

@Override
public void checkTransactionState(final String address, final String producerGroupe, final Message msg) {
    Runnable run = new Runnable() {

        @Override
        public void run() {
            try {
                TransactionMQProducer producer = (TransactionMQProducer) defaultMQProducer;
                LocalTransactionState localState = producer.getTransactionCheckListener().checkLocalTransactionState(msg);
                CheckTransactionStateResponseHeader header = new CheckTransactionStateResponseHeader();
                header.setCommitOrRollback(localState.name());
                header.setMessageId(msg.getMessageId());
                header.setProducerGroup(defaultMQProducer.getProducerGroup());
                RemotingCommand request = RemotingCommand.buildRequestCmd(header, RequestCode.CHECK_TRANSACTION_RESPONSE);
                mqProducerFactory.getRemotingClient().invokeOneway(address, request, 0);
            } catch (Exception e) {
                log.error("check transaction state error:{}", e);
            }
        }
    };
    this.checkExecutor.submit(run);
}
Also used : RemotingCommand(com.yanghui.elephant.remoting.procotol.RemotingCommand) LocalTransactionState(com.yanghui.elephant.common.constant.LocalTransactionState) CheckTransactionStateResponseHeader(com.yanghui.elephant.common.protocol.header.CheckTransactionStateResponseHeader) TransactionMQProducer(com.yanghui.elephant.client.producer.TransactionMQProducer) RemotingSendRequestException(com.yanghui.elephant.remoting.exception.RemotingSendRequestException) MQClientException(com.yanghui.elephant.client.exception.MQClientException) RemotingConnectException(com.yanghui.elephant.remoting.exception.RemotingConnectException) RemotingTimeoutException(com.yanghui.elephant.remoting.exception.RemotingTimeoutException)

Aggregations

CheckTransactionStateResponseHeader (com.yanghui.elephant.common.protocol.header.CheckTransactionStateResponseHeader)2 MQClientException (com.yanghui.elephant.client.exception.MQClientException)1 TransactionMQProducer (com.yanghui.elephant.client.producer.TransactionMQProducer)1 LocalTransactionState (com.yanghui.elephant.common.constant.LocalTransactionState)1 RemotingConnectException (com.yanghui.elephant.remoting.exception.RemotingConnectException)1 RemotingSendRequestException (com.yanghui.elephant.remoting.exception.RemotingSendRequestException)1 RemotingTimeoutException (com.yanghui.elephant.remoting.exception.RemotingTimeoutException)1 RemotingCommand (com.yanghui.elephant.remoting.procotol.RemotingCommand)1