com.alibaba.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader Java Examples

The following examples show how to use com.alibaba.rocketmq.common.protocol.header.CheckTransactionStateRequestHeader. 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: DefaultTransactionCheckExecuter.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Override
public void gotoCheck(int producerGroupHashCode, long tranStateTableOffset, long commitLogOffset,
        int msgSize) {
    final ClientChannelInfo clientChannelInfo =
            this.brokerController.getProducerManager().pickProducerChannelRandomly(producerGroupHashCode);
    if (null == clientChannelInfo) {
        log.warn("check a producer transaction state, but not find any channel of this group[{}]",
            producerGroupHashCode);
        return;
    }

     SelectMapedBufferResult selectMapedBufferResult =
            this.brokerController.getMessageStore().selectOneMessageByOffset(commitLogOffset, msgSize);
    if (null == selectMapedBufferResult) {
        log.warn(
            "check a producer transaction state, but not find message by commitLogOffset: {}, msgSize: ",
            commitLogOffset, msgSize);
        return;
    }

    final CheckTransactionStateRequestHeader requestHeader = new CheckTransactionStateRequestHeader();
    requestHeader.setCommitLogOffset(commitLogOffset);
    requestHeader.setTranStateTableOffset(tranStateTableOffset);
    this.brokerController.getBroker2Client().checkProducerTransactionState(
        clientChannelInfo.getChannel(), requestHeader, selectMapedBufferResult);
}
 
Example #2
Source File: Broker2Client.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public void checkProducerTransactionState(//
        final Channel channel,//
        final CheckTransactionStateRequestHeader requestHeader,//
        final SelectMapedBufferResult selectMapedBufferResult//
) {
    RemotingCommand request =
            RemotingCommand.createRequestCommand(RequestCode.CHECK_TRANSACTION_STATE, requestHeader);
    request.markOnewayRPC();

    try {
        FileRegion fileRegion =
                new OneMessageTransfer(request.encodeHeader(selectMapedBufferResult.getSize()),
                    selectMapedBufferResult);
        channel.writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                selectMapedBufferResult.release();
                if (!future.isSuccess()) {
                    log.error("invokeProducer failed,", future.cause());
                }
            }
        });
    }
    catch (Throwable e) {
        log.error("invokeProducer exception", e);
        selectMapedBufferResult.release();
    }
}
 
Example #3
Source File: Broker2Client.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public void checkProducerTransactionState(//
                                          final Channel channel,//
                                          final CheckTransactionStateRequestHeader requestHeader,//
                                          final SelectMapedBufferResult selectMapedBufferResult//
) {
    RemotingCommand request =
            RemotingCommand.createRequestCommand(RequestCode.CHECK_TRANSACTION_STATE, requestHeader);
    request.markOnewayRPC();

    try {
        FileRegion fileRegion =
                new OneMessageTransfer(request.encodeHeader(selectMapedBufferResult.getSize()),
                        selectMapedBufferResult);
        channel.writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                selectMapedBufferResult.release();
                if (!future.isSuccess()) {
                    log.error("invokeProducer failed,", future.cause());
                }
            }
        });
    } catch (Throwable e) {
        log.error("invokeProducer exception", e);
        selectMapedBufferResult.release();
    }
}
 
Example #4
Source File: Broker2Client.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
/**
 * Broker主动回查Producer事务状态,Oneway
 */
public void checkProducerTransactionState(//
        final Channel channel, //
        final CheckTransactionStateRequestHeader requestHeader, //
        final SelectMapedBufferResult selectMapedBufferResult//
) {
    RemotingCommand request =
            RemotingCommand.createRequestCommand(RequestCode.CHECK_TRANSACTION_STATE, requestHeader);
    request.markOnewayRPC();

    try {
        FileRegion fileRegion = new OneMessageTransfer(
            request.encodeHeader(selectMapedBufferResult.getSize()), selectMapedBufferResult);
        channel.writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
            @Override
            public void operationComplete(ChannelFuture future) throws Exception {
                selectMapedBufferResult.release();
                if (!future.isSuccess()) {
                    log.error("invokeProducer failed,", future.cause());
                }
            }
        });
    }
    catch (Throwable e) {
        log.error("invokeProducer exception", e);
        selectMapedBufferResult.release();
    }
}
 
Example #5
Source File: MQProducerInner.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 4 votes vote down vote up
void checkTransactionState(//
final String addr, //
final MessageExt msg, //
final CheckTransactionStateRequestHeader checkRequestHeader);
 
Example #6
Source File: MQProducerInner.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
void checkTransactionState(//
final String addr, //
final MessageExt msg, //
final CheckTransactionStateRequestHeader checkRequestHeader);
 
Example #7
Source File: MQProducerInner.java    From RocketMQ-Master-analyze with Apache License 2.0 4 votes vote down vote up
void checkTransactionState(//
final String addr, //
final MessageExt msg, //
final CheckTransactionStateRequestHeader checkRequestHeader);