Console.WriteLine($"Publishing to Default EXG & queue: {result.QueueName}");
Todo : BUILD Retries, Republish and Acknowledgement Workflow.
IBasicProperties messageProps = _channel.CreateBasicProperties();
messageProps.Persistent = true;
//Handle Acks
_channel.BasicAcks += _channel_BasicAcks;
_channel.ConfirmSelect();
//Publish
byte[] body = Encoding.UTF8.GetBytes(messageToPublish);
_channel.QueueBind(
queueName,
exchangeName,
routingKey,
null
);
_channel.BasicPublish
( exchange: exchangeName,
routingKey: routingKey,
basicProperties: messageProps,
body: body);
//Wait for the Confirmations
_channel.ConfirmSelect();
_channel.WaitForConfirmsOrDie(10000);
The Event
_channel_BasicAcks (Object Sender, EventArgs e)
which is being called now externally from the scope of the publish method(async) instead of Synchronously getting response.
For a hardbound requirement of retrying individual messages immediately after a nack in a bulk publish how do I make this strictly synchronous.
Sync Wrapper to Async Publish method is the Solution I came up with, it works though it is not the best there is! Is there a better performing solution instead of having to trial and error with timeouts!