A Lightweight Annotation-Driven HTTP Middleware for IoT Applications Based on Remoting Patterns
Overview This preprint presents the design, implementation, and preliminary experimental evaluation of a lightweight, annotation-driven HTTP middleware for Internet of Things (IoT) applications based on remoting patterns. Implemented in Java without relying on a web framework or servlet container, the middleware separates network communication, request routing, parameter conversion, remote invocation, and error handling from application-specific domain logic. The architecture combines annotation-based component discovery, reflection-based method invocation, non-blocking network communication, bounded thread-pool execution, lifecycle management, and observability services. An IoT application for sensor registration, data collection, and visualization was developed to demonstrate the middleware's programming model and architectural capabilities. System Architecture The system is organized as a modular Maven project comprising two main modules: Middleware: Provides the HTTP server, component container, routing mechanisms, invocation services, serialization, lifecycle management, and infrastructure endpoints. IoT Application: Implements sensor registration, reading collection, data storage, simulation, and a web dashboard. The architecture maintains a unidirectional dependency between the application and the middleware, ensuring that the middleware remains independent of application-specific domain concepts. The HTTP processing pipeline includes: Non-blocking connection management through Java NIO. HTTP request parsing and response serialization. Annotation-driven component discovery. Static and parameterized route resolution. Automatic parameter binding and type conversion. Reflection-based method invocation. JSON serialization and deserialization. Standardized exception-to-HTTP error mapping. Annotation-Driven Programming Model The middleware defines six annotations that allow developers to expose ordinary Java classes and methods as remote HTTP components: @RemoteComponent: Registers a class as a remote component. @RemoteMethod: Defines the HTTP operation, path, method, and response type. @Param: Binds values from path variables and query parameters. @Body: Binds JSON request bodies to method parameters. @OnStart: Defines component initialization operations. @OnStop: Defines component shutdown operations. This programming model allows application developers to define remote operations without directly implementing HTTP connection handling, request parsing, routing, or response generation. Remoting Patterns The middleware architecture implements eight server-side remoting patterns, organized into four categories: Basic Remoting Patterns Server Request Handler — NioHttpServer. Invoker — Router and Invoker. Marshaller — JsonParser and JsonWriter. Remoting Error — ErrorMapper. Identification Patterns Object ID — Component paths registered in Router. Lifecycle Management Patterns Static Instance — Shared component instances maintained by the middleware registry. Extended Infrastructure Patterns Lifecycle Manager — LifecycleManager. QoS Observer — RequestMetrics. The implementation provides an explicit correspondence between architectural patterns and software components, making the request-processing flow and component responsibilities identifiable within the codebase. Client-side proxies, invocation interceptors, leasing, and asynchronous invocation patterns are outside the scope of the current implementation. Concurrency and Runtime Services The concurrency architecture combines the Reactor pattern with a bounded worker-thread execution model. A single reactor thread manages network events through a Java NIO selector, while a fixed-size worker pool executes application requests. The execution queue is limited to 1,024 tasks. When both the worker pool and its queue are saturated, the reactor executes incoming tasks directly, introducing a backpressure mechanism that temporarily restricts further network reads. Additional runtime capabilities include: Shared read-buffer pooling. Singleton-like component instances shared across worker threads. Ordered component initialization and shutdown. Timeout-controlled shutdown operations. Runtime configuration management. HTTP-accessible metrics. Prometheus-compatible metrics exposition. Application and infrastructure health endpoints. The manuscript also documents a lifecycle-related limitation affecting the middleware's infrastructure health endpoints. IoT Application An independent IoT application was implemented to demonstrate the middleware's capabilities in a sensor-oriented use case. The application supports: Sensor registration and management. Sensor reading collection. Temperature, humidity, pressure, light, and sound sensors. In-memory state management. JSON-based data storage. Internal sensor simulation. External HTTP-based data ingestion. Web-based sensor visualization. Application-level performance monitoring. The application operates in two modes: an internal simulation mode, which generates sensor readings without physical devices, and an external mode, which receives sensor data through HTTP requests. Experimental Design The experimental methodology was designed as a three-phase Apache JMeter campaign: Baseline: 10 concurrent users, 30-second ramp-up, and 180-second duration. Load: 200 concurrent users, 120-second ramp-up, and 300-second duration. Stress: 1,000 concurrent users, 300-second ramp-up, and 600-second duration. The campaign evaluates response times, throughput, error rates, and capacity-related behavior across sensor registration, reading submission, application health, and performance-monitoring operations. Only the baseline phase was executed. The load and stress phases remain planned experimental activities. Preliminary Experimental Results The baseline experiment with 10 concurrent users recorded: Total HTTP requests: 909. Requests classified as successful by JMeter: 859. Timed-out requests: 50. Overall error rate: approximately 5.50%. Median response time for successful requests: 12 ms. 95th percentile response time for successful requests: 21 ms. Maximum response time for successful requests: 192 ms. Overall average throughput: 4.7 requests per second. All recorded timeouts occurred during sensor registration. These results characterize the behavior observed during a single baseline execution and should not be interpreted as measurements of maximum server capacity or scalability. Software Defect Analysis The experimental evaluation revealed a defect in the middleware's HTTP request-body processing. The implementation compares the Content-Length value, expressed in bytes, with the number of received characters. This discrepancy causes requests containing multibyte UTF-8 characters to be incorrectly classified as incomplete. The issue was observed in temperature-sensor registration requests containing the degree symbol (°C), causing the server to continue waiting for additional data until the client timed out. The defect was investigated through the recorded test data and reproduced using equivalent requests with and without the affected character. The manuscript identifies byte-based request-body length verification as the appropriate corrective direction. Main Contributions A lightweight HTTP middleware implemented in Java without external web frameworks or servlet containers. An explicit mapping of eight remoting patterns to identifiable software components. An annotation-driven programming model for component discovery, route registration, parameter binding, remote invocation, and lifecycle management. A concurrent HTTP processing architecture combining non-blocking I/O, the Reactor pattern, bounded worker-thread execution, and backpressure. An independent IoT application demonstrating the middleware's programming model in a sensor-oriented use case. A structured Apache JMeter evaluation methodology accompanied by preliminary baseline results. An experimentally motivated investigation of a request-body processing defect involving multibyte UTF-8 content. Scope and Limitations This work is positioned as an academic middleware implementation intended to demonstrate architectural principles, remoting patterns, and concurrent HTTP request processing rather than to compete with production-grade web frameworks. The available experimental evidence is limited to a single baseline execution with 10 concurrent users. Additional limitations include: Co-location of the JMeter client and HTTP server on the same machine. Potential performance interference from detailed diagnostic logging. Reuse of a limited sensor dataset containing 14 entries. HTTP success responses that do not consistently represent successful domain-level operations. A lifecycle-related defect affecting middleware health endpoints. Lack of preservation of the exact source-code revision executed during the baseline experiment. Consequently, the reported results do not establish scalability, maximum throughput, knee capacity, or usable capacity. Reproducibility and Supporting Artifacts The manuscript documents the architectural organization, annotation model, remoting-pattern mapping, concurrency mechanisms, HTTP interfaces, experimental configuration, baseline results, and identified implementation limitations. Full reproduction requires access to the corresponding Java source code, Maven configuration, Apache JMeter test plans, sensor datasets, experimental logs, and execution environment. Supporting software artifacts and experimental datasets may be associated with this record when made available. Publication Status This record contain
Authors
- Douglas Felipe Lima Silva (ORCID: https://orcid.org/0009-0007-9868-4891)
Publication Details
- Journal
- Zenodo (CERN European Organization for Nuclear Research)
- Published
- 2026-12-03
- DOI
- https://doi.org/10.5281/zenodo.24801099
- Primary Topic
- Service-Oriented Architecture and Web Services
- Type
- preprint