![]() Processor.ProcessMessageAsync += MessageHandler ServiceBusProcessor processor = client.CreateProcessor(queueName, processorOptions) create a processor that we can use to process the messages ReceiveMode = ServiceBusReceiveMode.ReceiveAndDelete, MaxAutoLockRenewalDuration = TimeSpan.FromMinutes(10), Var processorOptions = new ServiceBusProcessorOptions Static Task ErrorHandler(ProcessErrorEventArgs args)Ĭonsole.WriteLine(()) handle any errors when receiving messages await args.CompleteMessageAsync(args.Message) Static async Task MessageHandler(ProcessMessageEventArgs args) ServiceBusMessage message = new ServiceBusMessage(textMessage) Ĭonsole.WriteLine($"Sent a single message to the queue: ") ServiceBusSender sender = client.CreateSender(queueName) With this application I am using "ReceiveAndDelete" and below is the sample codeĬreate Message private static async void CreateMessage(string queueName, string textMessage)Īwait using (ServiceBusClient client = new ServiceBusClient(connectionString)) Just make sure your API consumers are informed of the variance.So I have created sample application where an application will send message to queue and read the message. So, when it makes sense to not follow the guidance for your problem domain, don't. Again, link headers can make this discoverable. This does actually change the Request-URI and is definitely not RESTful. Use a separate endpoint per reason: Using a url like resource/:id/canceled.You can make it discoverable with Link headers on the resource for each reason (with a rel tag on each to identify the reason). In your case, I would just have a default reason if the reason is not specified in the query string. The question you linked was talking about not allowing the delete if the query parameter was missing. I actually think this is also a valid approach. Use the query parameters: The resource uri is not being changed.Therefore, I believe updating the record via a PUT/PATCH operation is a valid approach, even though it is not a DELETE operation per se. Send a PUT or PATCH: I am deducing that the delete operation is virtual, by the nature of needing a delete reason.Given the situation you have, I would take one of the following approaches: My first preference would probably be to use the message body, second to custom HTTP headers however, as indicated, there are some downsides to these approaches.Īre there any recommendations or best practices inline with REST/HTTP standards for including such required metadata on DELETE requests? Are there any other alternatives that I haven't considered? The delete reason (and other related metadata) are not part of the resource representation itself. PUT delete metadata, then DELETE) splits an atomic operation into two, potentially leaving an inconsistent state. Multiple Methods - Splitting the DELETE request into two operations (e.g.POST creates resource subordinates but I need to delete the resource) ![]() POST /resourceToDelete ) POST is not a semantic option for deleting POST actually represents the opposite action desired (i.e. Query Parameters - Adding query params actually changes the Request-URI being deleted against standard practices.Standard HTTP Headers - No standard headers are appropriate.Custom HTTP Headers - Requiring custom headers is generally against standard practices using them is inconsistent with the rest of my API, none of which require custom headers further, no good HTTP response available to indicate bad custom header values (probably a separate question altogether).Message Body - The spec indicates that message bodies on DELETE have no semantic value not fully supported by HTTP clients not standard practice.I've considered the following options, none of which seem completely appropriate and inline with HTTP specs and/or REST best practices: the "reason" for deletion, along with some other metadata required for deletion). My use case calls for the addition of some required metadata on a DELETE (e.g. Most libraries seem to oblige, although occasionally with a little bit of initial resistance. Most discussions seem to concur that providing a message body on a DELETE may be allowed, but is generally not recommended.įurther, I've noticed a trend in various HTTP client libraries where more and more enhancements seem to be getting logged for these libraries to support request bodies on DELETE. Is an entity body allowed for an HTTP DELETE request?.I've already reviewed several related discussions on this topic on SO and beyond, such as: Then the message-body SHOULD be ignored when handling the request. Request method does not include defined semantics for an entity-body, While the HTTP 1.1 spec seems to allow message bodies on DELETE requests, it seems to indicate that servers should ignore it since there are no defined semantics for it.Ī server SHOULD read and forward a message-body on any request if the
0 Comments
Leave a Reply. |