use of com.nexblocks.authguard.emb.annotations.Channel in project AuthGuard by AuthGuard.
the class AutoSubscribers method subscribe.
public void subscribe() {
if (allowedSubscribers.isEmpty()) {
log.info("No subscribers were allowed in the configuration");
return;
}
for (final MessageSubscriber subscriber : subscribers) {
if (!allowedSubscribers.contains(subscriber.getClass().getCanonicalName())) {
log.info("Subscriber {} is not in the allowed list", subscriber.getClass().getCanonicalName());
continue;
}
final Channel channel = subscriber.getClass().getAnnotation(Channel.class);
try {
messageBus.subscribe(channel.value(), subscriber);
log.info("Auto-subscribed {} to channel {}", subscriber.getClass().getSimpleName(), channel.value());
} catch (final Exception e) {
log.warn("Failed to subscribe {} to channel {}. Reason: {}", subscriber.getClass().getSimpleName(), channel.value(), e.getMessage());
}
}
}
Aggregations