0

I have been running a simple Windows Service, with a EasyNetQ, but when i try to publish a message I have been receiving an Exception.

Exception:

Pubisher confirms timed out after 10 seconds waiting for ACK or NACK from sequence

Here are my publish tests:

try {       
    var queue = _bus.Advanced.QueueDeclare("api-request-history");        
    _bus.Send(queue.Name, message);

} catch (Exception e) {
    Logger.FatalException(string.Format("Message were not queued in queue: {0}", queue.Name), e);                
    OnErrorOccurred(e);     
} 

Here is my Subscription tests:

public override void Subscribe(Action<IReceiveRegistration> execution) {
     var queue = _bus.Advanced.QueueDeclare("api-request-history");
     try {
         while (_bus.IsConnected) {
             _bus.Receive(queue.Name, execution);
         }
     } catch (Exception e) {
         Logger.ErrorException("Error occurred", e);
     } finally {
         if (_bus != null) {
             _bus.Dispose();
         }
     }
 }

Here is the Invokation of Subscribe:

_queueConsumer.Subscribe(x => x.Add<ApiRequestHistory>(message => {
    Logger.Info("Initializing subscribtion sequence!");
    Logger.Info("Message data is being saved...");

    Execute();
    Logger.Info("Message data saving is completed!");
    Thread.Sleep(100);
    wait.Set();
}));
wait.Wait();
hackp0int
  • 4,052
  • 8
  • 59
  • 95

1 Answers1

0

I think you are subscribing the wrong way. You shouldn't be calling _bus.Receive(queueName) more than once for the same queue (from EasyNETQ docs):

Note: You probably do not want to call bus.Receive more than once for the same queue. This will create a new consumer on the queue and RabbitMQ will round-robin between them. If you are consuming different types on different Receive calls (and thus different consumers), some of your messages will end up on the error queue because EasyNetQ will not find a handler for your message type associated with the consumer on which it is consumed.

Just do it once and your consumers (per type) will be registered.

This is specially true as it seems you are using publisher confirms. I don't know your scenario fully well, but usually that is not needed unless you have a transactional RPC call model.

Check the docs on publisher confirms.

cvbarros
  • 1,684
  • 1
  • 12
  • 19
  • How should I call it from windows service?? It's reoccurring every 1000ms, that mean that will be invoked every time it will re-initialize. Can you suggest a windows service with easynetq example, that will demonstrate, how it's works? – hackp0int Mar 01 '14 at 21:45