-
Notifications
You must be signed in to change notification settings - Fork 78
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
[Host.RabbitMQ] Add ability to configure connection retry attempts and delay #310
Comments
It makes sense to add the connection retries. Check also #282 as it could help (while not directly related to this issue, it could help in some scenarios). Are you looking to contribute or rather asking for the feature to be built? |
Rather a suggestion to add feature, as I don't have time to contribute myself. |
How can multiple consumers be used on a single bus, each with different parallelism limits? Currently, this isn't possible and isn't planned, is it? |
@robert94p do you need 2 separate consumers on the same rabbitmq queue? With current implementation, the consumer declarations are grouped by the queue name (see RabbitMqMessageBus.cs). If you want to have 2 distinct consumer instances on the same queue, then a feature would be required (I could look into this). Ideally, if you provide me with a sample bus setup to better understand the need. |
Apologies, I wrote this under the wrong issue; it should have been under #205 I need 2 or more consumers. I have one producer, one exchange, and three queues for three different consumers. When publishing a message, the target queue is determined via the routingKey. One of the consumers performs a resource-intensive operation, so it needs to be limited to processing only 2 messages in parallel. The other consumers can handle more messages simultaneously. I would like to configure the number of messages that can be processed concurrently per consumer, similar to how it works in MemoryMessageBus. Currently, messages are processed based on the ConsumerDispatchConcurrency setting, which applies globally to all consumers. |
I think I can sort this. It makes sense to not group same consumer declarations if they all have a different routing key. Let me look into this and get back to you. |
There is already some built-in retry via |
Yes, such functionalities exist. A feature for retrying connection attempts is needed for establishing a new connection. The built-in functionality of RabbitMQ does not allow retries when initially establishing a connection. |
I like this idea. Would it also not be a good idea to be able to throw an exception once the retry attempts are all done? Now there only seem to be an error message in the log. Or am I missing something? I'm quite new to SMB. |
@Jan-Olof as far as I know, the initial connection retries should happen (3 times with some delay). After the 3rd attempt, it rethrows the error making publishing to the bus impossible. Link to the retry logic. I've tested this with 2.7.0 version, and corrupted my URL to emulate an unreachable broker. Here is the result:
Do you expect something else here? |
Thank you for the quick reply. It was the error in the last line I was thinking of: [14:25:06 ERR] SlimMessageBus.Host.MessageBusBase Could not auto start consumers For my purpose it would be better if it threw an exception. But really, it would be enough if there was something like a property you could access that showed if there is an active connection to RabbitMQ or not. I.e. an easy way to know the connection status. But I guess you should make a "ping" publish to find out? |
Thanks for the clarification.
Let me know your thoughts. Specifically if 2) does what you asked for, and if 1) would be useful. |
Thanks again for your answer. I had missed the IsStarted in IConsumerControl. It is indeed what I asked for. Also 1) would be very useful, as I would like connection retries to be endless (or at least until you tell it to stop. Returning to the producer (though this may be off topic). I don't suppose you use the RabbitMQ Publisher Confirms feature? https://www.rabbitmq.com/docs/confirms#publisher-confirms https://rianjs.net/2013/12/publisher-confirms-with-rabbitmq-and-c-sharp |
It is necessary to add the ability to configure the number of connection attempts (including infinite) and the delay between them. This is required because the connection is established when the application starts, but at that moment RabbitMQ may be unavailable for various reasons and could remain unavailable for an extended period. Alternatively, the ability to detect successful bus creation should be added so that in case of failure, the application can be restarted.
The text was updated successfully, but these errors were encountered: