What are the category theory structures describing queues and topics? By queues and topics I mean the ones described in systems like Apache Kafka, AcriveMQ or Java Messaging Service.

Where I can find material about that?


1 Answer 1


A data structure Queue is very close to the concept of a List, however a Queue is a First-In-First-Out (FIFO) data structure. The available operations to interact with the List structure then, are limited to enqueue() and dequeue() (it is not a case in fact that a queue can be implemented using a List structure).

In the context of Category Theory you might find a parallelism between a List data structure and a Free Monoid https://ncatlab.org/nlab/show/free+monoid which can provide a recursive implementation of a List data structure. The same category equipped with ad-hoc morphism can be used to describe the behaviour of Stacks and Queues data structure.

In the case of Kafka and other similar queue services, besides the complications coming from the distributed case scenario, they don't really resemble the usual case of a Queue data structure. In fact, such a data structure is always supposed to be finite - they are rather implementing the concept of a stream (which could be finite or infinite) under the access condition of a queue (to be completely precise, for Kafka that's not even completely true, since you have the ability to access elements arbitrarily from the topic/queue using an offset). To model such kind of streaming structures an approach similar to this https://ncatlab.org/nlab/show/stream could be used.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.