# A Scalable Framework for Sensor Data Ingestion and Real-Time Processing in Cloud Manufacturing
## Appendix A  
In this appendix section, we presented a series of innovative pseudocodes corresponding to key layers of the proposed framework. Algorithm A1 outlines the pseudocode for the description of the Kafka producer considering varying input workloads. ```
0: Kafka and essential libraries (pandas, json, etc.) 0: Message count, total time, and throughput metrics Initialize logger with INFO level and load dataset as data for max_messages in {100, 1000, 10000} do  Sample data_sample of size max_messages from data Initialize Kafka producer and start_time for each row in data_sample up to max_messages do  Produce message to 'temp_humidity_topic'; increment message_count Log progress every 10 messages; sleep 0.001s for simulation endfor  Flush producer, calculate total_time and throughput as message_count / total_time Log final metrics: message_count, total_time, and throughput endfor
```  
**Algorithm A2** Kafka Consumer Pseudocode  
Algorithm A2 reports the pseudocode defining the Kafka consumer tool, still considering varying numbers of input messages. ```
0: Kafka and essential libraries (json, time, etc.) 0: Processed message count, total time, and throughput metrics Initialize logger with INFO level and set consumer_config with Kafka parameters Initialize Kafka consumer with consumer_config and subscribe to 'temp_humidity_topic' function consume_messages(max_messages) Start timer (start_time); initialize message_count to 0 while message_count < max_messages do  Poll for messages with timeout if message error then  Log error and continue polling else  Decode JSON message, log message, and increment message_count if message_count is divisible by 10 then  Log progress  endif endif endwhile  Calculate total_time and throughput as message_count / total_time Log final metrics and close consumer endfunction Run consume_messages for max_messages values {100, 1000, 10000}
```  
**Algorithm A3** Kafka Consumer Pseudocode  
Furthermore, we described the pseudocodes for, respectively, configuring both RabbitMQ producer and consumer with varying input workloads (Algorithms A3 and A4). ```
**Algorithm A3** RabbitMQ Producer Pseudocode
```
0: Total messages sent, total time, and throughput metrics Initialize logger with INFO level Read dataset as data for max_messages in [100, 1000, 10000] do Sample data with max_messages rows as data_sample Establish RabbitMQ connection and declare durable queue 'temp_humidity_queue' Start timer (start_time) and log initial message Initialize message_count to 0 for each row in data_sample do Convert row to json and publish to RabbitMQ queue 'temp_humidity_queue' Increment message_count and sleep briefly if message_count is divisible by 10 then Log progress endif endfor  Close connection, calculate total_time, and compute throughput Log final metrics and output: \"Total Messages: message_count\", \"Total Time: total_time\", \"Throughput: throughput\" endfor ```
**Algorithm A4** RabbitMQ Consumer Pseudocode
```
0: Total messages consumed, total time, and throughput metrics Initialize logger with INFO level Establish RabbitMQ connection and declare durable queue 'temp_humidity_queue' for max_messages in [100, 1000, 10000] do Set start_time and initialize message_count to 0 function callback(ch, method, properties, body) Parse body as message_data; log data and acknowledge message Increment message_count if message_count is divisible by 10 then Log progress endif if message_count \(\geq\) max_messages then Stop consuming endif endfunction Log start; set prefetch to 1; register callback and start consuming On exit, calculate total_time and compute throughput Log final metrics and output: \"Total Messages: message_count\", \"Total Time: total_time\", \"Throughput: throughput\" Close connection endfor ```
**Algorithm A5** Spark Streaming Code for Real-Time Monitoring

The pseudocode for configuring the Data Processing and Analytics layer is detailed in Algorithm A5, with emphasis on the Spark Streaming tool.