I have the following code in C#, which does not throw error if the routing key is invalid.
var connFactory = GetConnectionFactory();
using (var conn = connFactory.CreateConnection())
{
using (var channel = conn.CreateModel())
{
channel.TxSelect();
var publicationAddress = new PublicationAddress(ExchangeType.Direct, Settings.ServiceBusExchange, Settings.ServiceBusRoutingKey);
var headers = new Dictionary<String, Object>();
headers.Add("TransactionID", transactionID);
var basicProperties = new BasicProperties();
basicProperties.ContentEncoding = Encoding.UTF8.ToString();
basicProperties.ContentType = "text/xml";
basicProperties.Headers = headers;
basicProperties.DeliveryMode = 2;
var payLoad = Encoding.UTF8.GetBytes(message);
channel.BasicPublish(publicationAddress, basicProperties, payLoad);
channel.TxCommit();
}
}
My question is, how can I make the code throw error if the routing key is invalid? Like when I Publish a message using RabbitMQ UI with invalid routing key, it gives a message "Message published, but not routed."
Thanks in advance.