import pika from typing import Dict import json def send_message_to_rmq(user_id: int, message: Dict): credentials = pika.credentials.PlainCredentials(username="notifier",password="strongpassword") conn_params = pika.ConnectionParameters(host="localhost", credentials=credentials,virtual_host="app_notifications") connection = pika.BlockingConnection(conn_params) #connection = pika.BlockingConnection(pika.ConnectionParameters('localhost')) channel = connection.channel() channel.confirm_delivery() channel.basic_publish(exchange='app_notifications', routing_key=f"notify.user.{user_id}", body=json.dumps(message), properties=pika.BasicProperties( content_type="application/json", delivery_mode=2 ))