Java Code Examples for com.alibaba.rocketmq.common.ServiceState#SHUTDOWN_ALREADY

The following examples show how to use com.alibaba.rocketmq.common.ServiceState#SHUTDOWN_ALREADY . 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: DefaultMQProducerImpl.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
public void shutdown(final boolean shutdownFactory) {
    switch (this.serviceState) {
    case CREATE_JUST:
        break;
    case RUNNING:
        this.mQClientFactory.unregisterProducer(this.defaultMQProducer.getProducerGroup());
        if (shutdownFactory) {
            this.mQClientFactory.shutdown();
        }

        log.info("the producer [{}] shutdown OK", this.defaultMQProducer.getProducerGroup());
        this.serviceState = ServiceState.SHUTDOWN_ALREADY;
        break;
    case SHUTDOWN_ALREADY:
        break;
    default:
        break;
    }
}
 
Example 2
Source File: DefaultMQPushConsumerImpl.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
public void shutdown() {
    switch (this.serviceState) {
    case CREATE_JUST:
        break;
    case RUNNING:
        this.consumeMessageService.shutdown();
        this.persistConsumerOffset();
        this.mQClientFactory.unregisterConsumer(this.defaultMQPushConsumer.getConsumerGroup());
        this.mQClientFactory.shutdown();
        log.info("the consumer [{}] shutdown OK", this.defaultMQPushConsumer.getConsumerGroup());
        this.rebalanceImpl.destroy();
        this.serviceState = ServiceState.SHUTDOWN_ALREADY;
        break;
    case SHUTDOWN_ALREADY:
        break;
    default:
        break;
    }
}
 
Example 3
Source File: DefaultMQAdminExtImpl.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void shutdown() {
    switch (this.serviceState) {
    case CREATE_JUST:
        break;
    case RUNNING:
        this.mqClientInstance.unregisterAdminExt(this.defaultMQAdminExt.getAdminExtGroup());
        this.mqClientInstance.shutdown();

        log.info("the adminExt [{}] shutdown OK", this.defaultMQAdminExt.getAdminExtGroup());
        this.serviceState = ServiceState.SHUTDOWN_ALREADY;
        break;
    case SHUTDOWN_ALREADY:
        break;
    default:
        break;
    }
}
 
Example 4
Source File: DefaultMQProducerImpl.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public void shutdown(final boolean shutdownFactory) {
    switch (this.serviceState) {
        case CREATE_JUST:
            break;
        case RUNNING:
            this.mQClientFactory.unregisterProducer(this.defaultMQProducer.getProducerGroup());
            if (shutdownFactory) {
                this.mQClientFactory.shutdown();
            }

            log.info("the producer [{}] shutdown OK", this.defaultMQProducer.getProducerGroup());
            this.serviceState = ServiceState.SHUTDOWN_ALREADY;
            break;
        case SHUTDOWN_ALREADY:
            break;
        default:
            break;
    }
}
 
Example 5
Source File: DefaultMQPushConsumerImpl.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public void shutdown() {
    switch (this.serviceState) {
        case CREATE_JUST:
            break;
        case RUNNING:
            this.consumeMessageService.shutdown();
            this.persistConsumerOffset();
            this.mQClientFactory.unregisterConsumer(this.defaultMQPushConsumer.getConsumerGroup());
            this.mQClientFactory.shutdown();
            log.info("the consumer [{}] shutdown OK", this.defaultMQPushConsumer.getConsumerGroup());
            this.rebalanceImpl.destroy();
            this.serviceState = ServiceState.SHUTDOWN_ALREADY;
            break;
        case SHUTDOWN_ALREADY:
            break;
        default:
            break;
    }
}
 
Example 6
Source File: DefaultMQPullConsumerImpl.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
public void shutdown() {
    switch (this.serviceState) {
        case CREATE_JUST:
            break;
        case RUNNING:
            this.persistConsumerOffset();
            this.mQClientFactory.unregisterConsumer(this.defaultMQPullConsumer.getConsumerGroup());
            this.mQClientFactory.shutdown();
            log.info("the consumer [{}] shutdown OK", this.defaultMQPullConsumer.getConsumerGroup());
            this.serviceState = ServiceState.SHUTDOWN_ALREADY;
            break;
        case SHUTDOWN_ALREADY:
            break;
        default:
            break;
    }
}
 
Example 7
Source File: DefaultMQAdminExtImpl.java    From rocketmq with Apache License 2.0 6 votes vote down vote up
@Override
public void shutdown() {
    switch (this.serviceState) {
        case CREATE_JUST:
            break;
        case RUNNING:
            this.mqClientInstance.unregisterAdminExt(this.defaultMQAdminExt.getAdminExtGroup());
            this.mqClientInstance.shutdown();

            log.info("the adminExt [{}] shutdown OK", this.defaultMQAdminExt.getAdminExtGroup());
            this.serviceState = ServiceState.SHUTDOWN_ALREADY;
            break;
        case SHUTDOWN_ALREADY:
            break;
        default:
            break;
    }
}
 
Example 8
Source File: DefaultMQProducerImpl.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
public void shutdown(final boolean shutdownFactory) {
    switch (this.serviceState) {
    case CREATE_JUST:
        break;
    case RUNNING:
        this.mQClientFactory.unregisterProducer(this.defaultMQProducer.getProducerGroup());
        if (shutdownFactory) {
            this.mQClientFactory.shutdown();
        }

        log.info("the producer [{}] shutdown OK", this.defaultMQProducer.getProducerGroup());
        this.serviceState = ServiceState.SHUTDOWN_ALREADY;
        break;
    case SHUTDOWN_ALREADY:
        break;
    default:
        break;
    }
}
 
Example 9
Source File: DefaultMQPushConsumerImpl.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
public void shutdown() {
    switch (this.serviceState) {
    case CREATE_JUST:
        break;
    case RUNNING:
        this.consumeMessageService.shutdown();
        this.persistConsumerOffset();
        this.mQClientFactory.unregisterConsumer(this.defaultMQPushConsumer.getConsumerGroup());
        this.mQClientFactory.shutdown();
        log.info("the consumer [{}] shutdown OK", this.defaultMQPushConsumer.getConsumerGroup());
        this.rebalanceImpl.destroy();
        this.serviceState = ServiceState.SHUTDOWN_ALREADY;
        break;
    case SHUTDOWN_ALREADY:
        break;
    default:
        break;
    }
}
 
Example 10
Source File: DefaultMQPullConsumerImpl.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
public void shutdown() {
    switch (this.serviceState) {
    case CREATE_JUST:
        break;
    case RUNNING:
        this.persistConsumerOffset();
        this.mQClientFactory.unregisterConsumer(this.defaultMQPullConsumer.getConsumerGroup());
        this.mQClientFactory.shutdown();
        log.info("the consumer [{}] shutdown OK", this.defaultMQPullConsumer.getConsumerGroup());
        this.serviceState = ServiceState.SHUTDOWN_ALREADY;
        break;
    case SHUTDOWN_ALREADY:
        break;
    default:
        break;
    }
}
 
Example 11
Source File: DefaultMQAdminExtImpl.java    From RocketMQ-Master-analyze with Apache License 2.0 6 votes vote down vote up
@Override
public void shutdown() {
    switch (this.serviceState) {
    case CREATE_JUST:
        break;
    case RUNNING:
        this.mqClientInstance.unregisterAdminExt(this.defaultMQAdminExt.getAdminExtGroup());
        this.mqClientInstance.shutdown();

        log.info("the adminExt [{}] shutdown OK", this.defaultMQAdminExt.getAdminExtGroup());
        this.serviceState = ServiceState.SHUTDOWN_ALREADY;
        break;
    case SHUTDOWN_ALREADY:
        break;
    default:
        break;
    }
}
 
Example 12
Source File: DefaultMQPullConsumerImpl.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public void shutdown() {
    switch (this.serviceState) {
        case CREATE_JUST:
            break;
        case RUNNING:
            this.persistConsumerOffset();
            /* 如果是生产者,断开连接后会注销producer,抓包如下:
             *客户端向broker发送注销 yyzGroup2 消费分组请求
             * ........{"code":35,"extFields":{"clientID":"192.168.56.1@7644","producerGroup":"yyzGroup2"},"flag":0,
             * "language":"JAVA","opaque":12,"serializeTypeCurrentRPC":"JSON","version":115}
             * broker会有注销成功
             * ...s...o{"code":0,"extFields":{},"flag":1,"language":"JAVA","opaque":12,"serializeTypeCurrentRPC":"JSON","version":115}
             *
             *客户端向broker发送注销 CLIENT_INNER_PRODUCER 消费分组请求
             * ........{"code":35,"extFields":{"clientID":"192.168.56.1@7644","producerGroup":"CLIENT_INNER_PRODUCER"},"flag":0,"
             * language":"JAVA","opaque":20,"serializeTypeCurrentRPC":"JSON","version":115}
             *
             * broker会有注销成功
             * ...s...o{"code":0,"extFields":{},"flag":1,"language":"JAVA","opaque":20,"serializeTypeCurrentRPC":"JSON","version":115}
              * */
            this.mQClientFactory.unregisterConsumer(this.defaultMQPullConsumer.getConsumerGroup());
            this.mQClientFactory.shutdown();
            log.info("the consumer [{}] shutdown OK", this.defaultMQPullConsumer.getConsumerGroup());
            this.serviceState = ServiceState.SHUTDOWN_ALREADY;
            break;
        case SHUTDOWN_ALREADY:
            break;
        default:
            break;
    }
}
 
Example 13
Source File: MQClientInstance.java    From reading-and-annotate-rocketmq-3.4.6 with GNU General Public License v3.0 5 votes vote down vote up
public void shutdown() {
    // Consumer
    if (!this.consumerTable.isEmpty())
        return;

    // AdminExt
    if (!this.adminExtTable.isEmpty())
        return;

    // Producer
    if (this.producerTable.size() > 1)
        return;

    synchronized (this) {
        switch (this.serviceState) {
        case CREATE_JUST:
            break;
        case RUNNING:
            this.defaultMQProducer.getDefaultMQProducerImpl().shutdown(false);

            this.serviceState = ServiceState.SHUTDOWN_ALREADY;
            this.pullMessageService.shutdown(true);
            this.scheduledExecutorService.shutdown();
            this.mQClientAPIImpl.shutdown();
            this.rebalanceService.shutdown();

            if (this.datagramSocket != null) {
                this.datagramSocket.close();
                this.datagramSocket = null;
            }
            MQClientManager.getInstance().removeClientFactory(this.clientId);
            log.info("the client factory [{}] shutdown OK", this.clientId);
            break;
        case SHUTDOWN_ALREADY:
            break;
        default:
            break;
        }
    }
}
 
Example 14
Source File: MQClientInstance.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public void shutdown() {
    // Consumer
    if (!this.consumerTable.isEmpty())
        return;

    // AdminExt
    if (!this.adminExtTable.isEmpty())
        return;

    // Producer
    if (this.producerTable.size() > 1)
        return;

    synchronized (this) {
        switch (this.serviceState) {
            case CREATE_JUST:
                break;
            case RUNNING:
                this.defaultMQProducer.getDefaultMQProducerImpl().shutdown(false);

                this.serviceState = ServiceState.SHUTDOWN_ALREADY;
                this.pullMessageService.shutdown(true);
                this.scheduledExecutorService.shutdown();
                this.mQClientAPIImpl.shutdown();
                this.rebalanceService.shutdown();

                if (this.datagramSocket != null) {
                    this.datagramSocket.close();
                    this.datagramSocket = null;
                }
                MQClientManager.getInstance().removeClientFactory(this.clientId);
                log.info("the client factory [{}] shutdown OK", this.clientId);
                break;
            case SHUTDOWN_ALREADY:
                break;
            default:
                break;
        }
    }
}
 
Example 15
Source File: MQClientInstance.java    From RocketMQ-Master-analyze with Apache License 2.0 5 votes vote down vote up
public void shutdown() {
    // Consumer
    if (!this.consumerTable.isEmpty())
        return;

    // AdminExt
    if (!this.adminExtTable.isEmpty())
        return;

    // Producer
    if (this.producerTable.size() > 1)
        return;

    synchronized (this) {
        switch (this.serviceState) {
            case CREATE_JUST:
                break;
            case RUNNING:
                this.defaultMQProducer.getDefaultMQProducerImpl().shutdown(false);

                this.serviceState = ServiceState.SHUTDOWN_ALREADY;
                this.pullMessageService.shutdown(true);
                this.scheduledExecutorService.shutdown();
                this.mQClientAPIImpl.shutdown();
                this.rebalanceService.shutdown();

                if (this.datagramSocket != null) {
                    this.datagramSocket.close();
                    this.datagramSocket = null;
                }
                MQClientManager.getInstance().removeClientFactory(this.clientId);
                log.info("the client factory [{}] shutdown OK", this.clientId);
                break;
            case SHUTDOWN_ALREADY:
                break;
            default:
                break;
        }
    }
}