Webhooks for Nexus queues
Webhooks is a popular way of letting another web application notify your web application that something has happened by posting data to an endpoint in your application. Nexus supports this out-of-the-box by automatically creating an endpoint for each queue in the system that can be used given to another application to send notifications to.
The webhook url is:
https://url-to-your-nexus-app.com/api/queues/[queue name]/webhook
You can also click on the More button in the admin url of your queue to get the exact url.
Request details
Nexus requires the incoming HTTP request to be a POST request and to have a request body in JSON. The body can either be a single message or an array of messages:
Either:
{ "someMessageProperty": "some value" }
Or:
[
{ "someMessageProperty": "message1" },
{ "someMessageProperty": "message1" },
{ "someMessageProperty": "message1" }
]
The JSON body is deserialized into the structure of your queue message and sent to the queue. Which means that any properties in the JSON body that doesn't exist in your message type is discarded, so make sure to include all the properties you need.
You can customize the message deserialization by implementing your own IQueueMessageSerializer
in which you can take the entire original JSON body and store in a separate property on your message.
It's also a good idea to use virtual queues for webhooks since it lets you register a single webhook and then pass the webhook notitication to multiple internal queues.