platform/sandbox/mqueue/example/routing/production_logger.dart

29 lines
663 B
Dart

import 'dart:developer';
import 'package:angel3_mq/mq.dart';
final class ProductionLogger with ConsumerMixin {
ProductionLogger() {
MQClient.instance.declareExchange(
exchangeName: 'logs',
exchangeType: ExchangeType.direct,
);
_queueName = MQClient.instance.declareQueue('production');
}
late final String _queueName;
void startListening() {
MQClient.instance.bindQueue(
queueId: _queueName,
exchangeName: 'logs',
bindingKey: 'error',
);
subscribe(
queueId: _queueName,
callback: (Message message) {
log('Production Logger recieved: ${message.payload}');
},
);
}
}