Pub/sub API reference
This endpoint lets you publish data to multiple consumers who are listening on a . Dapr guarantees At-Least-Once semantics for this endpoint.
HTTP Response codes
Parameter | Description |
---|---|
daprPort | The Dapr port |
pubsubname | The name of pubsub component |
topic | The name of the topic |
metadata | Query parameters for metadata as described below |
curl -X POST http://localhost:3500/v1.0/publish/pubsubName/deathStarStatus \
-H "Content-Type: application/json" \
-d '{
"status": "completed"
}'
Headers
The Content-Type
header tells Dapr which content type your data adheres to when constructing a CloudEvent envelope. The Content-Type
header value populates the datacontenttype
field in the CloudEvent.
Unless specified, Dapr assumes text/plain
. If your content type is JSON, use a Content-Type
header with the value of application/json
.
If you want to send your own custom CloudEvent, use the value for the Content-Type
header.
Metadata
Metadata can be sent via query parameters in the request’s URL. It must be prefixed with metadata.
, as shown below.
Dapr will invoke the following endpoint on user code to discover topic subscriptions:
HTTP Request
URL Parameters
Parameter | Description |
---|---|
appPort | The application port |
HTTP Response body
A JSON-encoded array of strings.
Example:
[
{
"topic": "newOrder",
"route": "/orders",
"metadata": {
"rawPayload": "true",
}
}
]
Metadata
Optionally, metadata can be sent via the request body.
Provide route(s) for Dapr to deliver topic events
In order to deliver topic events, a POST
call will be made to user code with the route specified in the subscription response.
HTTP Request
URL Parameters
Parameter | Description |
---|---|
appPort | The application port |
path | Route path from the subscription configuration |
Expected HTTP Response
An HTTP 2xx response denotes successful processing of message.
For richer response handling, a JSON-encoded payload body with the processing status can be sent:
{
"status": "<status>"
}
Dapr assumes that a JSON-encoded payload response without status
field or an empty payload responses with HTTP 2xx is a SUCCESS
.
The HTTP response might be different from HTTP 2xx. The following are Dapr’s behavior in different HTTP statuses:
HTTP Status | Description |
---|---|
2xx | message is processed as per status in payload (SUCCESS if empty; ignored if invalid payload). |
404 | error is logged and message is dropped |
other | warning is logged and message to be retried |
Dapr pub/sub adheres to version 1.0 of CloudEvents.