question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Each ConsumeMessageThread should have different thread name

See original GitHub issue

FEATURE REQUEST

  1. Please describe the feature you are requesting. I am looking for a feature of ConsumeMessageThread for different Consumer has different ThreadName.

  2. Provide any additional detail on your proposed use case for this feature. For example, when two PushConsumer started in the same process, the client will create two ThreadPool for message consumption. But Threads in the two pools share the same thread names, thus cause confusion and increase the complexity of resolving problems.

  3. Indicate the importance of this issue to you (blocker, must-have, should-have, nice-to-have). Are you currently using any workarounds to address this issue? Nice to have. Not any workarounds.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
ahuazhucommented, Aug 1, 2019

@duhenglucky Thanks for your reply. In some scenarios, it’s necessary to create multi consumers. For example, suppose we have messages in two topics. One contains fewer messages, but each one takes a long consumption time, and the other is the opposite. In such a situation, subscribing these topics in one consumer maybe not a good choice. Because the few but heavy messages may block all ConsumeThreads, which leads to the another topic consumption latency. Here we need two isolated thread pools (consumer) for these two topics. For your second question, I think ConsumerGroup as a part of ConsumeThread name is more intuitive than instance.

1reaction
ahuazhucommented, Aug 1, 2019

What about if modifying the code in ConsumeMessageConcurrentlyService.java from

            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_"));

to

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

        this.scheduledExecutorService = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("ConsumeMessageScheduledThread_" + this.consumerGroup + "_"));
        this.cleanExpireMsgExecutors = Executors.newSingleThreadScheduledExecutor(new ThreadFactoryImpl("CleanExpireMsgScheduledThread_" + this.consumerGroup + "_"));
Read more comments on GitHub >

github_iconTop Results From Across the Web

Can Java understand that threads which have same name are ...
1 Answer 1 ... From the Javadoc: Every thread has a name for identification purposes. More than one thread may have the same...
Read more >
Naming a thread and fetching name of current thread in Java
It is a direct method of naming threads in java, each thread has a name that is: Thread-0, Thread-1, Thread-2,….so on.
Read more >
Set the Name of a Thread in Java - Baeldung
In this tutorial, we'll look at different ways to set the name of a Thread in Java. First, we'll create an example of...
Read more >
Set a Thread Name in Native Code - Visual Studio (Windows)
There are two ways to set a thread name. The first is via the SetThreadDescription function. The second is by throwing a particular...
Read more >
How to Check Thread Names in the ThreadPoolExecutor in ...
We would expect each worker thread to have a separate native and Python ID from the main thread and from each other.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found