org.apache.rocketmq.remoting.netty.NettyRemotingClient Java Examples

The following examples show how to use org.apache.rocketmq.remoting.netty.NettyRemotingClient. 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: MQClientAPIImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
public MQClientAPIImpl(final NettyClientConfig nettyClientConfig,
    final ClientRemotingProcessor clientRemotingProcessor,
    RPCHook rpcHook, final ClientConfig clientConfig) {
    this.clientConfig = clientConfig;
    topAddressing = new TopAddressing(MixAll.getWSAddr(), clientConfig.getUnitName());
    this.remotingClient = new NettyRemotingClient(nettyClientConfig, null, clientConfig.isShareThread());
    this.clientRemotingProcessor = clientRemotingProcessor;

    this.remotingClient.registerRPCHook(rpcHook);
    this.remotingClient.registerProcessor(RequestCode.CHECK_TRANSACTION_STATE, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_RUNNING_INFO, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.CONSUME_MESSAGE_DIRECTLY, this.clientRemotingProcessor, null);
}
 
Example #2
Source File: MQClientAPIImpl.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
public MQClientAPIImpl(final NettyClientConfig nettyClientConfig,
    final ClientRemotingProcessor clientRemotingProcessor,
    RPCHook rpcHook, final ClientConfig clientConfig) {
    this.clientConfig = clientConfig;
    topAddressing = new TopAddressing(MixAll.getWSAddr(), clientConfig.getUnitName());
    this.remotingClient = new NettyRemotingClient(nettyClientConfig, null, clientConfig.isShareThread());
    this.clientRemotingProcessor = clientRemotingProcessor;

    this.remotingClient.registerRPCHook(rpcHook);
    this.remotingClient.registerProcessor(RequestCode.CHECK_TRANSACTION_STATE, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_RUNNING_INFO, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.CONSUME_MESSAGE_DIRECTLY, this.clientRemotingProcessor, null);
}
 
Example #3
Source File: MQClientAPIImpl.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public MQClientAPIImpl(final NettyClientConfig nettyClientConfig, final ClientRemotingProcessor clientRemotingProcessor,
                       RPCHook rpcHook, final ClientConfig clientConfig) {
    this.clientConfig = clientConfig;
    topAddressing = new TopAddressing(MixAll.WS_ADDR, clientConfig.getUnitName());
    this.remotingClient = new NettyRemotingClient(nettyClientConfig, null);
    this.clientRemotingProcessor = clientRemotingProcessor;

    this.remotingClient.registerRPCHook(rpcHook);
    this.remotingClient.registerProcessor(RequestCode.CHECK_TRANSACTION_STATE, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_RUNNING_INFO, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.CONSUME_MESSAGE_DIRECTLY, this.clientRemotingProcessor, null);
}
 
Example #4
Source File: MQClientAPIImpl.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public MQClientAPIImpl(final NettyClientConfig nettyClientConfig,
    final ClientRemotingProcessor clientRemotingProcessor,
    RPCHook rpcHook, final ClientConfig clientConfig) {
    this.clientConfig = clientConfig;
    topAddressing = new TopAddressing(MixAll.getWSAddr(), clientConfig.getUnitName());
    this.remotingClient = new NettyRemotingClient(nettyClientConfig, null);
    this.clientRemotingProcessor = clientRemotingProcessor;

    this.remotingClient.registerRPCHook(rpcHook);
    this.remotingClient.registerProcessor(RequestCode.CHECK_TRANSACTION_STATE, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_RUNNING_INFO, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.CONSUME_MESSAGE_DIRECTLY, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.PUSH_REPLY_MESSAGE_TO_CLIENT, this.clientRemotingProcessor, null);
}
 
Example #5
Source File: MQClientAPIImpl.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
public MQClientAPIImpl(final NettyClientConfig nettyClientConfig,
    final ClientRemotingProcessor clientRemotingProcessor,
    RPCHook rpcHook, final ClientConfig clientConfig) {
    this.clientConfig = clientConfig;
    topAddressing = new TopAddressing(MixAll.getWSAddr(), clientConfig.getUnitName());
    this.remotingClient = new NettyRemotingClient(nettyClientConfig, null);
    this.clientRemotingProcessor = clientRemotingProcessor;

    this.remotingClient.registerRPCHook(rpcHook);
    this.remotingClient.registerProcessor(RequestCode.CHECK_TRANSACTION_STATE, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_RUNNING_INFO, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.CONSUME_MESSAGE_DIRECTLY, this.clientRemotingProcessor, null);
}
 
Example #6
Source File: MQClientAPIImpl.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
public MQClientAPIImpl(final NettyClientConfig nettyClientConfig, final ClientRemotingProcessor clientRemotingProcessor,
    RPCHook rpcHook, final ClientConfig clientConfig) {
    this.clientConfig = clientConfig;
    topAddressing = new TopAddressing(MixAll.getWSAddr(), clientConfig.getUnitName());
    this.remotingClient = new NettyRemotingClient(nettyClientConfig, null);
    this.clientRemotingProcessor = clientRemotingProcessor;

    this.remotingClient.registerRPCHook(rpcHook); 
    this.remotingClient.registerProcessor(RequestCode.CHECK_TRANSACTION_STATE, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_RUNNING_INFO, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.CONSUME_MESSAGE_DIRECTLY, this.clientRemotingProcessor, null);
}
 
Example #7
Source File: MQClientAPIImpl.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
public MQClientAPIImpl(final NettyClientConfig nettyClientConfig, final ClientRemotingProcessor clientRemotingProcessor,
    RPCHook rpcHook, final ClientConfig clientConfig) {
    this.clientConfig = clientConfig;
    topAddressing = new TopAddressing(MixAll.WS_ADDR, clientConfig.getUnitName());
    this.remotingClient = new NettyRemotingClient(nettyClientConfig, null);
    this.clientRemotingProcessor = clientRemotingProcessor;

    this.remotingClient.registerRPCHook(rpcHook);
    this.remotingClient.registerProcessor(RequestCode.CHECK_TRANSACTION_STATE, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_RUNNING_INFO, this.clientRemotingProcessor, null);

    this.remotingClient.registerProcessor(RequestCode.CONSUME_MESSAGE_DIRECTLY, this.clientRemotingProcessor, null);
}
 
Example #8
Source File: MQClientAPIImpl.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
/**
 * mqClientAPIImpl
 * @param nettyClientConfig nettyclient配置
 * @param clientRemotingProcessor 客户端远程实例
 * @param rpcHook rpcHook
 * @param clientConfig 客户端配置
 */
public MQClientAPIImpl(final NettyClientConfig nettyClientConfig,
    final ClientRemotingProcessor clientRemotingProcessor,
    RPCHook rpcHook, final ClientConfig clientConfig) {

    this.clientConfig = clientConfig;
    topAddressing = new TopAddressing(MixAll.getWSAddr(), clientConfig.getUnitName());
    this.remotingClient = new NettyRemotingClient(nettyClientConfig, null);
    this.clientRemotingProcessor = clientRemotingProcessor;

    //注册请求处理器
    this.remotingClient.registerRPCHook(rpcHook);
    this.remotingClient.registerProcessor(RequestCode.CHECK_TRANSACTION_STATE, this.clientRemotingProcessor, null);
    this.remotingClient.registerProcessor(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, this.clientRemotingProcessor, null);
    this.remotingClient.registerProcessor(RequestCode.RESET_CONSUMER_CLIENT_OFFSET, this.clientRemotingProcessor, null);
    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_STATUS_FROM_CLIENT, this.clientRemotingProcessor, null);
    this.remotingClient.registerProcessor(RequestCode.GET_CONSUMER_RUNNING_INFO, this.clientRemotingProcessor, null);
    this.remotingClient.registerProcessor(RequestCode.CONSUME_MESSAGE_DIRECTLY, this.clientRemotingProcessor, null);
}
 
Example #9
Source File: DefaultMQProducerTest.java    From rocketmq-read with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetCallbackExecutor() throws MQClientException {
    String producerGroupTemp = "testSetCallbackExecutor_" + System.currentTimeMillis();
    producer = new DefaultMQProducer(producerGroupTemp);
    producer.setNamesrvAddr("127.0.0.1:9876");
    producer.start();

    ExecutorService customized = Executors.newCachedThreadPool();
    producer.setCallbackExecutor(customized);

    NettyRemotingClient remotingClient = (NettyRemotingClient) producer.getDefaultMQProducerImpl()
        .getmQClientFactory().getMQClientAPIImpl().getRemotingClient();

    assertThat(remotingClient.getCallbackExecutor()).isEqualTo(customized);
}
 
Example #10
Source File: DefaultMQProducerTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetCallbackExecutor() throws MQClientException {
    String producerGroupTemp = producerGroupPrefix + System.currentTimeMillis();
    producer = new DefaultMQProducer(producerGroupTemp);
    producer.setNamesrvAddr("127.0.0.1:9876");
    producer.start();

    ExecutorService customized = Executors.newCachedThreadPool();
    producer.setCallbackExecutor(customized);

    NettyRemotingClient remotingClient = (NettyRemotingClient) producer.getDefaultMQProducerImpl()
        .getmQClientFactory().getMQClientAPIImpl().getRemotingClient();

    assertThat(remotingClient.getCallbackExecutor()).isEqualTo(customized);
}
 
Example #11
Source File: DLedgerRpcNettyService.java    From openmessaging-storage-dledger with Apache License 2.0 5 votes vote down vote up
public DLedgerRpcNettyService(DLedgerServer dLedgerServer) {
    this.dLedgerServer = dLedgerServer;
    this.memberState = dLedgerServer.getMemberState();
    NettyRequestProcessor protocolProcessor = new NettyRequestProcessor() {
        @Override
        public RemotingCommand processRequest(ChannelHandlerContext ctx, RemotingCommand request) throws Exception {
            return DLedgerRpcNettyService.this.processRequest(ctx, request);
        }

        @Override public boolean rejectRequest() {
            return false;
        }
    };
    //start the remoting server
    NettyServerConfig nettyServerConfig = new NettyServerConfig();
    nettyServerConfig.setListenPort(Integer.valueOf(memberState.getSelfAddr().split(":")[1]));
    this.remotingServer = new NettyRemotingServer(nettyServerConfig, null);
    this.remotingServer.registerProcessor(DLedgerRequestCode.METADATA.getCode(), protocolProcessor, null);
    this.remotingServer.registerProcessor(DLedgerRequestCode.APPEND.getCode(), protocolProcessor, null);
    this.remotingServer.registerProcessor(DLedgerRequestCode.GET.getCode(), protocolProcessor, null);
    this.remotingServer.registerProcessor(DLedgerRequestCode.PULL.getCode(), protocolProcessor, null);
    this.remotingServer.registerProcessor(DLedgerRequestCode.PUSH.getCode(), protocolProcessor, null);
    this.remotingServer.registerProcessor(DLedgerRequestCode.VOTE.getCode(), protocolProcessor, null);
    this.remotingServer.registerProcessor(DLedgerRequestCode.HEART_BEAT.getCode(), protocolProcessor, null);
    this.remotingServer.registerProcessor(DLedgerRequestCode.LEADERSHIP_TRANSFER.getCode(), protocolProcessor, null);

    //start the remoting client
    this.remotingClient = new NettyRemotingClient(new NettyClientConfig(), null);

}
 
Example #12
Source File: DefaultMQProducerTest.java    From rocketmq-4.3.0 with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetCallbackExecutor() throws MQClientException {
    String producerGroupTemp = "testSetCallbackExecutor_" + System.currentTimeMillis();
    producer = new DefaultMQProducer(producerGroupTemp);
    producer.setNamesrvAddr("127.0.0.1:9876");
    producer.start();

    ExecutorService customized = Executors.newCachedThreadPool();
    producer.setCallbackExecutor(customized);

    NettyRemotingClient remotingClient = (NettyRemotingClient) producer.getDefaultMQProducerImpl()
        .getmQClientFactory().getMQClientAPIImpl().getRemotingClient();

    assertThat(remotingClient.getCallbackExecutor()).isEqualTo(customized);
}
 
Example #13
Source File: DefaultMQProducerTest.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetCallbackExecutor() throws MQClientException {
    String producerGroupTemp = "testSetCallbackExecutor_" + System.currentTimeMillis();
    producer = new DefaultMQProducer(producerGroupTemp);
    producer.setNamesrvAddr("127.0.0.1:9876");
    producer.start();

    ExecutorService customized = Executors.newCachedThreadPool();
    producer.setCallbackExecutor(customized);

    NettyRemotingClient remotingClient = (NettyRemotingClient) producer.getDefaultMQProducerImpl()
        .getmQClientFactory().getMQClientAPIImpl().getRemotingClient();

    assertThat(remotingClient.getCallbackExecutor()).isEqualTo(customized);
}
 
Example #14
Source File: DefaultMQProducerTest.java    From DDMQ with Apache License 2.0 5 votes vote down vote up
@Test
public void testSetCallbackExecutor() throws MQClientException {
    String producerGroupTemp = producerGroupPrefix + System.currentTimeMillis();
    producer = new DefaultMQProducer(producerGroupTemp);
    producer.setNamesrvAddr("127.0.0.1:9876");
    producer.start();

    ExecutorService customized = Executors.newCachedThreadPool();
    producer.setCallbackExecutor(customized);

    NettyRemotingClient remotingClient = (NettyRemotingClient) producer.getDefaultMQProducerImpl()
        .getmQClientFactory().getMQClientAPIImpl().getRemotingClient();

    assertThat(remotingClient.getCallbackExecutor()).isEqualTo(customized);
}
 
Example #15
Source File: BrokerOuterAPI.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public BrokerOuterAPI(final NettyClientConfig nettyClientConfig, RPCHook rpcHook) {
    this.remotingClient = new NettyRemotingClient(nettyClientConfig);
    this.remotingClient.registerRPCHook(rpcHook);
}
 
Example #16
Source File: FilterServerOuterAPI.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
public FilterServerOuterAPI() {
    this.remotingClient = new NettyRemotingClient(new NettyClientConfig());
}
 
Example #17
Source File: BrokerOuterAPI.java    From rocketmq_trans_message with Apache License 2.0 4 votes vote down vote up
public BrokerOuterAPI(final NettyClientConfig nettyClientConfig, RPCHook rpcHook) {
    this.remotingClient = new NettyRemotingClient(nettyClientConfig);
    this.remotingClient.registerRPCHook(rpcHook);
}
 
Example #18
Source File: BrokerOuterAPI.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
public BrokerOuterAPI(final NettyClientConfig nettyClientConfig, RPCHook rpcHook) {
    this.remotingClient = new NettyRemotingClient(nettyClientConfig);
    this.remotingClient.registerRPCHook(rpcHook);
}
 
Example #19
Source File: FilterServerOuterAPI.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
public FilterServerOuterAPI() {
    this.remotingClient = new NettyRemotingClient(new NettyClientConfig());
}
 
Example #20
Source File: RemotingServerTest.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 4 votes vote down vote up
public static RemotingClient createRemotingClient() {
    NettyClientConfig config = new NettyClientConfig();
    RemotingClient client = new NettyRemotingClient(config);
    client.start();
    return client;
}
 
Example #21
Source File: BrokerOuterAPI.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public BrokerOuterAPI(final NettyClientConfig nettyClientConfig, RPCHook rpcHook) {
    this.remotingClient = new NettyRemotingClient(nettyClientConfig);
    this.remotingClient.registerRPCHook(rpcHook);
}
 
Example #22
Source File: RemotingServerTest.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public static RemotingClient createRemotingClient(NettyClientConfig nettyClientConfig) {
    RemotingClient client = new NettyRemotingClient(nettyClientConfig);
    client.start();
    return client;
}
 
Example #23
Source File: FilterServerOuterAPI.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public FilterServerOuterAPI() {
    this.remotingClient = new NettyRemotingClient(new NettyClientConfig());
}
 
Example #24
Source File: RemotingServerTest.java    From DDMQ with Apache License 2.0 4 votes vote down vote up
public static RemotingClient createRemotingClient(NettyClientConfig nettyClientConfig) {
    RemotingClient client = new NettyRemotingClient(nettyClientConfig);
    client.start();
    return client;
}
 
Example #25
Source File: BrokerOuterAPI.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public BrokerOuterAPI(final NettyClientConfig nettyClientConfig, RPCHook rpcHook) {
    this.remotingClient = new NettyRemotingClient(nettyClientConfig);
    this.remotingClient.registerRPCHook(rpcHook);
}
 
Example #26
Source File: FilterServerOuterAPI.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public FilterServerOuterAPI() {
    this.remotingClient = new NettyRemotingClient(new NettyClientConfig());
}
 
Example #27
Source File: RemotingServerTest.java    From rocketmq with Apache License 2.0 4 votes vote down vote up
public static RemotingClient createRemotingClient() {
    NettyClientConfig config = new NettyClientConfig();
    RemotingClient client = new NettyRemotingClient(config);
    client.start();
    return client;
}
 
Example #28
Source File: DLedgerClientRpcNettyService.java    From openmessaging-storage-dledger with Apache License 2.0 4 votes vote down vote up
public DLedgerClientRpcNettyService() {
    this.remotingClient = new NettyRemotingClient(new NettyClientConfig(), null);
}
 
Example #29
Source File: BrokerOuterAPI.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
public BrokerOuterAPI(final NettyClientConfig nettyClientConfig, RPCHook rpcHook) {
    this.remotingClient = new NettyRemotingClient(nettyClientConfig);
    this.remotingClient.registerRPCHook(rpcHook);
}
 
Example #30
Source File: RemotingServerTest.java    From rocketmq-read with Apache License 2.0 4 votes vote down vote up
public static RemotingClient createRemotingClient(NettyClientConfig nettyClientConfig) {
    RemotingClient client = new NettyRemotingClient(nettyClientConfig);
    client.start();
    return client;
}