logo

Callback

A callback is a mechanism for handling the result of an asynchronous operation. In programming, it refers to a function passed as an argument for later invocation. In web architectures, it refers to a URL that receives an HTTP request upon event completion.

Callbacks in Programming

// Function callback
fetchData(url, function(error, result) {
if (error) handleError(error);
else processResult(result);
});
// Modern async/await (still callbacks under the hood)
try {
const result = await fetchData(url);
processResult(result);
} catch (error) {
handleError(error);
}

Callback URLs in Web Services

In task orchestration and webhook systems, a callback URL is an HTTP endpoint that receives a request when an operation completes:

  1. Your application creates a task with a callback URL
  2. The task orchestrator executes the work
  3. When complete, it sends an HTTP POST to your callback URL with the result

This pattern is essential for long-running operations that cannot hold a connection open.

Callbacks in AsyncQueue

AsyncQueue’s core feature is callback-based task orchestration:

await asyncqueue.tasks.create({
targetUrl: "https://api.example.com/on-complete",
payload: { orderId: "12345" },
retries: 3
});
// Your app continues immediately
// AsyncQueue calls your URL when the task completes

The callback URL receives the task result, status, and metadata via HTTP POST. AsyncQueue retries automatically if delivery fails.