Semantics of Subscriptions vs Queues¶
The naming of different contexts in the SWIM services using AMQP can be confusing, especially when it comes to the terms subscriptions and queues, as well as exchanges or topics vs. services.
This document clarifies the semantics of these terms.
What are Services and Subscriptions?¶
The term service and subscription are used in the SWIM context to denote an offer of data that can be consumed by a customer.
A service is identified by a unique name, which is used to create a subscription.
A list of services can be found in the SWIM Service Registry.
A service may contain multiple datasets with multiple endpoints.
The details and the actual mapping to the technical endpoints are explained in the SWIM Service Registry.
When a customer wants to consume data from a service, they have to create a subscription. This subscription is a unique identifier that allows the customer to connect to the service and receive data. It follows the Subscription Lifecycle and is managed by the service provider.
What are Queues and Exchanges?¶
While there is no notion of exchanges or queues in the AMQP 1.0 protocol, DWD's SWIM service uses the RabbitMQ implementation of AMQP 1.0, which introduces the concept of exchanges and queues.
The exchange concept is used to route messages to the appropriate queues based on the routing key.
The concept of queues is used to denote a storage mechanism for messages that are sent by the service
and to offer a private endpoint for the customer to connect to and consume the messages.
If the user disconnects the messages are stored in the queue until the user reconnects and consumes them.
These two concepts directly relate to the subscription and service concepts:
- Subscription: A subscription is a unique identifier that allows the customer to connect to a service and receive data. It is represented by a queue in RabbitMQ.
- Service: A service is a unique name that identifies the data being offered. It is represented by an exchange in RabbitMQ.
When a subscription is created, a queue is created in RabbitMQ that is bound to the exchange of the service.
So for the AMQP service offer the concepts of services/subscriptions and exchanges/queues are closely related.
However, this documentation uses the abstract concept of service and subscription to avoid confusion with the RabbitMQ implementation details.
The documentation may only refer to the technical terms whenever necessary, e.g., when talking about the connection details or the AMQP protocol itself.
In AMQP 1.0 as well as in RabbitMQ there is no concept of a topic as it might be known from other messaging systems used, e.g. in the WMO WIS2 system.
There are, however, topic exchanges in RabbitMQ, which are used to route messages to queues based on the routing key.
This is an implementation detail of RabbitMQ and is of no concern for the user of the SWIM service.