Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A problem when using TransactionMQProducer (4.3.0-Release) #392

Closed
laiyy0728 opened this issue Aug 7, 2018 · 2 comments
Closed

A problem when using TransactionMQProducer (4.3.0-Release) #392

laiyy0728 opened this issue Aug 7, 2018 · 2 comments

Comments

@laiyy0728
Copy link

laiyy0728 commented Aug 7, 2018

When implementing the Transaction demo of Java, there is a question: the ExecutorService that implements a ThreadPool is passed to the TransactionMQProducer.
When producer shutdown , is throw a Exception of NullPointException.
Check source code and found in the destroyTransactionEnv of DefaultMQProducerImpl checkRequestQueue is null. And found in the initTransactionEnv of DefaultMQProducerImpl, after initializing the executorService, the checkRequestQueue will not be initialized, causing it to be empty. And no manually added position in TransactionProducer. How can I solve this problem?

Source code:

 public void initTransactionEnv() {
        TransactionMQProducer producer = (TransactionMQProducer) this.defaultMQProducer;
        if (producer.getExecutorService() != null) {
            this.checkExecutor = producer.getExecutorService();
        } else {
            this.checkRequestQueue = new LinkedBlockingQueue<Runnable>(2000);
            this.checkExecutor = new ThreadPoolExecutor(
                1,
                1,
                1000 * 60,
                TimeUnit.MILLISECONDS,
                this.checkRequestQueue);
        }
    }

    public void destroyTransactionEnv() {
        this.checkExecutor.shutdown();
        this.checkRequestQueue.clear();
    }
@laiyy0728 laiyy0728 changed the title A problem when using TransactionProducer (4.3.0-Release) A problem when using TransactionMQProducer (4.3.0-Release) Aug 7, 2018
@duhengforever
Copy link
Contributor

duhengforever commented Aug 7, 2018

@laiyy0728 yep,this is really an issue, actually there is no need to clear the queue anymore, because the tasks in the queue will be processed after shutdown. you can modify this and pull a request ,we are glad to see your contribution.

@duhengforever
Copy link
Contributor

This Issue had been resolved in other PR, but thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants