I've got an ASP.NET Web API that accepts a DTO in an HTTP PUT method, performs some validation then Bus.Send()s a command.
Currently, all the messages are ending up in the configured MSMQ error queue.
Here's some pseudo code as an overview of the model I'm using...
public HttpResponseMessage Put([FromBody]EntityModel entity)
{
if (ModelState.IsValid)
{
_bus.Send(new command());
return Request.CreateResponse(HttpStatusCode.Accepted);
}
else
{
var msg = new HttpResponseMessage(HttpStatusCode.NotModified) { ReasonPhrase = "Error text here" };
return msg;
}
}
Upon investigation I set a breakpoint on the last brace/bracket of the Web API action method and look at the MSMQ in Computer Management and can see the message has made it's way into the correct queue and looks well formed.
When I step past the last bracket the message immediately moves into the error queue. There appears to be no other code running after the breakpoint (custom filters/attributes etc)
I'm theorising that it's something to do with the queues being transactional and something is causing that transaction to abort but I can't figure out what it is..
Any help would be great, thanks,
It sounds like there is a failure in the message handler code. If the message fails handling then it will be removed from the input queue (where you can see it delivered) and moved to the error queue.
Can you confirm that there is no failure on handling?