sorry....this posted before I finished. After I clean up the consumer, I clean up the model and connection like so:
try
{
if (null != _consumerChannel)
{
_consumerChannel.FlowControl -= this.FlowControlChanged;
_consumerChannel.Close();
}
}
catch
{
try
{
_consumerChannel.Abort();
}
catch { }
}
finally
{
try
{
if (null != _consumerChannel)
{
_consumerChannel.Dispose();
}
}
catch { }
finally
{
_consumerChannel = null;
}
}
if (null != this.connection)
{
try
{
this.connection.ConnectionBlocked -= this.ConnectionOnConnectionBlocked;
this.connection.ConnectionUnblocked -= this.ConnectionOnConnectionUnBlocked;
this.connection.ConnectionShutdown -= this.ConnectionOnConnectionShutdown;
this.connection.Close(1000);
}
catch
{
try
{
this.connection.Abort();
}
catch { }
}
finally
{
if (null != connection)
{
// yes...just calling dispose can cause a System.IO.IOException....
try
{
connection.Dispose();
}
catch { }
finally
{
connection = null;
}
}
}
}
so far all good, right?
after this, I will publish another message. Once the message is published (this is done in a separate app using a separate connection object), I'll go ahead and reconnect my consumer.
everything will be created from scratch again...the connection, the IModel channel and then the event consumer at which point I'll wire in the received event again. However, now NO messages will be received.
If I look at the rabbitMQ health monitor, I can see that I'm connected to the Queue (i.e. 1 consumer is registered) however, there is 1 unacked message....and its stuck.
Here's the rub. If I go through the process and disconnect my event consumer again (exact same way as I showed above), I'll now get the message.
What's happening here? How do I go about troubleshooting this? is the event consumer somehow NOT getting properly unregistered?
any help would be Greatly appreciated.
Thanks!