Our intention is that our messages should be consumed serially, therefore we have 1 consumer per queue. The messages are all identical, and are published to indicate that the consumer should request the next resource from the server.
Recently we had an issue where our Received event handler was called concurrently by 2 different threads. I've attached a screenshot of the logs at this time, which show the timestamp, thread id and message correlation id. At first the handler is called from thread 113, but then switches to 178. Could it be that these "duplicates" are due to the prefetch count of 5?
We also logged an exception around this time, whilst attempting to manually acknowledge a message:
RabbitMQ.Client.Exceptions.AlreadyClosedException: Already closed: The AMQP operation was interrupted: AMQP close-reason, initiated by Library, code=541, text="Unexpected Exception", classId=0, methodId=0, cause=System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
--- End of inner exception stack trace ---
at RabbitMQ.Client.Impl.InboundFrame.ReadFrom(NetworkBinaryReader reader)
at RabbitMQ.Client.Framing.Impl.Connection.MainLoopIteration()
at RabbitMQ.Client.Framing.Impl.Connection.MainLoop()
at RabbitMQ.Client.Impl.SessionBase.Transmit(Command cmd)
at RabbitMQ.Client.Impl.RecoveryAwareModel.BasicAck(UInt64 deliveryTag, Boolean multiple)
We're using the nuget package with version 5.1.0.
Do we need to handle locking ourselves? Or is there a bug with the client? Or have we mis-configured something?