org.apache.rocketmq.common.ThreadFactoryImpl Java Examples

The following examples show how to use org.apache.rocketmq.common.ThreadFactoryImpl. 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: StatsItemSetTest.java    From rocketmq with 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 #2
Source File: ConsumeMessageConcurrentlyService.java    From DDMQ with 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 #3
Source File: ConsumeMessageOrderlyService.java    From rocketmq-all-4.1.0-incubating with 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 #4
Source File: ConsumeMessageConcurrentlyService.java    From rocketmq-all-4.1.0-incubating with 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 #5
Source File: ConsumeMessageConcurrentlyService.java    From rocketmq with 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<>();

    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 File: ConsumeMessageOrderlyService.java    From rocketmq with 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
Source File: ConsumeMessageOrderlyService.java    From rocketmq_trans_message with 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 #8
Source File: ConsumeMessageConcurrentlyService.java    From rocketmq-read with 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
Source File: ConsumeMessageOrderlyService.java    From rocketmq-read with Apache License 2.0 6 votes vote down vote up
/**
 * 构造顺序消费的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 #10
Source File: ConsumeMessageConcurrentlyService.java    From rocketmq_trans_message with 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 #11
Source File: ConsumeMessageConcurrentlyService.java    From rocketmq-4.3.0 with 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 #12
Source File: ConsumeMessageOrderlyService.java    From rocketmq-4.3.0 with 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 #13
Source File: AsyncTraceDispatcher.java    From rocketmq with 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 File: ConsumeMessageOrderlyService.java    From rocketmq with 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
Source File: StatsItemSetTest.java    From rocketmq with 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 #16
Source File: ConsumeMessageConcurrentlyService.java    From DDMQ with 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 #17
Source File: ConsumeMessageConcurrentlyService.java    From rocketmq with 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 #18
Source File: DefaultLitePullConsumerImpl.java    From rocketmq with Apache License 2.0 5 votes vote down vote up
public DefaultLitePullConsumerImpl(final DefaultLitePullConsumer defaultLitePullConsumer, final RPCHook rpcHook) {
    this.defaultLitePullConsumer = defaultLitePullConsumer;
    this.rpcHook = rpcHook;
    this.scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(
        this.defaultLitePullConsumer.getPullThreadNums(),
        new ThreadFactoryImpl("PullMsgThread-" + this.defaultLitePullConsumer.getConsumerGroup())
    );
    this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactory() {
        @Override
        public Thread newThread(Runnable r) {
            return new Thread(r, "MonitorMessageQueueChangeThread");
        }
    });
    this.pullTimeDelayMillsWhenException = defaultLitePullConsumer.getPullTimeDelayMillsWhenException();
}
 
Example #19
Source File: LocalMessageCache.java    From rocketmq-all-4.1.0-incubating with 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 #20
Source File: MQPullConsumerScheduleService.java    From DDMQ with 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 File: FiltersrvController.java    From rocketmq-all-4.1.0-incubating with 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 #22
Source File: MQPullConsumerScheduleService.java    From rocketmq-all-4.1.0-incubating with 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 #23
Source File: NamesrvController.java    From rocketmq-all-4.1.0-incubating with Apache License 2.0 5 votes vote down vote up
public boolean initialize() {

    	// 加载KV配置
        this.kvConfigManager.load();

       // 初始化通信层
        this.remotingServer = new NettyRemotingServer(this.nettyServerConfig, this.brokerHousekeepingService);  //brokerHousekeepingService 接收Broker连接事件

        // 初始化固定线程池
        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); //每隔10s扫描broker,维护当前存活的Broker信息

        this.scheduledExecutorService.scheduleAtFixedRate(new Runnable() {

            @Override
            public void run() {
                NamesrvController.this.kvConfigManager.printAllPeriodically();
            }
        }, 1, 10, TimeUnit.MINUTES); //每隔10s打印KVConfig信息。

        return true;
    }
 
Example #24
Source File: MQPullConsumerScheduleService.java    From rocketmq with 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 #25
Source File: FiltersrvController.java    From rocketmq_trans_message with 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 #26
Source File: MQPullConsumerScheduleService.java    From rocketmq_trans_message with 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 #27
Source File: NamesrvController.java    From rocketmq_trans_message with Apache License 2.0 5 votes vote down vote up
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();

        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 #28
Source File: LocalMessageCache.java    From rocketmq with 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 #29
Source File: LocalMessageCache.java    From rocketmq-read with 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 #30
Source File: FiltersrvController.java    From DDMQ with 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;
    }