createSubscriptions(topicKeys);
}
private void createSubscriptions(Iterable<TopicKey> topicKeys) {
for (TopicKey topicKey : topicKeys) {
Topic pushTopic = topicsContext.getOrCreateTopic(topicKey);
String errorMessage = null;
if (pushTopic == null) {
errorMessage = MessageFormat.format("Topic ''{0}'' is not configured", topicKey.getTopicAddress());
} else {
try {
// TODO - publish another events
pushTopic.checkSubscription(this);
} catch (SubscriptionFailureException e) {
if (e.getMessage() != null) {
errorMessage = e.getMessage();
} else {
errorMessage = MessageFormat.format("Unknown error connecting to ''{0}'' topic",
topicKey.getTopicAddress());
}
}
}
if (errorMessage != null) {
failedSubscriptions.put(topicKey, errorMessage);
} else {
pushTopic.publishEvent(new SessionSubscriptionEvent(pushTopic, topicKey, this));
successfulSubscriptions.add(topicKey);
}
}
}