# A Novel Radio Network Information Service (RNIS) to MEC Framework in B5G Networks
## 3 Our Proposed RNIS as a Service to MEC Framework in B5G Networks
### RNIS as a Service Implementation
After all the checks carried out by RabInfoModel, the data is forwarded to Emit', as shown in Listing 4. This function encapsulates the logic for sending messages to a specific topic in the Broker, using the previously configured channel and connection. The Exchange class has an implementation that configures the connection and provides the channel and queue name needed for the operation with Broker. In this way, Emit contains the crucial information for publishing to the specific topic for this type of information. In this way, the flow of receiving and processing information from the RNIS is observed, obtaining data from the RAN. The information is then received, processed and assigned to its corresponding topics, ready to be sent to consumers interested in receiving various types of information. In Listing 4 (Function emit class Exchange), you can see the flow of consumers registering and waiting to receive notifications. ```
1 defemit(data,notif):
2
3 channel,queue_name,connection=Exchange.setup_rabsbitmq(notif)
4
5 channel.basic_publish(
6 exchange=notif,
7 routing_key='my_topic',
8 body=data
9)
10 print(\"Postedmessage\",notif)
11
12 connection.close()
13
14 returnmensagem
```  
Listing 5 shows the route, /<appRoot>/rni/v2/subscriptions, which is responsible for handling HTTP POST requests. The dynamic parameters of the URL are captured, appRoot being one of them. During request processing, the JSON payload data is extracted, including NotificationSubscription and callback_uri. Validation is carried out to ensure the presence of these essential parameters, as well as checking the integrity of the NotificationSubscription. If errors occur, appropriate responses are sent with HTTP 400 status codes. If validation is successful, the application is registered by calling the insert_application function, and a JSON response containing information about the registered application, such as NotificationSubscription, callback_uri and an identifier (id_registre), is returned with an HTTP status code of 200. In the event of exceptions during execution, an error response with code 500 is sent, containing details of the exception that occurred. Once the consumer has registered (subscribed), the registration information is stored in a database that feeds the receive_and_send_messages, allowing it to deliver the messages to the routes predetermined by the consumer. Listing 6 presents a function dedicated to receiving messages from a RabbitMQ queue called notification and sending them to a callback URL (callback_url) using the POST method. The implementation begins by establishing a connection with RabbitMQ and configuring a channel for subsequent operations. Next, an exchange and an exclusive queue are declared and linked. When a message is received, the callback function is triggered, converting the message from bytes to string and performing a POST to the return URL using the requests library. The code includes exception handling to deal with possible errors during the process, thus allowing the flow of execution to be maintained over the logic of receiving and sending messages. In short, this function uses the pika library to interact with the Broker, defines a temporary queue, associates it with an Exchange using a specific routing key, and starts a consumer that calls the callback function whenever a message is received. The callback function decodes the message, and sends it to a callback URL via HTTP POST. The code also handles exceptions and prints error messages if problems occur during execution.