• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java OneMessageTransfer类的典型用法和代码示例

java 3次浏览

本文整理汇总了Java中com.alibaba.rocketmq.broker.pagecache.OneMessageTransfer的典型用法代码示例。如果您正苦于以下问题:Java OneMessageTransfer类的具体用法?Java OneMessageTransfer怎么用?Java OneMessageTransfer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

OneMessageTransfer类属于com.alibaba.rocketmq.broker.pagecache包,在下文中一共展示了OneMessageTransfer类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: checkProducerTransactionState

点赞 2

import com.alibaba.rocketmq.broker.pagecache.OneMessageTransfer; //导入依赖的package包/类
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();
    }
}
 

开发者ID:y123456yz,
项目名称:reading-and-annotate-rocketmq-3.4.6,
代码行数:29,
代码来源:Broker2Client.java

示例2: checkProducerTransactionState

点赞 2

import com.alibaba.rocketmq.broker.pagecache.OneMessageTransfer; //导入依赖的package包/类
/**
 * 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();
    }
}
 

开发者ID:diwayou,
项目名称:rocketmq-all-trans,
代码行数:32,
代码来源:Broker2Client.java

示例3: checkProducerTransactionState

点赞 2

import com.alibaba.rocketmq.broker.pagecache.OneMessageTransfer; //导入依赖的package包/类
/**
 * Broker主动回查Producer事务状态,Oneway
 */
public void checkProducerTransactionState(//
        final Channel channel,//
        final CheckTransactionStateRequestHeader requestHeader,//
        final SelectMapedBufferResult selectMapedBufferResult//
) {
	/**
	 * chen.si 构造事务状态回查的请求
	 */
    RemotingCommand request =
            RemotingCommand.createRequestCommand(MQRequestCode.CHECK_TRANSACTION_STATE_VALUE,
                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();
    }
}
 

开发者ID:brucechan0921,
项目名称:RocketMQ-3.0.8,
代码行数:36,
代码来源:Broker2Client.java

示例4: viewMessageById

点赞 2

import com.alibaba.rocketmq.broker.pagecache.OneMessageTransfer; //导入依赖的package包/类
public RemotingCommand viewMessageById(ChannelHandlerContext ctx, RemotingCommand request)
        throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final ViewMessageRequestHeader requestHeader =
            (ViewMessageRequestHeader) request.decodeCommandCustomHeader(ViewMessageRequestHeader.class);

    response.setOpaque(request.getOpaque());

    final SelectMapedBufferResult selectMapedBufferResult =
            this.brokerController.getMessageStore().selectOneMessageByOffset(requestHeader.getOffset());
    if (selectMapedBufferResult != null) {
        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);

        try {
            FileRegion fileRegion =
                    new OneMessageTransfer(response.encodeHeader(selectMapedBufferResult.getSize()),
                        selectMapedBufferResult);
            ctx.channel().writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    selectMapedBufferResult.release();
                    if (!future.isSuccess()) {
                        log.error("transfer one message by pagecache failed, ", future.cause());
                    }
                }
            });
        }
        catch (Throwable e) {
            log.error("", e);
            selectMapedBufferResult.release();
        }

        return null;
    }
    else {
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark("can not find message by the offset, " + requestHeader.getOffset());
    }

    return response;
}
 

开发者ID:y123456yz,
项目名称:reading-and-annotate-rocketmq-3.4.6,
代码行数:43,
代码来源:QueryMessageProcessor.java

示例5: viewMessageById

点赞 2

import com.alibaba.rocketmq.broker.pagecache.OneMessageTransfer; //导入依赖的package包/类
/**
 * 根据消息ID查找消息
 * @param ctx
 * @param request
 * @return
 * @throws RemotingCommandException
 */
public RemotingCommand viewMessageById(ChannelHandlerContext ctx, RemotingCommand request)
        throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final ViewMessageRequestHeader requestHeader =
            (ViewMessageRequestHeader) request.decodeCommandCustomHeader(ViewMessageRequestHeader.class);

    response.setOpaque(request.getOpaque());

    final SelectMapedBufferResult selectMapedBufferResult =
            this.brokerController.getMessageStore().selectOneMessageByOffset(requestHeader.getOffset());

    if (selectMapedBufferResult != null) {
        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);

        try {

            FileRegion fileRegion = new OneMessageTransfer(response.encodeHeader(selectMapedBufferResult.getSize()),
                            selectMapedBufferResult);

            ctx.channel().writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    selectMapedBufferResult.release();
                    if (!future.isSuccess()) {
                        log.error("transfer one message by pagecache failed, ", future.cause());
                    }
                }
            });

        } catch (Throwable e) {
            log.error("", e);
            selectMapedBufferResult.release();
        }

        return null;
    } else {
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark("can not find message by the offset, " + requestHeader.getOffset());
    }

    return response;
}
 

开发者ID:medusar,
项目名称:rocketmq-commet,
代码行数:51,
代码来源:QueryMessageProcessor.java

示例6: viewMessageById

点赞 2

import com.alibaba.rocketmq.broker.pagecache.OneMessageTransfer; //导入依赖的package包/类
public RemotingCommand viewMessageById(ChannelHandlerContext ctx, RemotingCommand request)
        throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final ViewMessageRequestHeader requestHeader =
            (ViewMessageRequestHeader) request.decodeCommandCustomHeader(ViewMessageRequestHeader.class);

    // 由于使用sendfile,所以必须要设置
    response.setOpaque(request.getOpaque());

    final SelectMapedBufferResult selectMapedBufferResult =
            this.brokerController.getMessageStore().selectOneMessageByOffset(requestHeader.getOffset());
    if (selectMapedBufferResult != null) {
        response.setCode(ResponseCode.SUCCESS);
        response.setRemark(null);

        try {
            FileRegion fileRegion =
                    new OneMessageTransfer(response.encodeHeader(selectMapedBufferResult.getSize()),
                        selectMapedBufferResult);
            ctx.channel().writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    selectMapedBufferResult.release();
                    if (!future.isSuccess()) {
                        log.error("transfer one message by pagecache failed, ", future.cause());
                    }
                }
            });
        }
        catch (Throwable e) {
            log.error("", e);
            selectMapedBufferResult.release();
        }

        return null;
    }
    else {
        response.setCode(ResponseCode.SYSTEM_ERROR);
        response.setRemark("can not find message by the offset, " + requestHeader.getOffset());
    }

    return response;
}
 

开发者ID:diwayou,
项目名称:rocketmq-all-trans,
代码行数:44,
代码来源:QueryMessageProcessor.java

示例7: viewMessageById

点赞 2

import com.alibaba.rocketmq.broker.pagecache.OneMessageTransfer; //导入依赖的package包/类
public RemotingCommand viewMessageById(ChannelHandlerContext ctx, RemotingCommand request)
        throws RemotingCommandException {
    final RemotingCommand response = RemotingCommand.createResponseCommand(null);
    final ViewMessageRequestHeader requestHeader =
            (ViewMessageRequestHeader) request.decodeCommandCustomHeader(ViewMessageRequestHeader.class);

    // 由于使用sendfile,所以必须要设置
    response.setOpaque(request.getOpaque());

    final SelectMapedBufferResult selectMapedBufferResult =
            this.brokerController.getMessageStore().selectOneMessageByOffset(requestHeader.getOffset());
    if (selectMapedBufferResult != null) {
        response.setCode(ResponseCode.SUCCESS_VALUE);
        response.setRemark(null);

        try {
            FileRegion fileRegion =
                    new OneMessageTransfer(response.encodeHeader(selectMapedBufferResult.getSize()),
                        selectMapedBufferResult);
            ctx.channel().writeAndFlush(fileRegion).addListener(new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture future) throws Exception {
                    selectMapedBufferResult.release();
                    if (!future.isSuccess()) {
                        log.error("transfer one message by pagecache failed, ", future.cause());
                    }
                }
            });
        }
        catch (Throwable e) {
            log.error("", e);
            selectMapedBufferResult.release();
        }

        return null;
    }
    else {
        response.setCode(ResponseCode.SYSTEM_ERROR_VALUE);
        response.setRemark("can not find message by the offset, " + requestHeader.getOffset());
    }

    return response;
}
 

开发者ID:brucechan0921,
项目名称:RocketMQ-3.0.8,
代码行数:44,
代码来源:QueryMessageProcessor.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)