I am looking at using EasyNetQ for interacting with RabbitMQ and wondering if it can support following case:
Possibilities I have found are:
The question is can I just use existing queue with custom parameters and without need to specify them?
If the queue already exists and you know its name, couldn't you use the IAdvancedBus.Consume<T>
method (and not worry about IAdvancedBus.QueueDeclare
)?
For example:
var queueName = "TheNameOfYourExistingQueue";
var existingQueue = new EasyNetQ.Topology.Queue(queueName, false);
// bus should be an instance of IAdvancedBus
bus.Consume<TypeOfYourMessage>(existingQueue,
(msg, info) =>
{
// Implement your handling logic here
});
Note that EasyNetQ might have trouble automatically deserializing messages into instances of TypeOfYourMessage
. If that is the case, one way to solve it would be to bypass EasyNetQ's message serializer so that you can access the byte array of the message directly. Use the following overload to Consume
if you wish to go that route:
void Consume(IQueue queue, Func<Byte[], MessageProperties, MessageReceivedInfo, Task> onMessage);