publish<T> method
Implementation
Future<void> publish<T>(String topic, T event) async {
final encoded =
(event is TransferObjectBase) ? event.toJson() : encodeTyped<T>(event);
try {
await _publishChannel
.get()
.then((c) => c.exchange(exchange, ExchangeType.TOPIC))
.then((ex) => ex.publish(encoded, topic));
} catch (e, stack) {
_publishChannel.invalidate();
_log.warn('Amqp channel error, reconnecting.', error: e, trace: stack);
await _publishChannel
.get()
.then((c) => c.exchange(exchange, ExchangeType.TOPIC))
.then((ex) => ex.publish(encoded, topic));
}
}