Manuscript Offprint
arXiv:2608.25728A Spatially-Aware Publish-Subscribe Middleware for IoT Applications
Philipp Ungrund*, Kurt Rothermel† Sukanya Bhowmik*,
*University of Potsdam, Germany, †University of Stuttgart, Germany
Email: *lastname@uni-potsdam.de, †kurt.rothermel@ipvs.uni-stuttgart.de
Abstract—Spatial and proximity awareness are critical enablers for efficient communication in Cyber-Physical Systems (CPS) and the Internet of Things (IoT). However, the lack of suitable middleware support and standardized mechanisms for spatial awareness significantly limits the pervasiveness of location-dependent applications. In this paper, we present a novel approach that extends topic-based publish-subscribe, a dominant messaging model in this domain, with integrated spatial filtering and routing capabilities. Our approach leverages a highly flexible geometric method for describing spatial filters, enabling expressive and efficient spatial subscriptions. A geometric world model operates together with an enhanced topic-based broker to realize spatially constrained message dissemination. Importantly, this functionality is achieved using the MQTT5 protocol without violating the standard or requiring any modifications to existing client implementations. Experimental results based on both synthetic and real-world data demonstrate strong system efficiency, minimal computational overhead at the broker, and the practical feasibility of deploying the approach on existing IoT devices.
Index Terms—Publish/Subscribe, Spatial-Awareness, Digital Twins, IoT
I. INTRODUCTION
The Internet of Things (IoT) is a significant technology that profoundly impacts everyday life, industries, and the economy. IoT technology focuses on connecting devices and enabling data exchange in networked environments. It is therefore a building block for Cyber-Physical Systems (CPS), which emphasize the close integration of computing, networking, and physical processes to monitor and control real-world assets and processes. Digital twins leverage CPS models and IoT data to enable real-time monitoring, simulation, and optimization of their physical counterparts.
The publish-subscribe (pub/sub) communication paradigm has been identified as a basic building block of the IoT. Publishers send messages without knowing the recipients, and subscribers register for the messages they are interested in without knowing the senders. In topic-based pub/sub, messages are associated with topics, and subscribers register for topics of interest. This communication model allows many-to-many communication, decoupling senders from receivers for better scalability and flexibility. The primary standard for pub/sub communication in the IoT is MQTT [15], alongside protocols like AMQP [27], CoAP [24], etc.
A distinctive feature of CPS is that they maintain digital representations of their physical objects. These digital entities keep state data, which reflects the physical, operational and contextual status of their physical counterparts. This data forms the basis for monitoring, controlling, and optimizing physical entities and real-world processes. Digital entities are also referred to as resources [11], things [23], objects [10], or digital twins [17] elsewhere.
The state of an entity often depend on the states of other physical entities. Therefore, digital entities need to be informed about state changes of the physical entities they depend on, their group of interest. For example, a digital entity representing a particular intersection wants to receive traffic flow data for all adjacent road segments to determine the intersection's current traffic load. Physical entities, like roads and intersections, are situated in space. Therefore, the spatial relationships between these entities provide a powerful means of selecting groups of interest. These relationships define how physical entities interact geometrically; for example, entities may contain, touch, or intersect each other. In our example above, the spatial relation "touches" would be used to determine which road segments are of interest.
Few pub/sub systems support spatial relationships as a message filtering concept. Location-based pub/sub systems (e.g., [5], [9], [12], [13], [16]) support geofencing, a concept that allows subscribers to define an area of interest for each topic. Messages are only forwarded to consumers if they were published in the corresponding area of interest. However, these schemes are limited to a single spatial relation: containment. Furthermore, the location of publishers is used for filtering messages rather than that of the owner of the transferred state. This requires the state owner to be physically co-located with the publisher, which severely limits the placement of publishers.
In this paper, we propose spaPS, a novel spatial pub/sub middleware tailored to the specific needs of CPS. With spaPS, we expand the publish/subscribe paradigm to include physical entities, thereby accommodating the physical aspect of CPS. The digital counterparts of physical objects, which can act as publishers and consumers, represent the virtual part of CPS. Our system supports topic-based message filtering, although the proposed spatial extensions could also be combined with content-based filtering.
Each published message is assigned a topic, which indicates the type of state data included in the message. Additionally, it is associated with the physical entity whose state is transferred in the message. Consumers subscribe to topics and groups of interest, called neighborhoods, inspired by Tobler's first
This is the author's version of the work. It is posted here for your personal use. Not for redistribution. A revised and more concise version of this work is available in proceedings of the DISCOLI workshop of the 22nd IEEE International Conference on Distributed Computing in Smart Systems and the Internet of Things (DCOSS-IoT), 2026.
law of geography [26], which states that nearby things are more relevant than distant ones. In particular, each subscription specifies topics and a neighborhood, indicating the physical entities whose state data the subscriber wants to receive.
spaPS’s architecture leverages the inherent customizability of MQTT version 5 and completely conforms to the standard. With this approach, all additional complexity is confined to the broker while client implementations can stay virtually unchanged. Thus, publishers and subscribers can continue to run on resource-limited devices and the protocol’s lightweight character is kept. For the broker’s implementation, we enhance ActiveMQ Artemis as an open source, multi-core, and highly performant basis [20].
The contributions of this paper are as follows:
• An expressive scheme for specifying neighborhoods based on spatial relationships, which are the foundation of subscriptions.
• An architecture that incorporates spatial filtering on these neighborhoods into classic topic-based pub/sub systems while adhering to the MQTT standard.
• An implementation of this architecture on the ActiveMQ Artemis broker that can be used as a drop-in replacement.
• Extensive evaluations of spaPS that demonstrate the practical feasibility and efficiency of the novel middleware.
With location-based pub/sub, subscribers can use geofencing to define areas of interest (e.g., [5], [9], [12], [13], [16]. Each message is associated with the publisher's location. Messages can only be forwarded to subscribers if the publisher's location falls within one of their areas of interest. All of these systems are based on a simple location model that includes the locations (latitude, longitude) of producers and consumers, as well as a collection of geofences of various shapes, like circles or polygons. However, this simplicity comes with limitations. First, "containment" is the only spatial relation exploited. Second, since messages are associated with the publisher's location rather than the physical entity whose state is included in the message, publishers must be co-located with the corresponding physical entities. This severely limits publisher placement. spaPS's richer world model allows for decoupling physical and digital entities, with the latter being producers and consumers that can be placed anywhere in the IoT infrastructure, including on mobile devices.
For scalability reasons, some location-based pub/sub systems allow publishers to associate messages with an area of relevance (e.g., [13], [21]), meaning a consumer can only receive a message if it is currently located in the corresponding area. While neighborhoods could be used to define groups of relevance, we will not expand on this issue further.
Like spaPS, some location-based pub/sub systems conform to the MQTT standard (e.g., [9], [21]). However, it is important to note that spaPS's concepts and architecture do not depend on any MQTT features. Additionally, one of these systems, LA-MQTT [21], performs location filtering and routing within a dedicated pub/sub client, leading to each publication having to traverse the broker twice. This decreases efficiency and is a conceptual disadvantage in scalability.
A proximity-based service discovery scheme for the IoT is presented in [22]. Although this scheme also uses spatial relations to define service proximity, the neighborhood concept proposed in this paper is tailored to the specific needs of pub/sub communication. Furthermore, the spatial extensions for service discovery differ substantially from those for pub/sub.
spaPS is based on a geometric model that encompasses the relevant physical entities. Appropriate models are widely available, e.g., Geographic information system (GIS) models like OpenStreetMap, NASA EarthData. A vast amount of publicly available geospatial data comes from sources such as the USGS Earth Resources Observation and Science, NASA Earthdata, as well as from crowd-sourced initiatives like OpenStreetMap. Furthermore, Building Information Modeling (BIM) [7] is widely adopted in the architecture, engineering, and construction industry.
III. SYSTEM MODEL

Fig. 1. System Components
In this section, the major components and concepts of spaPS will be introduced. As illustrated, in Fig. 1 the system model comprises the following components: publishers, subscribers, the broker, and the geometric world model. In the following, we will describe these components in detail.
- Publishers, Subscribers, and Broker: Digital entities can publish their state data for consumption by other digital entities or application components. In spaPS, each published message is associated with a topic and a state owner. The topic defines the type of state data that the message transfers, while the state owner is the physical entity to which the state belongs.
Since messages are also associated with physical entities in spaPS, subscribers can filter messages by both topic and state owner. A subscriber registers for a set of topics and a neighborhood, specifying the state owners in which it is interested. For instance, a traffic management entity controlling the traffic lights of an intersection, say I would subscribe to topic /trafficFlow/# and a neighborhood encompassing all road segments that are adjacent to I. Consequently, this entity would receive all traffic flow data directly affecting the traffic load of I. As mentioned above, neighborhoods are specified based on the spatial relations between physical entities. We will propose an expressive scheme for specifying neighborhoods in Sec. IV.
The message broker functions as a central intermediary, thereby decoupling publishers from subscribers. The broker is responsible for receiving messages, filtering them based on topics and neighborhoods, and subsequently routing them to all interested subscribers. The determination of neighborhoods necessitates spatial analysis, for which the broker employs a geometric model encompassing the geometry of the relevant physical entities as well as their spatial relations. This model, discussed next, is referred to as the Geometric World Model.
- Geometric World Model: The Geometric World Model (in short World Model) includes a geometric representation of all physical entities relevant to the application. These entities can be visible material objects, such as buildings or road segments, or immaterial objects, such as traffic zones or national borders.
A physical entity is represented by three attributes:
-
Identifier (denoted by peid), which is unique among all physical entities in the model.
-
Geometry (geom), which defines the entity's position, orientation, size and shape in a coordinate system.
-
Category (Cat) to which the entity belongs. Categories typically group entities based on their purpose or type.
Like topics, categories can be organized hierarchically. For instance, the category road/major/motorway would include the motorway segments in the world model. The World Model also contains spatial relationships between the physical entities. A great variety of models for topological, metric and directional relations has been proposed in literature [6]. In our world model, we will use the relations standardized by the OGC Simple Feature Access [14]. Some of these relations, along with their abbreviations and descriptions, are shown in Table I. The last relation listed in this table is a metric relation, whereas all the others are topological relations.
TABLE I SPATIAL RELATIONS STANDARDIZED BY OGC SIMPLE FEATURE ACCESS [14]
| Relation | Abbrev. | Description |
|---|---|---|
| Equals(a,b) | E | geometries a and b are topological equivalent. |
| Intersects(a,b) | I | a and b have at least one point in common. |
| Disjoint(a,b) | D | a and b have no point in common. This is the logical negation of Intersects(a,b). |
| Touches(a,b) | T | a and b have at least one boundary point in common, but no interior points. |
| Contains(a,b) | C | b lies a and their interiors intersect. |
| DWithin(a,b,d) | DWd | The distance between geometries a and b is less or equal d. |
The OGC Simple Feature Access also defines a set of SQL routines for spatial analysis. In particular, for each of the depicted relationships, there exists a Boolean function that returns true if two geometries relate to each other and false otherwise. All major DBMS vendors support these routines.
We will assume that the world model is quasi-static, similar to maps. This means that changes will result in new model versions. Consequently, the world model does not support mobile physical entities, such as vehicles or people. However, note that this restriction applies only to modeled physical entities, whereas subscribers and publishers may be mobile. Supporting mobile physical entities is subject to future research.
IV. SPECIFYING NEIGHBORHOODS
Neighborhoods are the core concept of spaPS. In this section, we will introduce an expressive method for specifying neighborhoods based on spatial relations.
As mentioned above, the simplest form of a neighborhood specification consists of three attributes: a reference entity, a category, and a spatial relation. This specification can be extended in several ways to increase its expressiveness. First, instead of a single reference and category, we can allow for sets of references and categories. Secondly, rather than a single spatial relation, we can allow multiple relations connected by the logical operators "AND," "OR," and "NOT." These extensions lead to the following neighborhood specification:
Each neighborhood definition consists of a neighborhood name and a neighborhood descriptor, including three attributes: Refs is a non-empty set of references, Cats denotes a non-empty set of categories, and Cond represents a single spatial relation or several logically connected spatial relations. For example, suppose that the entity responsible for traffic control in zone is interested in the real-time traffic flow data of primary road segments in that zone. The corresponding neighborhood can be specified as follows: , where is the abbreviation for relation Contains listed in Table I. Now, assume that this entity only wants traffic data of its border motorway segments, i.e., the segments in that touch 's border: . If the entity were responsible for zones and and were interested in all major roads in these zones, the corresponding neighborhood would be . Note wildcard # in the category pattern.
To precisely define the semantics of the above neighborhood notation, we introduce two functions. Boolean function Related(e1, e2, Cond) checks whether entities e1 and e2 are spatially related according to condition Cond. It returns true if they are related and false otherwise. Note that this function encapsulates the logic for the spatial analysis.
Function Select determines the neighborhood specified by parameters Refs, Cats and Cond. Let Entities(Cats) denote the set of entities belonging to the categories specified by Cats.
Select(Refs, Cats, Cond) = {e ∈ Entities(Cats) - Ref :
This function determines those entities in Entities(Cat) – Ref that are spatially related to at least one entity in Refs according to condition Cond. For example, neighborhood selects all road segments within 1000 meters of segments seg1 or seg2. However, does not include seg1 or seg2, even if the two references are 1000 meters or less apart.
To further increase expressiveness, we introduce multi-stage neighborhoods. We will refer to the neighborhood introduced above as a single-stage neighborhood because it is defined by a single descriptor. In contrast, multi-stage neighborhoods consist of a sequence of chained stages, each of which is specified by an individual stage descriptor. The selection process begins with the first stage and then moves on to subsequent stages. Each stage selects a set of neighboring entities that may serve as input for subsequent stages. While the first stage uses the reference set supplied by the application, each subsequent stage determines its reference set based on neighbors selected in previous stages. Specifically, a stage can adopt the neighbors selected by any subset of its preceding stages.
Assume that an entity responsible for a city’s parking management wants to track the occupancy status of parking facilities that are adjacent to z’s border motorway segments. This neighborhood requires two stages: The first stage yields the border motorway segments of z (see above), which then are adopted as reference set of the second stage. Finally, the second stage selects parking spaces adjacent to at least one entity in its reference set. We will use the following notation to specify a neighborhood with k stages:
A multi-stage neighborhood has a name and consists of a sequence of stage descriptors. The descriptor for the first stage consists of the attributes of a single-stage neighborhood as introduced above. The stage descriptors for subsequent stages differ from this structure only in their first parameter . While parameter of stage 1 passes the set of references supplied by the application, specifies, how the reference set is to be constructed from neighbors selected by the stages preceding stage i. Let the set of stages preceding i be represented by . Then can be any non-empty subset of this set. Each stage identified by contributes neighbors to the set of references of stage i. We will use shorthand and to indicate that is set to and , respectively.
The following equations define how the neighbors of a k-stages neighborhood named N are determined. The neighbors selected in stage i will be denoted :
The first equation defines N[1], the neighbors selected in stage 1. The second equation shows how the reference set of stage i is built based on parameter and the neighbors of preceding stages. Finally, the third equation defines how the neighbors of stage i are selected based on this reference set.
To illustrate the effect of the various settings of parameter RefStages, we will examine the neighborhoods in Table II.
TABLE II EXAMPLE NEIGHBORHOODS
For neighborhood , we assume that the traffic control entity subscribes to traffic data from the road segments in zone z. To take also into account the traffic situation in neighboring zones, it additionally needs to receive traffic data from road segments within 3 hops of z. For stages 2 through 4 the RefStages parameter is set to Prev, which ensures that the neighbor sets selected by the 4 stages are mutually disjoint. contains all segments contained in z, and ( ) include all segments at a distance of hops from z. For neighborhood , we assume a parking management entity that tracks the occupancy status of parking facilities that are accessible via the road segments identified by . Neighborhood has an additional 5th stage that specifies neighbors in the transport/parking category. In neighborhood , only stages 2 through 4 contribute to the reference set of stage 5. Therefore, includes only parking spaces accessible via road segments outside z and reachable within three hops from z.
Finally, we will introduce the concept of a stage filter. So far, a k-stage neighborhood includes all neighbors for . However, a subscriber might be only interested in neighbors of a subset of stages. In the example above, the parking management entity is only interested in the parking facilities selected in the final stage of neighborhood . To enable subscribers to choose which stages are included in the final neighborhood, we attach parameter Visible, which is a Boolean vector with dimension k for a k-stage neighborhood. Entities selected in stage j will only be included if Visible[j] is set to true. The final neighborhood is the union of the neighbors selected by visible stages of N.
V. THE SPAPS MIDDLEWARE
A. System Architecture
The overall system architecture of spaPS follows the system model in Figure 1. The system components of this architecture are comprised of the spatial broker - an enhanced topic-based pub-sub broker that integrates with a spatial database - and clients, which can assume publishing and subscribing roles. The spatial database holds the world model and is queried by the spaPS broker for neighborhood resolution. The details of our broker architecture is depicted in Figure 2.
As mentioned above, a neighborhood subscription consists of a topic and a neighborhood. We refer to the action of issuing such a subscription as a neighborhood subscribe. Issuance of a neighborhood subscribe within the broker triggers a corresponding service provided by the spatial database called neighborhood resolution. This neighborhood resolution produces a mapping between the specific subscription and the relevant physical entity identifiers (peid), which we refer to as spatial filters. Conversely, we refer to the action of sending a publication that includes a peid as a spatial publish.
Internally, the spaPS broker receives publications and subscriptions via a protocol handler, which interfaces with a (i) subscription manager and a (ii) publication manager. For each subscription of a subscriber, the broker maintains a message queue to deliver publications. The subscription manager maintains the state of the topic filter mapping and the spatial filter mapping, and updates a queue manager that maintains the aforementioned queues. It also employs the neighborhood resolver to add new spatial mappings to the spatial filter mapping in response to neighborhood subscriptions. Conversely, the publication manager leverages the queue manager, topic filter mapping, and spatial filter mapping to filter publications and route them to the appropriate subscription message queues.

Fig. 2. Broker Architecture
B. Subscription Handling
For each incoming subscription four steps are performed: (i) a new message queue is created and associated with the subscription, (ii) the subscription's topic and identifier are added to the topic filter mapping, (iii) the neighborhood is resolved via the spatial DBMS with a neighborhood query, and finally (iv) the neighborhood's resolved set of peids is added to the spatial filter mapping. Next, we discuss the last two steps in detail.
- Processing Neighborhood Queries: The following outlines how neighborhood resolution queries are processed on the DBMS site. To improve readability, we will use pseudocode rather than SQL to sketch the major stored procedure that resolves a given neighborhood into a set of neighbors.
The used DBMS tables are depicted in Listing 1. Table PhysEntities contains a single row for each physical entity, which comprises the identifier and geometry of the corresponding entity. Note that this information is available in virtually all geometric models; hence the content of this table can be extracted from existing data sets. Table catMembers implements a many-to-many mapping between categories and physical entities. View catLayers adds geometry information to each pair (peid, cat), i.e., this table represents the category layers of our world model. NTable is a temporary table that is used to compute the members of a neighborhood. When the computation is finished, it contains the final neighborhood, where each member is identified by peid, and geom and stageNo specify the entity's geometry and the stage in which it was selected, respectively.
TABLE physEntities (peId physEntityId, geom geometry) TABLE catMembers (cat Category, peid physEntityId) MATERIALIZED VIEW catLayers AS SELECT c.peId, c.cat, p.geom FROM catMembers AS c JOIN physEntities AS p ON c.peId=p.peId TEMPORARY TABLE NTable (stageNo int, peId physEntityId, geom geometry)
Listing 1. DBMS Tables
The algorithm for selecting neighborhoods is outlined in Listing 2. It shows the major data types and the stored function that computes the neighborhood for a given neighborhood descriptor. A neighborhood descriptor is passed in an array of type nhoodDes, which includes a stage descriptor for each specified stage. A stage descriptor of type stageDes, specifies the neighbors to be selected in the corresponding stage. It consists of the components refStages, cats, and sCond. The component refStages lists the previous stages whose selected neighbors are to be merged to constitute the reference set of the current stage. Components cats and sCond define the desired neighbor categories and the spatial condition that a member must fulfill, respectively. Finally, the entity descriptor entityDes comprises the identifier and geometry of the corresponding physical entity. Function selectNeighborhood selects the neighborhood specified by descriptor nd and references refs. Parameter visible defines which stages will be visible in the final result. First, temporary table NTable is created, which is used to record the selected neighbors during stage processing. Next, function
TYPE stageDes (refStages int, cats Category[], sCond spatialCondition) TYPE nhoodDes stageDes[]; TYPE entityDes (peid physEntityId, geom geometry) FUNCTION selectNeighborhood (refs physEntityId[], nd nhoodDes, visible BOOLEAN[]) RETURNS physEntityId[]; DECLARE refEntities entityDes[]; stageNeighbors entityDes[]; BEGIN CREATE TEMPORARY TABLE NTable; refEntities := GetGeometry(refs); InsertIntoNTable (0, refEntities); nd[1].refstages := ARRAY[0]; FOR i IN 1..array_upper(nd,1) LOOP refEntities := mergeRefEntities(nd[i].refStages); stageNeighbors := selectStageNeigh(refEntities, sd[i].cats, sd[i].sCond); insertIntoNTable(i, stageNeighbors); END LOOP; RETURN filterNTable(visible); END;
Listing 2. Algorithm for Selecting Neighborhoods
GetGeometry retrieves the geometry of each physical entity identified by refs from table catLayers. The resulting entity descriptors are inserted in NTable as stage 0 neighbors. By setting refStages of the stage 1 descriptor to refer to stage 0, allows stage 1 to be treated as any subsequent stage.
The body of the loop is executed once for each specified stage. First, function MergeRefEntities delivers the reference entities for the current stage, say i, by merging the stage neighbors of the stages identified by refStages in i's descriptor. This function operates on table NTable, which records all neighbors selected in stages preceding i. Next, function selectStageNeigh computes the stage i neighbors based on refStages as well as the categories and spatial conditions specified for stage i. This function operates on table catLayers and uses the spatial predicates provided by the DBMS [14] to analyze which entities fulfill the spatial conditions. Processing of stage i ends with inserting the selected stage i neighbors into table NTable. After processing all stages, function filterNTable returns the identities of neighbors belonging to visible stages.
- Spatial Filter Mapping: As explained above, the neighborhood resolution returns a set of peids for each subscription, resulting in an update to a spatial filter map. This map contains a mapping of unique subscription identifiers to a set of peids.
For this, the architecture distinguishes between two main conceptual implementation variants that differ in where and how the mapping is stored. The first mode stores the mapping as a table within the DBMS and makes those tables available to the broker through stored procedures. The second mode stores the spatial filter mapping within the broker's main memory.
The table of the in-database variant has two columns: one for the subscription identifiers and another for the peids. Both columns have a B-tree index on them, resulting in a asymptotic time complexity for the addition of a new spatial filter. F denotes the number of spatial filters (i.e., subscriptions) and S denotes the average filter size (i.e., number of peids associated with a spatial filter).
The main memory mapping consists of a hash map with the peids as keys and hash sets with associated subscription identifiers as values. Here, the time complexity for addition of a subscription is .
C. Publication Filtering & Routing
Filtering publications is carried out in three distinct steps. All active subscription identifiers are first filtered against an incoming publication by topic such as in traditional topic-based pub/sub with the topic filter mapping, resulting in a subset of all subscriptions denoted by . Next, this subset is filtered by spatiality with the spatial filter mapping. In this process, we perform a lookup of the spatial filter map with the publication's peid, resulting in the set of matching subscriptions denoted by . The function for this can be defined as follows:
For the final step, each subscription of is chosen for routing and the publication is added to the subscription's corresponding message queue, from which it is eventually delivered to the subscriber.
Of course, the overhead of filtering is different for the two aforementioned modes. The lookup of the in-database mode has a complexity of and the main memory mode has a complexity. Note that this architecture favors publication filtering over filter addition for the main memory mapping. An inverted index with the subscription identifiers as key and peids as values could provide an complexity for filtering and for filter addition.
VI. IMPLEMENTATION
With the architecture from the preceding section, we end up with four distinct parts requiring implementation:
-
A spatial database that contains the geometric world model, providing neighborhood resolution as a service and storage for an in-database mapping of the results;
-
A topic-based pub/sub broker that incorporates spatial filtering capabilities based on the spatial filter mapping, which it constructs through the spatial database in response to neighborhood subscriptions;
-
A message codec that efficiently abstracts topic-based pub/sub communication while supporting representations for neighborhood descriptors in subscription messages and physical entity identifiers in publication messages;
-
A spatial client (library) that leverages the message codec and provides an interface to the spatial pub/sub middleware, enabling IoT and CPS devices to participate as subscribers and publishers.
We based the realization of this architecture, which is detailed in the following sections, on several well-established open-source projects. The message broker Apache ActiveMQ Artemis, together with enhancements to it, serves as the spatial pub/sub broker. The spatial database component is implemented using the PostGIS database management system. Location filter information is encoded using version 5 of the MQTT topic-based pub/sub protocol. Finally, the spatial client is built on top of Eclipse's paho-mqtt project for MQTT client implementations. More details on the implementation can be found in App. A.
VII. EVALUATION RESULTS
In this section, we show the behavior of the in-database and main memory mapping modes of spaPS.
A. Experimental Setup
Our experimental setup consists of three identical machines with 13th Gen Intel Core i9-13900K 24-core processors. Machine 1 runs the publishers, Machine 2 the subscribers, and Machine 3 the spatial broker. Furthermore, we deployed the spatial broker and database in separate Docker containers on Machine 3. With regard to the enhanced Artemis, we configured it according to the documentation's notes on performance tuning and turned persistence off.
To establish the general performance of spaPS, we used synthetically generated spatial filter mappings as this provides better control of environmental variables like the matching of publications with subscriptions and the client distribution. The general characteristics of the spatial filter in terms of number of subscriptions as well as average filter size is also independent of neighborhood resolution itself. Moreover, we performed experiments on real data by leveraging Berlin OpenStreetMap data. The dataset is freely available through Geofabrik and ODIS Berlin and - after pre-processing - includes the road network as well as certain shops and businesses as a basis for neighborhoods. Subscribers are randomly generated on this by the road network's traffic distribution and assumed to be vehicles. These subscribers use a Zipfian distribution for randomly selecting reference points around them as the basis for neighborhoods.
B. Performance & Scalability
-
Throughput: Figure 3a shows the throughput under a static, synthetic regime of 1 000 subscriptions with a spatial filter size of 2 000 peids by varying the publish rate for both types of mapping (in-database and main memory). The subscriptions are composed of a 100 subscribers with each having 10 subscriptions. The graphs show the median total filtering time in s as the throughput measure. As expected, the main memory mode performs better than the in-database mode as the communication overhead between Artemis and PostGIS is not required in the main memory mode. In both cases, the filtering time increases with the publish rate, but the increase is steeper for the in-database mode. Consequently, the in-database mode performs well up to around 150 000 messages/s, while the main memory mode scales much better to around 250 000 messages/s. Above these the system ceases to function timely. Overall, considering the large scale of these experiments, w.r.t. number of subscriptions and spatial filter size, spaPS exhibits high efficiency in terms of very low latencies for filtering in both modes (always in s) and very high publish rates for especially main memory mode.
-
Impact of Number of Subscriptions: The number of subscriptions can impact the total filtering time as discussed in Sec. V. Figure 3b shows the total filtering time under a constant publish rate of 100 000 messages/s and a fixed spatial filter size. Both mappings display a slowly growing filtering time with increasing number of subscriptions in the lower microseconds. While the in-database mode has a slightly faster growing rate and more variability, it has a consistently higher filtering time compared to the main memory mode. This is because of the additional overhead of database communication for the in-database mode. As can be seen, the filtering time of both modes is in s, showing the filtering efficiency of spaPS.
Figure 3c shows the time for the addition of a new filter (in ms) to the mappings under the same constant publish rate and fixed spatial filter size. To measure the filter addition time, we introduced a subscription churn rate (i.e., the number of subscriptions added and removed per second) of 10 to the system. The graph clearly shows the advantage of the main memory mode over the in-database mode by a constant addition time to a logarithmically increasing time.
- Impact of Spatial Filter Size: A second important factor on the behavior of the spatial filter is the average spatial filter size (no. of peids associated with a spatial filter). Figure 3d and Figure 3e show the impact of a variable spatial filter size on the total filtering time and subscription addition time, respectively. The number of subscriptions is fixed at 1 000 and the publish rate at 100 000 messages per second. In the experiments in Figure 3e, we introduce a subscription churn rate of 10 again to measure the filter addition time.
Considering the filtering time in Figure 3d, both modes exhibit a constant time in the low s over the chosen range of spatial filter size. The in-database mode's time is about s higher and shows a slightly increased variability. A logarithmic increase in this mode is not distinguishable under the chosen parameters, highlighting the efficiency of the system.
For the filter addition time, the in-database mode shows a logarithmic increase and the main memory mode a more linear increase (note the log scale). The in-database mode performs worse for filter addition under this variable than the main memory mode, which exhibits values in the s in contrast to the in-database mode that already starts out in the ms.
C. Performance under Real-World Data
The final two experiments that Figure 3f and Figure 4 show use the above discussed real-world dataset. In Figure 3f, we conducted the experiments with 1 000 1-stage neighborhood subscriptions. These resulted in a set of 592 publishers that had an overall publish rate of 50 000 messages/s. This graph uses the data of the measurements taken at a churn rate of 100 and shows the rolling median total filtering time (in s) over the first 5 seconds for both modes. After an initial warm-up

(a) Throughput

(b) Total Filtering Time

(c) Subscription Addition Time

(d) Total Filtering Time

(e) Subscription Addition Time
Fig. 3. Evaluation Results

(f) Total Filtering Time: Real-World Data

Fig. 4. Subscription Addition Time: Real-World Data
period of around 200 ms both modes settle around a constant filtering time. Again, the main memory mode exhibits a better performance than the in-database mode.
In Figure 4 we evaluate the behavior of multi-stage neighborhood resolution compared to single-stage neighborhoods for the main memory mode. Note that, in the case of real-world data, the time for actually resolving a neighborhood by the DBMS leads to additional overhead. Here we show the median subscription addition time under variable churn rate with regards to the scope of neighborhoods. The smaller neighborhood is depicted as 100m and the larger one is depicted as 500m. As expected, the single-stage resolution is faster than the multi-stage resolution, whereas the neighborhood scope only has a small effect in this case. The in-database mode showed similar behavior and was therefore omitted from the plot for clarity.
VIII. Conclusion
In this paper, we presented spaPS, a pub/sub middleware that incorporates a novel approach of spatial awareness into subscriptions and publications. Subscriptions' spatial interests are defined through so-called neighborhoods and resolved into sets of physical entity identifiers. These identifiers are associated with spatial attributes of a geometric world model and are added to publications to enable spatial filtering. Our evaluation results of a prototype implementation of spaPS show highly efficient behavior of the system on synthetic as well as real-world data. Additionally, the results highlight the practical feasibility of incorporating this approach into existing pub/sub solutions and enabling new applications that rely on IoT communication based on the spatial relations of devices and loose coupling.
REFERENCES
[1] Raphaël Barazzutti, Pascal Felber, Christof Fetzer, Emanuel Onica, Jean-François Pineau, Marcelo Pasin, Etienne Rivière, and Stefan Weigert. Streamhub: A massively parallel architecture for high-performance content-based publish/subscribe. In Proc. of the 7th ACM Int. Conf. on Distributed Event-based Systems, 2013.
[2] Sukanya Bhowmik, Muhammad Adnan Tariq, Jonas Grunert, Deepak Srinivasan, and Kurt Rothermel. Expressive content-based routing in software-defined networks. IEEE Trans. on Parallel and Distributed Syst., 29(11):2460–2477, 2018.
[3] Sukanya Bhowmik, Muhammad Adnan Tariq, Lobna Hegazy, and Kurt Rothermel. Hybrid content-based routing using network and application layer filtering. In 36th IEEE International Conference on Distributed Computing Systems, ICDCS 2016, Nara, Japan, June 27-30, 2016, pages 221–231. IEEE Computer Society, 2016.
[4] Sukanya Bhowmik, Muhammad Adnan Tariq, Boris Koldehofe, Frank Duerr, Thomas Kohler, and Kurt Rothermel. High performance publish/subscribe middleware in software-defined networks. IEEE/ACM Transactions on Networking, 25(3):1501–1516, 2017.
[5] Bertil Chapuis, Benoit Garbinato, and Lucas Mourot. A horizontally scalable and reliable architecture for location-based publish-subscribe. In 2017 IEEE 36th Symposium on Reliable Distributed Systems (SRDS), pages 74–83. IEEE, September 2017.
[6] Juan Chen, Anthony G. Cohn, Dayou Liu, Shengsheng Wang, Jihong Ouyang, and Qiangyuan Yu. A survey of qualitative spatial representations. The Knowledge Engineering Review, 30(1):106–136, 2013.
[7] Charles M. Eastman, editor. BIM handbook. Wiley, Hoboken, NJ, 2. ed. edition, 2011.
[8] Patrick Th. Eugster, Pascal A. Felber, Rachid Guerraoui, and Anne-Marie Kermarrec. The many faces of publish/subscribe. ACM Comput. Surv., 35(2):114–131, jun 2003.
[9] Andrew Fisher, Gautam Srivastava, and Robert Bryce. Mqttg: An android implementation. In 42nd Int. Conf. on Telecommunications and Signal Processing (TSP). IEEE, 2019.
[10] OPC Foundation. Opc unified architecture part 1: Overview and concepts, 2025.
[11] Open Connectivity Foundation. OCF core specification, 2025.
[12] Long Guo, Lu Chen, Dongxiang Zhang, Guoliang Li, Kian-Lee Tan, and Zhifeng Bao. Elaps: An efficient location-aware pub/sub system. In 2015 IEEE 31st International Conference on Data Engineering, pages 1504–1507. IEEE, April 2015.
[13] Jonathan Hasenburg and David Bermbach. Geobroker: Leveraging geo-contexts for iot data distribution. Computer Communications, 151:473–484, February 2020.
[14] John R. Herring. Opengis® implementation standard for geographic information - simple feature access - part 2: Sql option. OpenGIS® Implementation Standard OGC 06-104r4, Version: 1.2.1, Open Geospatial Consortium Inc., August 2010.
[15] Urs Hunkeler, Hong Linh Truong, and Andy Stanford-Clark. Mqtt-s—a publish/subscribe protocol for wireless sensor networks. In Proc. of Int. Conf. on Comm. Syst. Software and Middleware and Workshops, 2008.
[16] Felicien Ihirwe, Giovanni Iovino, and Davide Di Ruscio. Towards an mqtt5 geo-location extension for location-aware applications. In 2021 44th International Conference on Telecommunications and Signal Processing (TSP), pages 100–105. IEEE, July 2021.
[17] ISO. Digital twins - concepts and terminology, 2023.
[18] Petri Jokela, András Zahemszky, Christian Esteve Rothenberg, Somaya Arianfar, and Pekka Nikander. LIPSIN: line speed publish/subscribe inter-networking. ACM SIGCOMM Computer Communication Review, 2009.
[19] Ming Li, Fan Ye, Minkyong Kim, Han Chen, and Hui Lei. A scalable and elastic publish/subscribe service. In Proc. of IEEE Int. Parallel & Distributed Processing Symp., 2011.
[20] Biswajeeban Mishra, Biswaranjan Mishra, and Attila Kertesz. Stress-testing mqtt brokers: A comparative analysis of performance measurements. Energies, 14(18):5817, 2021.
[21] Federico Montori, Lorenzo Gigli, Luca Sciullo, and Marco Di Felice. La-mqtt: Location-aware publish-subscribe communications for the internet of things. ACM Trans. on Internet of Things, 3(3):1–28, 2022.
[22] Kurt Rothermel, Otthein Herzog, and Siegfried Wu Zhiqiang. Proximity-based service discovery for distributed digital twin systems. Discover Internet of Things, 5(1), February 2025.
[23] E. Korkan (ed.) S. Kaebisch, M. McCool. Web of things (wot) thing description. Technical report, W3C Recommendation, 2023.
[24] Zach Shelby, Klaus Hartke, and Carsten Bormann. The constrained application protocol (coap). Technical report, 2014.
[25] Muhammad Adnan Tariq, Boris Koldehofe, Sukanya Bhowmik, and Kurt Rothermel. PLEROMA: a sdn-based high performance publish/subscribe middleware. In Proc. of the 15th Int. Middleware Conf. ACM, 2014.
[26] Waldo. R. Tobler. A computer movie simulating urban growth in the detroit region. Economic Geography, Supplement: Proceedings, 46:234–240, 1970.
[27] Steve Vinoski. Advanced message queuing protocol. IEEE Internet Computing, 10(6):87–89, November 2006.
APPENDIX A IMPLEMENTATION DETAILS
We based this implementation on several well-established open-source projects. The message broker Apache ActiveMQ Artemis, together with enhancements to it, serves as the spatial pub/sub broker. The spatial database component is implemented using the PostGIS database management system. Spatial filter information is encoded using MQTT version 5 topic-based pub/sub protocol. Finally, the spatial client is built on top of Eclipse's paho-mqtt project for MQTT client implementations.
Apache’s ActiveMQ Artemis is a multithreaded pub/sub broker and the direct successor to ActiveMQ Classic. It offers high throughput and efficiency as well as support for multiple pub/sub protocols, including MQTT and STOMP. In addition, the broker provides clustering capabilities for load distribution and persistence. Our enhancements extend Artemis with changes to the broker state and the introduction of a main-memory spatial filter mapping.
PostGIS is an extension to the free and open-source relational DBMS PostgreSQL that provides comprehensive geospatial support. It offers spatial data types such as lines and polygons for both two- and three-dimensional space, spatial indexing, a wide range of spatial functions, and more. Access to the stored data from external applications is provided through JDBC.
The transmittance of spatial publications and neighborhood subscriptions requires a clear and well-defined representation of semantics that all communication participants understand. We chose the topic-based MQTT version 5 (MQTT5) pub/sub protocol as the basis, as it is the de-facto industry standard, already provides the general semantics needed and supports application-level customization. Consequently, our implementation conforms fully to the existing standard.
MQTT5 defines 15 different control packet types for conveying information such as publications. In addition, it supports three levels of quality of service (QoS) for message delivery guarantees, denoted 0, 1, and 2. QoS 0 provides almost-once semantics, QoS 1 at-least-once semantics, and QoS 2 exactly-once semantics. The focus of this work limits itself to QoS 0 delivery semantics and does not study the implications of client authentication, which MQTT5 also supports. With these constraints, the number of relevant control packet types is reduced to the five basic ones: Connect, Disconnect, Subscribe, Unsubscribe, and Publish.
Some MQTT5 control packet types support fields referred to as user properties, which are key-value pairs encoded as UTF-8 strings and can be used freely to provide application-specific information without any changes to the standardized protocol itself. Older versions of MQTT do not support user properties. The Connect, Disconnect, Subscribe, Unsubscribe, and Publish packet types all support user properties. For a neighborhood subscribe, the Subscribe packet type requires two user properties: a neighborhood subscription identifier and a neighborhood descriptor that encodes the neighborhood descriptor as a JSON UTF-8 String. The Unsubscribe control packet requires only the neighborhood subscription identifier. (Note: the identifiers could also be defined by the broker and returned in the Suback control packet type, which acknowledges a subscription. This could guarantee the system-wide uniqueness of identifiers.)
For the Publish control packet, two cases must be distinguished: publications sent from a client to the broker and filtered publications forwarded from the broker to subscribers. In the first case, the Publish packet includes a user property containing only the physical entity identifier. In the second case, the broker injects the matching spatial filter identifier into the publication as an additional user property so that the subscriber can associate the publication with a specific neighborhood subscription. Without this additional property, a client with two neighborhood subscriptions to the same topic could not determine from which neighborhood a given publication originates.
Clients — acting as publishers and subscribers — that utilize the middleware must, in principle, only adhere to the MQTT5 specification for communication and encode the additional spatial information using user properties. The actual client applications themselves are irrelevant to the middleware as long as the world model is maintained within the spatial database. Consequently, any MQTT5-compliant client library is sufficient, provided it supports writing and reading user properties.
Paho, an IoT project of the Eclipse Foundation, offers MQTT client implementations in various programming languages. Its Java, Python, C, and C++ libraries support MQTT5 in addition to MQTT versions 3.1 and 3.1.1. For our implementation, we selected the paho-mqtt Python library, as it provides a simple interface and enjoys broad adoption. A lightweight wrapper around the library's MQTTClient object, as well as its subscribe, unsubscribe, and publish methods, is sufficient to enable communication with the spatial pub-sub middleware. The unsubscribe and publish methods include an additional integer argument for the neighborhood subscription identifier and the physical entity identifier, while the subscribe method takes, as an additional argument, a string representing the neighborhood descriptor in JSON format.