All serverless function providers have a maximum execution time for each function. Usually you can extend this time by paying more, but it’s still limited. QStash provides a way to go around this problem by using callbacks.
A callback allows you to call a long running function without having to wait for its response. Instead of waiting for the request to finish, you can add a callback url to your published message and when the request finishes, we will call your callback URL with the response.
/v2/publish
endpointCallbacks publish a new message with the response to the callback URL. Messages created by callbacks are charged as any other message.
You can add a callback url in the Upstash-Callback
header when publishing a
message. The value must be a valid URL.
The callback body sent to you will be a JSON object with the following fields:
In Next.js you could use the following code to handle the callback:
We may truncate the response body if it exceeds your plan limits. You can check
your Max Message Size
in the
console.
Make sure you verify the authenticity of the callback request made to your API by verifying the signature.
Failure callbacks are similar to callbacks but they are called only when all the retries are exhausted and still the message can not be delivered to the given endpoint.
This is designed to be an serverless alternative to List messages to DLQ.
You can add a failure callback URL in the Upstash-Failure-Callback
header when publishing a
message. The value must be a valid URL.
The callback body sent to you will be a JSON object with the following fields:
You can also use a callback and failureCallback together!
Publishes/enqueues for callbacks can also be configured with the same HTTP headers that are used to configure direct publishes/enqueues.
Instead of the Upstash
prefix for headers, the Upstash-Callback
/Upstash-Failure-Callback
prefix can be used to configure callbacks as follows:
You can also forward headers to your callback endpoints as follows:
All serverless function providers have a maximum execution time for each function. Usually you can extend this time by paying more, but it’s still limited. QStash provides a way to go around this problem by using callbacks.
A callback allows you to call a long running function without having to wait for its response. Instead of waiting for the request to finish, you can add a callback url to your published message and when the request finishes, we will call your callback URL with the response.
/v2/publish
endpointCallbacks publish a new message with the response to the callback URL. Messages created by callbacks are charged as any other message.
You can add a callback url in the Upstash-Callback
header when publishing a
message. The value must be a valid URL.
The callback body sent to you will be a JSON object with the following fields:
In Next.js you could use the following code to handle the callback:
We may truncate the response body if it exceeds your plan limits. You can check
your Max Message Size
in the
console.
Make sure you verify the authenticity of the callback request made to your API by verifying the signature.
Failure callbacks are similar to callbacks but they are called only when all the retries are exhausted and still the message can not be delivered to the given endpoint.
This is designed to be an serverless alternative to List messages to DLQ.
You can add a failure callback URL in the Upstash-Failure-Callback
header when publishing a
message. The value must be a valid URL.
The callback body sent to you will be a JSON object with the following fields:
You can also use a callback and failureCallback together!
Publishes/enqueues for callbacks can also be configured with the same HTTP headers that are used to configure direct publishes/enqueues.
Instead of the Upstash
prefix for headers, the Upstash-Callback
/Upstash-Failure-Callback
prefix can be used to configure callbacks as follows:
You can also forward headers to your callback endpoints as follows: