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

Advanced Bus Consumer Dispose and then Re-consume failing #557

Closed
beartastic opened this issue Apr 3, 2016 · 5 comments
Closed

Advanced Bus Consumer Dispose and then Re-consume failing #557

beartastic opened this issue Apr 3, 2016 · 5 comments
Assignees

Comments

@beartastic
Copy link

I have a button to turn the EasyNetQ Consumer on and off.

I cannot seem to get it to work.

When my code initially runs with only the FIRST StartConsumingMQ(), it works fine. I can also toggle it to turn OFF - StopConsumingMQ(). However, when I try to turn it on again (StartConsumingMQ()) - the listener doesn't seem to reactivate.

How can I make it so that I can turn the consumer on and off?

public void StartConsumingMQ(){
     _mq._consumer = _mq._abus.Consume(_mq._queue, x => x.Add<MyMessage>((message, info) => { HandleMessage(message);}));
}

public void StopConsumingMQ(){
    _mq._consumer.Dispose();
}
@zidad
Copy link
Member

zidad commented Apr 4, 2016

Could you try recreating the bus instance instead?

@beartastic
Copy link
Author

The issue is, I am using the bus for other things in the code. I only want
to toggle the consuming portion of it.

This is a bug correct?

On Mon, Apr 4, 2016 at 11:20 AM, Wiebe Tijsma notifications@github.com
wrote:

Could you try recreating the bus instance instead?


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
#557 (comment)

@zidad
Copy link
Member

zidad commented Apr 5, 2016

I don't think it's a common use case, the Dispose() is meant to stop the consumers when stopping the entire bus instance. I'd be happy to accept a PR if you find a way to fix this!

@micdenny
Copy link
Member

micdenny commented Apr 5, 2016

The Dispose on a Consumer/Subscriber is meant to cancel the subscription, I don't remember if trying to re-subscribe was working in any version, but actually I'm using in production this feature, I'm not really expecting that re-subscribe works but if it would is not bad to me as well, I will check my code in these days and let you know if I understand by the code if I was expecting such a behavior you requested and if with new version we introduced a bug or not.

@Pliner Pliner self-assigned this Jul 18, 2018
@Pliner
Copy link
Member

Pliner commented Jul 18, 2018

Experiment 2.zip

I tried to reproduce the issue, but everything works as expected: recreation of subscriptions works.

The only advice I have is to try newest version.

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

No branches or pull requests

4 participants