Java Code Examples for org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerRequestHeader#setBrokerAddr()

The following examples show how to use org.apache.rocketmq.common.protocol.header.namesrv.RegisterBrokerRequestHeader#setBrokerAddr() . 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: MQProtosHelper.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
public static boolean registerBrokerToNameServer(final String nsaddr, final String brokerAddr,
    final long timeoutMillis) {
    RegisterBrokerRequestHeader requestHeader = new RegisterBrokerRequestHeader();
    requestHeader.setBrokerAddr(brokerAddr);

    RemotingCommand request =
        RemotingCommand.createRequestCommand(RequestCode.REGISTER_BROKER, requestHeader);

    try {
        RemotingCommand response = RemotingHelper.invokeSync(nsaddr, request, timeoutMillis);
        if (response != null) {
            return ResponseCode.SUCCESS == response.getCode();
        }
    } catch (Exception e) {
        log.error("Failed to register broker", e);
    }

    return false;
}
 
Example 2
Source File: MQProtosHelper.java    From rocketmq-4.3.0 with Apache License 2.0 6 votes vote down vote up
public static boolean registerBrokerToNameServer(final String nsaddr, final String brokerAddr,
    final long timeoutMillis) {
    RegisterBrokerRequestHeader requestHeader = new RegisterBrokerRequestHeader();
    requestHeader.setBrokerAddr(brokerAddr);

    RemotingCommand request =
        RemotingCommand.createRequestCommand(RequestCode.REGISTER_BROKER, requestHeader);

    try {
        RemotingCommand response = RemotingHelper.invokeSync(nsaddr, request, timeoutMillis);
        if (response != null) {
            return ResponseCode.SUCCESS == response.getCode();
        }
    } catch (Exception e) {
        log.error("Failed to register broker", e);
    }

    return false;
}
 
Example 3
Source File: MQProtosHelper.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
public static boolean registerBrokerToNameServer(final String nsaddr, final String brokerAddr,
    final long timeoutMillis) {
    RegisterBrokerRequestHeader requestHeader = new RegisterBrokerRequestHeader();
    requestHeader.setBrokerAddr(brokerAddr);

    RemotingCommand request =
        RemotingCommand.createRequestCommand(RequestCode.REGISTER_BROKER, requestHeader);

    try {
        RemotingCommand response = RemotingHelper.invokeSync(nsaddr, request, timeoutMillis);
        if (response != null) {
            return ResponseCode.SUCCESS == response.getCode();
        }
    } catch (Exception e) {
        log.error("Failed to register broker", e);
    }

    return false;
}
 
Example 4
Source File: MQProtosHelper.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public static boolean registerBrokerToNameServer(final String nsaddr, final String brokerAddr,
    final long timeoutMillis) {
    RegisterBrokerRequestHeader requestHeader = new RegisterBrokerRequestHeader();
    requestHeader.setBrokerAddr(brokerAddr);

    RemotingCommand request =
        RemotingCommand.createRequestCommand(RequestCode.REGISTER_BROKER, requestHeader);

    try {
        RemotingCommand response = RemotingHelper.invokeSync(nsaddr, request, timeoutMillis);
        if (response != null) {
            return ResponseCode.SUCCESS == response.getCode();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return false;
}
 
Example 5
Source File: MQProtosHelper.java    From DDMQ with Apache License 2.0 6 votes vote down vote up
public static boolean registerBrokerToNameServer(final String nsaddr, final String brokerAddr,
    final long timeoutMillis) {
    RegisterBrokerRequestHeader requestHeader = new RegisterBrokerRequestHeader();
    requestHeader.setBrokerAddr(brokerAddr);

    RemotingCommand request =
        RemotingCommand.createRequestCommand(RequestCode.REGISTER_BROKER, requestHeader);

    try {
        RemotingCommand response = RemotingHelper.invokeSync(nsaddr, request, timeoutMillis);
        if (response != null) {
            return ResponseCode.SUCCESS == response.getCode();
        }
    } catch (Exception e) {
        log.error("Failed to register broker", e);
    }

    return false;
}
 
Example 6
Source File: MQProtosHelper.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 6 votes vote down vote up
public static boolean registerBrokerToNameServer(final String nsaddr, final String brokerAddr,
    final long timeoutMillis) {
    RegisterBrokerRequestHeader requestHeader = new RegisterBrokerRequestHeader();
    requestHeader.setBrokerAddr(brokerAddr);

    RemotingCommand request =
        RemotingCommand.createRequestCommand(RequestCode.REGISTER_BROKER, requestHeader);

    try {
        RemotingCommand response = RemotingHelper.invokeSync(nsaddr, request, timeoutMillis);
        if (response != null) {
            return ResponseCode.SUCCESS == response.getCode();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return false;
}
 
Example 7
Source File: MQProtosHelper.java    From rocketmq_trans_message with Apache License 2.0 6 votes vote down vote up
public static boolean registerBrokerToNameServer(final String nsaddr, final String brokerAddr,
    final long timeoutMillis) {
    RegisterBrokerRequestHeader requestHeader = new RegisterBrokerRequestHeader();
    requestHeader.setBrokerAddr(brokerAddr);

    RemotingCommand request =
        RemotingCommand.createRequestCommand(RequestCode.REGISTER_BROKER, requestHeader);

    try {
        RemotingCommand response = RemotingHelper.invokeSync(nsaddr, request, timeoutMillis);
        if (response != null) {
            return ResponseCode.SUCCESS == response.getCode();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return false;
}
 
Example 8
Source File: MQProtosHelper.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public static boolean registerBrokerToNameServer(final String nsaddr, final String brokerAddr,
    final long timeoutMillis) {
    RegisterBrokerRequestHeader requestHeader = new RegisterBrokerRequestHeader();
    requestHeader.setBrokerAddr(brokerAddr);

    RemotingCommand request =
        RemotingCommand.createRequestCommand(RequestCode.REGISTER_BROKER, requestHeader);

    try {
        RemotingCommand response = RemotingHelper.invokeSync(nsaddr, request, timeoutMillis);
        if (response != null) {
            return ResponseCode.SUCCESS == response.getCode();
        }
    } catch (Exception e) {
        log.error("Failed to register broker", e);
    }

    return false;
}