Search in sources :

Example 1 with NotifyConsumerIdsChangedRequestHeader

use of org.apache.rocketmq.common.protocol.header.NotifyConsumerIdsChangedRequestHeader in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class ClientRemotingProcessor method notifyConsumerIdsChanged.

public RemotingCommand notifyConsumerIdsChanged(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    try {
        final NotifyConsumerIdsChangedRequestHeader requestHeader = (NotifyConsumerIdsChangedRequestHeader) request.decodeCommandCustomHeader(NotifyConsumerIdsChangedRequestHeader.class);
        log.info("receive broker's notification[{}], the consumer group: {} changed, rebalance immediately", RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getConsumerGroup());
        this.mqClientFactory.rebalanceImmediately();
    } catch (Exception e) {
        log.error("notifyConsumerIdsChanged exception", RemotingHelper.exceptionSimpleDesc(e));
    }
    return null;
}
Also used : NotifyConsumerIdsChangedRequestHeader(org.apache.rocketmq.common.protocol.header.NotifyConsumerIdsChangedRequestHeader) RemotingCommandException(org.apache.rocketmq.remoting.exception.RemotingCommandException)

Example 2 with NotifyConsumerIdsChangedRequestHeader

use of org.apache.rocketmq.common.protocol.header.NotifyConsumerIdsChangedRequestHeader in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.

the class Broker2Client method notifyConsumerIdsChanged.

/**
 * Broker主动通知Consumer,Id列表发生变化,Oneway
 */
public void notifyConsumerIdsChanged(final Channel channel, final String consumerGroup) {
    if (null == consumerGroup) {
        log.error("notifyConsumerIdsChanged consumerGroup is null");
        return;
    }
    NotifyConsumerIdsChangedRequestHeader requestHeader = new NotifyConsumerIdsChangedRequestHeader();
    requestHeader.setConsumerGroup(consumerGroup);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, requestHeader);
    try {
        this.brokerController.getRemotingServer().invokeOneway(channel, request, 10);
    } catch (Exception e) {
        log.error("notifyConsumerIdsChanged exception, " + consumerGroup, e.getMessage());
    }
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) NotifyConsumerIdsChangedRequestHeader(org.apache.rocketmq.common.protocol.header.NotifyConsumerIdsChangedRequestHeader) RemotingSendRequestException(org.apache.rocketmq.remoting.exception.RemotingSendRequestException) RemotingTimeoutException(org.apache.rocketmq.remoting.exception.RemotingTimeoutException)

Example 3 with NotifyConsumerIdsChangedRequestHeader

use of org.apache.rocketmq.common.protocol.header.NotifyConsumerIdsChangedRequestHeader in project rocketmq by apache.

the class Broker2Client method notifyConsumerIdsChanged.

public void notifyConsumerIdsChanged(final Channel channel, final String consumerGroup) {
    if (null == consumerGroup) {
        log.error("notifyConsumerIdsChanged consumerGroup is null");
        return;
    }
    NotifyConsumerIdsChangedRequestHeader requestHeader = new NotifyConsumerIdsChangedRequestHeader();
    requestHeader.setConsumerGroup(consumerGroup);
    RemotingCommand request = RemotingCommand.createRequestCommand(RequestCode.NOTIFY_CONSUMER_IDS_CHANGED, requestHeader);
    try {
        this.brokerController.getRemotingServer().invokeOneway(channel, request, 10);
    } catch (Exception e) {
        log.error("notifyConsumerIdsChanged exception, " + consumerGroup, e.getMessage());
    }
}
Also used : RemotingCommand(org.apache.rocketmq.remoting.protocol.RemotingCommand) NotifyConsumerIdsChangedRequestHeader(org.apache.rocketmq.common.protocol.header.NotifyConsumerIdsChangedRequestHeader) RemotingSendRequestException(org.apache.rocketmq.remoting.exception.RemotingSendRequestException) RemotingTimeoutException(org.apache.rocketmq.remoting.exception.RemotingTimeoutException)

Example 4 with NotifyConsumerIdsChangedRequestHeader

use of org.apache.rocketmq.common.protocol.header.NotifyConsumerIdsChangedRequestHeader in project rocketmq by apache.

the class ClientRemotingProcessor method notifyConsumerIdsChanged.

public RemotingCommand notifyConsumerIdsChanged(ChannelHandlerContext ctx, RemotingCommand request) throws RemotingCommandException {
    try {
        final NotifyConsumerIdsChangedRequestHeader requestHeader = (NotifyConsumerIdsChangedRequestHeader) request.decodeCommandCustomHeader(NotifyConsumerIdsChangedRequestHeader.class);
        log.info("receive broker's notification[{}], the consumer group: {} changed, rebalance immediately", RemotingHelper.parseChannelRemoteAddr(ctx.channel()), requestHeader.getConsumerGroup());
        this.mqClientFactory.rebalanceImmediately();
    } catch (Exception e) {
        log.error("notifyConsumerIdsChanged exception", RemotingHelper.exceptionSimpleDesc(e));
    }
    return null;
}
Also used : NotifyConsumerIdsChangedRequestHeader(org.apache.rocketmq.common.protocol.header.NotifyConsumerIdsChangedRequestHeader) RemotingCommandException(org.apache.rocketmq.remoting.exception.RemotingCommandException)

Aggregations

NotifyConsumerIdsChangedRequestHeader (org.apache.rocketmq.common.protocol.header.NotifyConsumerIdsChangedRequestHeader)4 RemotingCommandException (org.apache.rocketmq.remoting.exception.RemotingCommandException)2 RemotingSendRequestException (org.apache.rocketmq.remoting.exception.RemotingSendRequestException)2 RemotingTimeoutException (org.apache.rocketmq.remoting.exception.RemotingTimeoutException)2 RemotingCommand (org.apache.rocketmq.remoting.protocol.RemotingCommand)2