Detecting consume failure with EasyNetQ - c#

When I start consuming from a queue that is already locked by another exclusive consumer then no exception is thrown by the consume method, although I can see the error being logged. The ExclusiveConsumer keeps trying to start consuming every 10 seconds, which is great, but I would like to check (from code) when it hasn't started.
Consume failed. queue='Queue1', consumer tag='cb439965-72d4-4d52-a248-91077b796703', message='The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=403, text="ACCESS_REFUSED - queue '1' in vhost '/' in exclusive use", classId=60, methodId=20, cause='
Is there any way I can detect the Consumer status without modifying the code?

Related

Is there any chance to process RabbitMQ asynchronous requests slowly to cause the process of request as duplicate- Research

I was publishing 2000 asynchronous request into RabbitMQ pipeline and which will process each request asynchronously.
I have some issue while processing the request.
1.Some request being processed multiple times.
I found a solution as [https://www.rabbitmq.com/consumers.html#message-properties][1]
In the event of network failure (or a node failure), messages can be redelivered, and consumers must be prepared to handle deliveries they have seen in the past.
My question is do we have any cases while processing asynchronous RabbitMQ request slowly?
example -
Processing request-1 start at 2020-08-12 08:06:05.000.
Request 1 ends at 2020-08-12 08:06:19.000
Processing the same request 1 at 2020-08-12 08:06:11.000 and which ends at 2020-08-12 08:06:18.000
If any delay or timeout happens to RabbitMQ will cause process the request again?
before ending the first request RabbitMQ process it again.
Do we have any chance like this? Please help.

Is it possible to extend MassTransit RabbitMq transport/pipeline exceptions?

We are using a clustered setup with HA queues using MassTransit and RabbitMQ. This works mostly well, but is it possible to extend what happens when there is an exception in the transport layer?
For instance, once a node in the cluster goes down a consumer gets this error:
MassTransit.Util.TaskSupervisor Error: 0 :
Failed to close scope
MassTransit.RabbitMqTransport.Pipeline.RabbitMqBasicConsumer -
rabbitmq://x:5672/y/z?durable=false&autodelete=true&prefetch=16,
System.Threading.Tasks.TaskCanceledException: A task was canceled.
The message flow will still be working as it will switch to another node, but we would like to perform additional actions when the above happens. It is a handled exception, so it is not possible to hook into UnhandledException for the application.

Never ending messages with RabbitMQ

We are using MassTransit(3.5.2) together with RabbitMQ(3.6.6). We are having a problem with a message that never gets removed from the queue (even if we have read and consumed the message).
To read from the queue we have implemented an IConsumer class.
The only thing we are doing is closing the sender (abrupt).
After that the message never gets acknowledged and rabbitmq is continuing to send the same message to our consumer all the time.
Have anyone else got the same problem and how did you solve this issue?
:: Update from comments ::
We had already checked the log files and it says: "closing AMQP connection <0.18285.1> ([::1]:57008 -> [::1]:5672): client unexpectedly closed TCP connection ".
That doesnt feel that wierd since i am actually closing the tcp connection unexpectedly with killing the .exe file :)
Regarding the log files from masstransit we have also done that and we do not get any error, we only gets two debug messages.
One that we have received and one that we are sending the result.
DEBUG 47 MassTransit.Messages - RECEIVE rabbitmq://localhost/[VirtualHost]/[ConsumerName] N/A ContractCommand CommandConsumer(00:00:00.0364932)
DEBUG 30 MassTransit.Messages - SEND rabbitmq://localhost/[VirtualHost]/bus-[ComputerName]-[Sende‌​rName].Server.vshost‌​-4bayyydsf9rfs3qzbdk‌​gx8bbr1?durable=fals‌​e&autodelete=true d0700000-762f-c85b-f03a-08d4679c39d4 Result
One observation that I have made in my consumer is that at the same time as I am force closing my sender I get an MessageNotConfirmedException followed by some AlreadyClosedException from RabbitMQ.
And it's after that we get in the infinite loop when MT does not set the ACK/NACK. (and in the infinite loop I do not get any MessagenNotConfirmedException).
Also for my consumer to properly work again I need to restart my consumer then it will be ACK/NACKed.
MessageNotConfirmedMessage: "'MassTransit.RabbitMqTransport.MessageNotConfirmedException‌​' in mscorlib.dll Additional information: rabbitmq://localhost/[VirtualHost]/bus-[ComputerName]-[Servi‌​ce].Server.vshost-4b‌​ayyydsf9rfsf3ybdkgxg‌​5h8b => The message was not confirmed by RabbitMQ
'RabbitMQ.Client.Exceptions.AlreadyClosedException' Additional information: Already closed: The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=404, text="NOT_FOUND - no exchange 'bus-[ComputerName]-[ServiceName].Server.vshost-4bayyydsf9rf‌​s3qzbdkgx8bbr1' in vhost '[VirtualHost]'", classId=60, methodId=40, cause=
I have updated our code to use MassTransit 3.5.7 and after that I have not been able to reproduce this issue.
When you are done processing your queue object, you can mark it as successful by BasicAck(e.DeliveryTag, false)

Error sending message to queue

I'm using EasyNetQ to send a message in a queue of rabbit.
I have a code like this
using (var bus = RabbitHutch.CreateBus("MyConnection"))
{
bus.Send("MyCodeName", "MyClass");
}
the connection is open when I create the bus, but there is this error when I send the message
The AMQP operation was interrupted: AMQP close-reason, initiated by Peer, code=406, text="PRECONDITION_FAILED - inequivalent arg 'x-max-priority' for queue ....: received none but current is the value '10' of type 'long'", classId=50, methodId=10, cause=
I setup the queue with x-max-priority: 10.
I have to setup anything else in the connection string?
I have resolved without using Send method
EasyNetQ
Infact the send method, tries to create a queue before send message.
I have used the publish method
Delete the queue/exchange first and try again.
Don't use 'using' around the bus instance, instead instantiate it once in your application and dispose on quit.

RabbitMQ no ack usage

I'm integrating RMQ into my project, in order to implement work queues.
I understand what if module succeeded, it calls the ack method so RMQ will know about it.
What about failures?
I read that only when connection or channel are closed, RMQ knows we've failed and re-push the message to the queue.
I'd like however to make the RMQ re-push messages whenever I have an internal error, regardless of wheter I crash or not (e.g. failure to insert to DB, I handle that gracefully without crashing however I want the whole job to be re-tried).
Do I have to manually close and open the channel again in order to trigger that?
You can use negative ACK, or rejects. Info here.
The AMQP specification defines the basic.reject method that allows
clients to reject individual, delivered messages, instructing the
broker to either discard them or requeue them.

Categories

Resources