Java Code Examples for org.apache.rocketmq.common.ThreadFactoryImpl

The following examples show how to use org.apache.rocketmq.common.ThreadFactoryImpl. These examples are extracted from open source projects. 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 Project: DDMQ   Source File: ConsumeMessageConcurrentlyService.java    License: Apache License 2.0 6 votes vote down vote up
public ConsumeMessageConcurrentlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
    MessageListenerConcurrently messageListener) {
    this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
    this.messageListener = messageListener;

    this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
    this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
    this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

    this.consumeExecutor = new ThreadPoolExecutor(
        this.defaultMQPushConsumer.getConsumeThreadMin(),
        this.defaultMQPushConsumer.getConsumeThreadMax(),
        1000 * 60,
        TimeUnit.MILLISECONDS,
        this.consumeRequestQueue,
        new ThreadFactoryImpl("ConsumeMessageThread_"));

    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
    this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("CleanExpireMsgScheduledThread_"));
}
 
Example 2
public ConsumeMessageOrderlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
        MessageListenerOrderly messageListener) {
        this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
        this.messageListener = messageListener;

        this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
        this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
//        阻塞队列保证异步监听是有序的
        this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

        this.consumeExecutor = new ThreadPoolExecutor(
            this.defaultMQPushConsumer.getConsumeThreadMin(),
            this.defaultMQPushConsumer.getConsumeThreadMax(),
            1000 * 60,
            TimeUnit.MILLISECONDS,
            this.consumeRequestQueue,
            new ThreadFactoryImpl("ConsumeMessageThread_"));

        this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
    }
 
Example 3
public ConsumeMessageConcurrentlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
    MessageListenerConcurrently messageListener) {
    this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
    this.messageListener = messageListener;

    this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
    this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
    this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

    this.consumeExecutor = new ThreadPoolExecutor(
        this.defaultMQPushConsumer.getConsumeThreadMin(),
        this.defaultMQPushConsumer.getConsumeThreadMax(),
        1000 * 60,
        TimeUnit.MILLISECONDS,
        this.consumeRequestQueue,
        new ThreadFactoryImpl("ConsumeMessageThread_"));

    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
    this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("CleanExpireMsgScheduledThread_"));
}
 
Example 4
/**
 * 构造顺序消费的Service
 * @param defaultMQPushConsumerImpl ;
 * @param messageListener ;
 */
public ConsumeMessageOrderlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
    MessageListenerOrderly messageListener) {

    this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
    this.messageListener = messageListener;

    this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
    this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
    this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

    //消费线程池
    this.consumeExecutor = new ThreadPoolExecutor(
        this.defaultMQPushConsumer.getConsumeThreadMin(),
        this.defaultMQPushConsumer.getConsumeThreadMax(),
        1000 * 60,
        TimeUnit.MILLISECONDS,
        this.consumeRequestQueue,
        new ThreadFactoryImpl("ConsumeMessageThread_"));
    //调度线程池
    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
}
 
Example 5
public ConsumeMessageConcurrentlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
    MessageListenerConcurrently messageListener) {
    this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
    this.messageListener = messageListener;

    this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
    this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
    this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

    /*
     * 消费线程池
     */
    this.consumeExecutor = new ThreadPoolExecutor(
        this.defaultMQPushConsumer.getConsumeThreadMin(),
        this.defaultMQPushConsumer.getConsumeThreadMax(),
        1000 * 60,
        TimeUnit.MILLISECONDS,
        this.consumeRequestQueue,
        new ThreadFactoryImpl("ConsumeMessageThread_"));

    //两个单线程线程池
    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
    this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("CleanExpireMsgScheduledThread_"));
}
 
Example 6
Source Project: rocketmq   Source File: ConsumeMessageOrderlyService.java    License: Apache License 2.0 6 votes vote down vote up
public ConsumeMessageOrderlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl, MessageListenerOrderly messageListener) {
    this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
    this.messageListener = messageListener;

    this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
    this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
    this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

    this.consumeExecutor = new ThreadPoolExecutor(//
        this.defaultMQPushConsumer.getConsumeThreadMin(), //
        this.defaultMQPushConsumer.getConsumeThreadMax(), //
        1000 * 60, //
        TimeUnit.MILLISECONDS, //
        this.consumeRequestQueue, //
        new ThreadFactoryImpl("ConsumeMessageThread_"));

    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
}
 
Example 7
public ConsumeMessageConcurrentlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
                                         MessageListenerConcurrently messageListener) {
    this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
    this.messageListener = messageListener;

    this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
    this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
    this.consumeRequestQueue = new LinkedBlockingQueue<>();

    this.consumeExecutor = new ThreadPoolExecutor(//
        this.defaultMQPushConsumer.getConsumeThreadMin(), //
        this.defaultMQPushConsumer.getConsumeThreadMax(), //
        1000 * 60, //
        TimeUnit.MILLISECONDS, //
        this.consumeRequestQueue, //
        new ThreadFactoryImpl("ConsumeMessageThread_"));

    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
    this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("CleanExpireMsgScheduledThread_"));
}
 
Example 8
Source Project: DDMQ   Source File: ConsumeMessageConcurrentlyService.java    License: Apache License 2.0 6 votes vote down vote up
public ConsumeMessageConcurrentlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
    MessageListenerConcurrently messageListener) {
    this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
    this.messageListener = messageListener;

    this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
    this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
    this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

    this.consumeExecutor = new ThreadPoolExecutor(
        this.defaultMQPushConsumer.getConsumeThreadMin(),
        this.defaultMQPushConsumer.getConsumeThreadMax(),
        1000 * 60,
        TimeUnit.MILLISECONDS,
        this.consumeRequestQueue,
        new ThreadFactoryImpl("ConsumeMessageThread_"));

    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
    this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("CleanExpireMsgScheduledThread_"));
}
 
Example 9
public ConsumeMessageOrderlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl, MessageListenerOrderly messageListener) {
    this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
    this.messageListener = messageListener;

    this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
    this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
    this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

    this.consumeExecutor = new ThreadPoolExecutor(//
        this.defaultMQPushConsumer.getConsumeThreadMin(), //
        this.defaultMQPushConsumer.getConsumeThreadMax(), //
        1000 * 60, //
        TimeUnit.MILLISECONDS, //
        this.consumeRequestQueue, //
        new ThreadFactoryImpl("ConsumeMessageThread_"));

    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
}
 
Example 10
public ConsumeMessageConcurrentlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
    MessageListenerConcurrently messageListener) {
    this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
    this.messageListener = messageListener;

    this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
    this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
    this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

    this.consumeExecutor = new ThreadPoolExecutor(//
        this.defaultMQPushConsumer.getConsumeThreadMin(), //
        this.defaultMQPushConsumer.getConsumeThreadMax(), //
        1000 * 60, //
        TimeUnit.MILLISECONDS, //
        this.consumeRequestQueue, //
        new ThreadFactoryImpl("ConsumeMessageThread_"));

    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
    this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("CleanExpireMsgScheduledThread_"));
}
 
Example 11
public ConsumeMessageOrderlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl, MessageListenerOrderly messageListener) {
    this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
    this.messageListener = messageListener;

    this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
    this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
    this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

    this.consumeExecutor = new ThreadPoolExecutor(//
        this.defaultMQPushConsumer.getConsumeThreadMin(), //
        this.defaultMQPushConsumer.getConsumeThreadMax(), //
        1000 * 60, //
        TimeUnit.MILLISECONDS, //
        this.consumeRequestQueue, //
        new ThreadFactoryImpl("ConsumeMessageThread_"));

    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
}
 
Example 12
public ConsumeMessageConcurrentlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
    MessageListenerConcurrently messageListener) {
    this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
    this.messageListener = messageListener;

    this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
    this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
    this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

    this.consumeExecutor = new ThreadPoolExecutor(//
        this.defaultMQPushConsumer.getConsumeThreadMin(), //
        this.defaultMQPushConsumer.getConsumeThreadMax(), //
        1000 * 60, //
        TimeUnit.MILLISECONDS, //
        this.consumeRequestQueue, //
        new ThreadFactoryImpl("ConsumeMessageThread_"));

    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
    this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("CleanExpireMsgScheduledThread_"));
}
 
Example 13
Source Project: rocketmq   Source File: AsyncTraceDispatcher.java    License: Apache License 2.0 6 votes vote down vote up
public AsyncTraceDispatcher(String group, Type type,String traceTopicName, RPCHook rpcHook) {
    // queueSize is greater than or equal to the n power of 2 of value
    this.queueSize = 2048;
    this.batchSize = 100;
    this.maxMsgSize = 128000;
    this.discardCount = new AtomicLong(0L);
    this.traceContextQueue = new ArrayBlockingQueue<TraceContext>(1024);
    this.group = group;
    this.type = type;

    this.appenderQueue = new ArrayBlockingQueue<Runnable>(queueSize);
    if (!UtilAll.isBlank(traceTopicName)) {
        this.traceTopicName = traceTopicName;
    } else {
        this.traceTopicName = TopicValidator.RMQ_SYS_TRACE_TOPIC;
    }
    this.traceExecutor = new ThreadPoolExecutor(//
        10, //
        20, //
        1000 * 60, //
        TimeUnit.MILLISECONDS, //
        this.appenderQueue, //
        new ThreadFactoryImpl("MQTraceSendThread_"));
    traceProducer = getAndCreateTraceProducer(rpcHook);
}
 
Example 14
Source Project: rocketmq   Source File: ConsumeMessageOrderlyService.java    License: Apache License 2.0 6 votes vote down vote up
public ConsumeMessageOrderlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
    MessageListenerOrderly messageListener) {
    this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
    this.messageListener = messageListener;

    this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
    this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
    this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

    this.consumeExecutor = new ThreadPoolExecutor(
        this.defaultMQPushConsumer.getConsumeThreadMin(),
        this.defaultMQPushConsumer.getConsumeThreadMax(),
        1000 * 60,
        TimeUnit.MILLISECONDS,
        this.consumeRequestQueue,
        new ThreadFactoryImpl("ConsumeMessageThread_"));

    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
}
 
Example 15
public ConsumeMessageConcurrentlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
    MessageListenerConcurrently messageListener) {
    this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
    this.messageListener = messageListener;

    this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
    this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
    this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

    this.consumeExecutor = new ThreadPoolExecutor(
        this.defaultMQPushConsumer.getConsumeThreadMin(),
        this.defaultMQPushConsumer.getConsumeThreadMax(),
        1000 * 60,
        TimeUnit.MILLISECONDS,
        this.consumeRequestQueue,
        new ThreadFactoryImpl("ConsumeMessageThread_"));

    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_"));
    this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("CleanExpireMsgScheduledThread_"));
}
 
Example 16
Source Project: rocketmq   Source File: StatsItemSetTest.java    License: Apache License 2.0 6 votes vote down vote up
private AtomicLong test_unit() throws InterruptedException {
    final StatsItemSet statsItemSet = new StatsItemSet("topicTest", scheduler, null);
    executor = new ThreadPoolExecutor(10, 20, 10, TimeUnit.SECONDS,
        new ArrayBlockingQueue<Runnable>(100), new ThreadFactoryImpl("testMultiThread"));
    for (int i = 0; i < 10; i++) {
        executor.submit(new Runnable() {
            @Override
            public void run() {
                statsItemSet.addValue("topicTest", 2, 1);
            }
        });
    }
    while (true) {
        if (executor.getCompletedTaskCount() == 10) {
            break;
        }
        Thread.sleep(1000);
    }
    return statsItemSet.getStatsItem("topicTest").getValue();
}
 
Example 17
Source Project: rocketmq   Source File: StatsItemSetTest.java    License: Apache License 2.0 6 votes vote down vote up
private AtomicLong test_unit_moment() throws InterruptedException {
    final MomentStatsItemSet statsItemSet = new MomentStatsItemSet("topicTest", scheduler, null);
    executor = new ThreadPoolExecutor(10, 20, 10, TimeUnit.SECONDS,
        new ArrayBlockingQueue<Runnable>(100), new ThreadFactoryImpl("testMultiThread"));
    for (int i = 0; i < 10; i++) {
        executor.submit(new Runnable() {
            @Override
            public void run() {
                statsItemSet.setValue("test", 10);
            }
        });
    }
    while (true) {
        if (executor.getCompletedTaskCount() == 10) {
            break;
        }
        Thread.sleep(1000);
    }
    return statsItemSet.getAndCreateStatsItem("test").getValue();
}
 
Example 18
Source Project: DDMQ   Source File: LocalMessageCache.java    License: Apache License 2.0 5 votes vote down vote up
LocalMessageCache(final DefaultMQPullConsumer rocketmqPullConsumer, final ClientConfig clientConfig) {
    consumeRequestCache = new LinkedBlockingQueue<>(clientConfig.getRmqPullMessageCacheCapacity());
    this.consumedRequest = new ConcurrentHashMap<>();
    this.pullOffsetTable = new ConcurrentHashMap<>();
    this.rocketmqPullConsumer = rocketmqPullConsumer;
    this.clientConfig = clientConfig;
    this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
        "OMS_CleanExpireMsgScheduledThread_"));
}
 
Example 19
Source Project: DDMQ   Source File: FiltersrvController.java    License: Apache License 2.0 5 votes vote down vote up
public boolean initialize() {

        MixAll.printObjectProperties(log, this.filtersrvConfig);

        this.remotingServer = new NettyRemotingServer(this.nettyServerConfig);

        this.remotingExecutor =
            Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(),
                new ThreadFactoryImpl("RemotingExecutorThread_"));

        this.registerProcessor();

        this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {

            @Override
            public void run() {
                FiltersrvController.this.registerFilterServerToBroker();
            }
        }, 3, 10, TimeUnit.SECONDS);

        this.defaultMQPullConsumer.setBrokerSuspendMaxTimeMillis(this.defaultMQPullConsumer
            .getBrokerSuspendMaxTimeMillis() - 1000);
        this.defaultMQPullConsumer.setConsumerTimeoutMillisWhenSuspend(this.defaultMQPullConsumer
            .getConsumerTimeoutMillisWhenSuspend() - 1000);

        this.defaultMQPullConsumer.setNamesrvAddr(this.filtersrvConfig.getNamesrvAddr());
        this.defaultMQPullConsumer.setInstanceName(String.valueOf(UtilAll.getPid()));

        return true;
    }
 
Example 20
Source Project: DDMQ   Source File: MQPullConsumerScheduleService.java    License: Apache License 2.0 5 votes vote down vote up
public void start() throws MQClientException {
    final String group = this.defaultMQPullConsumer.getConsumerGroup();
    this.scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(
        this.pullThreadNums,
        new ThreadFactoryImpl("PullMsgThread-" + group)
    );

    this.defaultMQPullConsumer.setMessageQueueListener(this.messageQueueListener);

    this.defaultMQPullConsumer.start();

    log.info("MQPullConsumerScheduleService start OK, {} {}",
        this.defaultMQPullConsumer.getConsumerGroup(), this.callbackTable);
}
 
Example 21
Source Project: DDMQ   Source File: ConsumeMessageOrderlyService.java    License: Apache License 2.0 5 votes vote down vote up
public ConsumeMessageOrderlyService(DefaultMQPushConsumerImpl defaultMQPushConsumerImpl,
    MessageListenerOrderly messageListener) {
    this.defaultMQPushConsumerImpl = defaultMQPushConsumerImpl;
    this.messageListener = messageListener;

    this.defaultMQPushConsumer = this.defaultMQPushConsumerImpl.getDefaultMQPushConsumer();
    this.consumerGroup = this.defaultMQPushConsumer.getConsumerGroup();
    this.consumeRequestQueue = new LinkedBlockingQueue<Runnable>();

    if (this.defaultMQPushConsumer.getSharedThreadPoolExecutor() == null) {
        this.consumeExecutor = new ThreadPoolExecutor(
                this.defaultMQPushConsumer.getConsumeThreadMin(),
                this.defaultMQPushConsumer.getConsumeThreadMax(),
                1000 * 60,
                TimeUnit.MILLISECONDS,
                this.consumeRequestQueue,
                new ThreadFactoryImpl("ConsumeMessageThread_" + consumerGroup + "_"));
    } else {
        this.consumeExecutor = this.defaultMQPushConsumer.getSharedThreadPoolExecutor();
    }

    if (this.defaultMQPushConsumer.getSharedScheduledExecutorService() == null) {
        this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(
                new ThreadFactoryImpl("ConsumeMessageScheduledThread_" + consumerGroup + "_"));
    } else {
        this.scheduledExecutorService = this.defaultMQPushConsumer.getSharedScheduledExecutorService();
    }
}
 
Example 22
Source Project: DDMQ   Source File: NamesrvController.java    License: Apache License 2.0 5 votes vote down vote up
public boolean initialize() {
    if (namesrvConfig.isRoleSwitchEnable()) {
        haManager = new HAManager(this);
    }
    routeInfoManager.setHaManager(haManager);

    this.kvConfigManager.load();

    this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.brokerHousekeepingService);

    this.remotingExecutor =
        Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_"));

    this.registerProcessor();

    this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {

        @Override
        public void run() {
            NamesrvController.this.routeInfoManager.scanNotActiveBroker();
        }
    }, 5, 10, TimeUnit.SECONDS);

    this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {

        @Override
        public void run() {
            NamesrvController.this.kvConfigManager.printAllPeriodically();
        }
    }, 1, 10, TimeUnit.MINUTES);

    return true;
}
 
Example 23
Source Project: rocketmq-4.3.0   Source File: LocalMessageCache.java    License: Apache License 2.0 5 votes vote down vote up
LocalMessageCache(final DefaultMQPullConsumer rocketmqPullConsumer, final ClientConfig clientConfig) {
    consumeRequestCache = new LinkedBlockingQueue<>(clientConfig.getRmqPullMessageCacheCapacity());
    this.consumedRequest = new ConcurrentHashMap<>();
    this.pullOffsetTable = new ConcurrentHashMap<>();
    this.rocketmqPullConsumer = rocketmqPullConsumer;
    this.clientConfig = clientConfig;
    this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
        "OMS_CleanExpireMsgScheduledThread_"));
}
 
Example 24
public void start() throws MQClientException {
    final String group = this.defaultMQPullConsumer.getConsumerGroup();
    this.scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(
        this.pullThreadNums,
        new ThreadFactoryImpl("PullMsgThread-" + group)
    );

    this.defaultMQPullConsumer.setMessageQueueListener(this.messageQueueListener);

    this.defaultMQPullConsumer.start();

    log.info("MQPullConsumerScheduleService start OK, {} {}",
        this.defaultMQPullConsumer.getConsumerGroup(), this.callbackTable);
}
 
Example 25
Source Project: rocketmq-read   Source File: LocalMessageCache.java    License: Apache License 2.0 5 votes vote down vote up
LocalMessageCache(final DefaultMQPullConsumer rocketmqPullConsumer, final ClientConfig clientConfig) {
    consumeRequestCache = new LinkedBlockingQueue<>(clientConfig.getRmqPullMessageCacheCapacity());
    this.consumedRequest = new ConcurrentHashMap<>();
    this.pullOffsetTable = new ConcurrentHashMap<>();
    this.rocketmqPullConsumer = rocketmqPullConsumer;
    this.clientConfig = clientConfig;
    this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
        "OMS_CleanExpireMsgScheduledThread_"));
}
 
Example 26
/**
 * 启动
 * @throws MQClientException ;
 */
public void start() throws MQClientException {
    final String group = this.defaultMQPullConsumer.getConsumerGroup();
    this.scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(
        this.pullThreadNums,
        new ThreadFactoryImpl("PullMsgThread-" + group)
    );

    this.defaultMQPullConsumer.setMessageQueueListener(this.messageQueueListener);

    this.defaultMQPullConsumer.start();

    log.info("MQPullConsumerScheduleService start OK, {} {}",
        this.defaultMQPullConsumer.getConsumerGroup(), this.callbackTable);
}
 
Example 27
Source Project: rocketmq   Source File: FiltersrvController.java    License: Apache License 2.0 5 votes vote down vote up
public boolean initialize() {

        MixAll.printObjectProperties(log, this.filtersrvConfig);

        this.remotingServer = new NettyRemotingServer(this.nettyServerConfig);

        this.remotingExecutor =
            Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(),
                new ThreadFactoryImpl("RemotingExecutorThread_"));

        this.registerProcessor();

        // 固定间隔注册到Broker
        this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {

            @Override
            public void run() {
                FiltersrvController.this.registerFilterServerToBroker();
            }
        }, 15, 10, TimeUnit.SECONDS); // TODO edit by 芋艿:initialDelay时间太短,可能导致初始化失败。从3=》15

        this.defaultMQPullConsumer.setBrokerSuspendMaxTimeMillis(this.defaultMQPullConsumer
            .getBrokerSuspendMaxTimeMillis() - 1000);
        this.defaultMQPullConsumer.setConsumerTimeoutMillisWhenSuspend(this.defaultMQPullConsumer
            .getConsumerTimeoutMillisWhenSuspend() - 1000);

        this.defaultMQPullConsumer.setNamesrvAddr(this.filtersrvConfig.getNamesrvAddr());
        this.defaultMQPullConsumer.setInstanceName(String.valueOf(UtilAll.getPid()));

        return true;
    }
 
Example 28
Source Project: rocketmq   Source File: MQPullConsumerScheduleService.java    License: Apache License 2.0 5 votes vote down vote up
public void start() throws MQClientException {
    final String group = this.defaultMQPullConsumer.getConsumerGroup();
    this.scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(
        this.pullThreadNums,
        new ThreadFactoryImpl("PullMsgThread-" + group)
    );

    this.defaultMQPullConsumer.setMessageQueueListener(this.messageQueueListener);

    this.defaultMQPullConsumer.start();

    log.info("MQPullConsumerScheduleService start OK, {} {}",
        this.defaultMQPullConsumer.getConsumerGroup(), this.callbackTable);
}
 
Example 29
Source Project: rocketmq   Source File: NamesrvController.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * @return
 */
public boolean initialize() {

    this.kvConfigManager.load();

    this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.brokerHousekeepingService);

    this.remotingExecutor =
        Executors.newFixedThreadPool(nettyServerConfig.getServerWorkerThreads(), new ThreadFactoryImpl("RemotingExecutorThread_"));

    this.registerProcessor();

    //启动内部扫描失效Broker的定时任务,5S后执行第一次,每次间隔10S
    this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {

        @Override
        public void run() {
            NamesrvController.this.routeInfoManager.scanNotActiveBroker();
        }
    }, 5, 10, TimeUnit.SECONDS);

    //定期打印配置信息,每10分钟一次
    this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {

        @Override
        public void run() {
            NamesrvController.this.kvConfigManager.printAllPeriodically();
        }
    }, 1, 10, TimeUnit.MINUTES);

    return true;
}
 
Example 30
Source Project: DDMQ   Source File: LocalMessageCache.java    License: Apache License 2.0 5 votes vote down vote up
LocalMessageCache(final DefaultMQPullConsumer rocketmqPullConsumer, final ClientConfig clientConfig) {
    consumeRequestCache = new LinkedBlockingQueue<>(clientConfig.getRmqPullMessageCacheCapacity());
    this.consumedRequest = new ConcurrentHashMap<>();
    this.pullOffsetTable = new ConcurrentHashMap<>();
    this.rocketmqPullConsumer = rocketmqPullConsumer;
    this.clientConfig = clientConfig;
    this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl(
        "OMS_CleanExpireMsgScheduledThread_"));
}