Hello Guys,
I am getting this issue "This messaging entity has already been closed, aborted, or disposed."
Here is the scenario is, I am trying to process the Dead Letter Queue messages with Azure Functions.
Snippet here
deadLetterClient.OnMessage(msg =>
{
if (msg != null)
{
int retryCount = 0;
string domainObjectID = string.Empty;
domainObjectID = msg.GetBody();
try
{
DateTime oTime = Convert.ToDateTime("ds");
msg.Complete();
}
catch (Exception error)
{
-- This is the error throwing some time.
-- Error: This messaging entity has already been closed, aborted, or disposed
msg.Abandon(new Dictionary<string, object> { { "RetryCount", retryCount.ToString() } });
}
}
});
deadLetterClient.Close();
In this secanrio also throwing error like "Operation is not valid due to the current state of the object".
public static void Run(BrokeredMessage myQueueItem, TraceWriter log)
{
string domainObjectID = string.Empty;
//domainObjectID = myQueueItem.GetBody<string>();
var bodyStream = myQueueItem.GetBody<Stream>();
var sr = new StreamReader(bodyStream);
var jsonText = sr.ReadToEnd();
log.Info("C# ServiceBus queue trigger function processed message:" + jsonText);
try
{
var deadLetterqueuePath = QueueClient.FormatDeadLetterPath(QueueClient.CreateFromConnectionString(connectionString, mqCustomer).Path);
var deadLetterClient = QueueClient.CreateFromConnectionString(connectionString, deadLetterqueuePath, ReceiveMode.PeekLock);
deadLetterClient.Send(myQueueItem);
}
catch
{
log.Info("Exception");
}
finally
{
//myQueueItem.Abandon();
//myQueueItem.DeadLetter();
}
}
Advance thanks for suggestions.
Thanks
San