New alert service
This commit is contained in:
@@ -15,7 +15,6 @@ from app.api.notification_operations import router as notification_operations_ro
|
||||
from app.api.analytics import router as analytics_router
|
||||
from app.api.audit import router as audit_router
|
||||
from app.api.whatsapp_webhooks import router as whatsapp_webhooks_router
|
||||
from app.services.messaging import setup_messaging, cleanup_messaging
|
||||
from app.services.sse_service import SSEService
|
||||
from app.services.notification_orchestrator import NotificationOrchestrator
|
||||
from app.services.email_service import EmailService
|
||||
@@ -159,13 +158,15 @@ class NotificationService(StandardFastAPIService):
|
||||
)
|
||||
|
||||
async def _setup_messaging(self):
|
||||
"""Setup messaging for notification service"""
|
||||
await setup_messaging()
|
||||
self.logger.info("Messaging initialized")
|
||||
"""Setup messaging for notification service using unified messaging"""
|
||||
# The base class will handle the unified messaging setup
|
||||
# For notification service, no additional setup is needed
|
||||
self.logger.info("Notification service messaging initialized")
|
||||
|
||||
async def _cleanup_messaging(self):
|
||||
"""Cleanup messaging for notification service"""
|
||||
await cleanup_messaging()
|
||||
# The base class will handle the unified messaging cleanup
|
||||
self.logger.info("Notification service messaging cleaned up")
|
||||
|
||||
async def on_startup(self, app: FastAPI):
|
||||
"""Custom startup logic for notification service"""
|
||||
@@ -208,9 +209,12 @@ class NotificationService(StandardFastAPIService):
|
||||
)
|
||||
|
||||
# Start consuming PO approved events in background
|
||||
# Use the global notification_publisher from messaging module
|
||||
from app.services.messaging import notification_publisher
|
||||
if notification_publisher and notification_publisher.connected:
|
||||
# Initialize unified messaging publisher
|
||||
from shared.messaging import UnifiedEventPublisher, RabbitMQClient
|
||||
|
||||
rabbitmq_client = RabbitMQClient(settings.RABBITMQ_URL, "notification-service")
|
||||
if await rabbitmq_client.connect():
|
||||
notification_publisher = UnifiedEventPublisher(rabbitmq_client, "notification-service")
|
||||
self.po_consumer_task = asyncio.create_task(
|
||||
self.po_consumer.consume_po_approved_event(notification_publisher)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user