Deffering messages with nservicebus

后端 未结 1 500
轻奢々
轻奢々 2021-01-25 03:14

I am dealing with nServiceBus and I want to retry and a message at another time when one fails. I have heard of Bus.Defer() but my understanding of it is limited.

I have

相关标签:
1条回答
  • 2021-01-25 03:33

    In your code

    if (scheduleRecheck && result.ErrorMessage.Equals("Bad Request"))
                {
                    Logger.Error("Stock query for stock code '{0}' returned a 'Product Not Found' status",
                        stockcode);
    
                    _bus.SendLocal<ScheduleCheckStockAvailabilityCommand>(cmd =>
                    {
                        cmd.StockCode = stockcode;
                    });
                }
            }
    

    you are sending a message ScheduleCheckStockAvailabilityCommand. Now in your other function yoe are deferring this message i.e. ScheduleCheckStockAvailabilityCommand (which i think is called only when there is some error with CheckCurrentProductAvailabilityCommand ). So according to what I gather you want to defer CheckCurrentProductAvailabilityCommand rather than ScheduleCheckStockAvailabilityCommand so I think your code should be:

    if (scheduleRecheck && result.ErrorMessage.Equals("Bad Request"))
                {
                    Logger.Error("Stock query for stock code '{0}' returned a 'Product Not               Found' status",stockcode);
                  _bus.Defer(_checkStockCodeAvailability.TimeOutTime, CheckCurrentProductAvailabilityCommand);
    
                }
            }
    
    0 讨论(0)
提交回复
热议问题