ActivityPub: An Inbox is Not a Queue

It's not unusual to see AP Fediverse posts discussing message queue middleware and message brokers and pondering whether using them is conformant with "inboxes" as defined in the ActivityPub Recommendation (AP). The answer is that conformance is not relevant because an inbox is not a queue.

AP discusses an inbox from two perspectives: inbox endpoints and inbox collections. An inbox endpoint is the URL where AP messages can be posted. For a server that's only Server-to-Server (S2S) conformant, which is almost all of the AP Fediverse, reading an inbox is not required. Only inbox posting is required for server federation. An inbox URL is not a queue or any other collection structure. This is where the inbox *collection* would possibly be relevant.

An inbox collection is the Activity Streams 2.0 Collection type used to serialize inbox activities when they are requested through the inbox URL endpoint. For S2S-only servers this is never done. Although there are AP requirements for the inbox collection related to reverse chronological ordering, for example, these are not relevant to an S2S-only server implementation.

As an aside, even if inbox collections were relevant, an inbox would not be a queue. There are several significant differences. Queues are first-in-first-out (FIFO) data structures. An inbox is a last-in-first-out (LIFO) structure. Queue items are removed when they are dequeued. However, inbox items remain in the inbox after being read.

It's important to remember that an AP inbox is a serialization for import/export or interprocess communication, not a description of how data should be stored or processed internally in a server. This may be the fundamental confusion when a developer directly compares an inbox serialization with using a message broker as an implementation technique.

So if you encounter these types of discussions, the good news is that using a message broker, message queue, in-memory queue, append-only log, relational database, RDF graph store, flat files, or whatever is not a conformance issue. AP has very few requirements related to these internal implementation details of a server.

Leave a Comment

Mastodon