private void subscribeForEvents() { checkConnectionNotNull(); // unsubscribe to previously subscribed topics unsubscribeFromEvents(); uniqueTopics = connection.getTargets().stream() .flatMap(target -> target.getTopics().stream().map(FilteredTopic::getTopic)) .collect(Collectors.toSet()); forEachPubSubTopicDo(pubSubTopic -> { final DistributedPubSubMediator.Subscribe subscribe = new DistributedPubSubMediator.Subscribe(pubSubTopic, PUB_SUB_GROUP_PREFIX + connectionId, getSelf()); log.debug("Subscribing to pub-sub topic <{}> for connection <{}>.", pubSubTopic, connectionId); pubSubMediator.tell(subscribe, getSelf()); }); }
private void subscribeForEvents() { checkConnectionNotNull(); // unsubscribe to previously subscribed topics unsubscribeFromEvents(); uniqueTopics = connection.getTargets().stream() .flatMap(target -> target.getTopics().stream().map(FilteredTopic::getTopic)) .collect(Collectors.toSet()); forEachPubSubTopicDo(pubSubTopic -> { final DistributedPubSubMediator.Subscribe subscribe = new DistributedPubSubMediator.Subscribe(pubSubTopic, PUB_SUB_GROUP_PREFIX + connectionId, getSelf()); log.debug("Subscribing to pub-sub topic <{}> for connection <{}>.", pubSubTopic, connectionId); pubSubMediator.tell(subscribe, getSelf()); }); }
@Override public void preStart() { log.debug(getSelf().path().toString()); try { ActorRef mediator = DistributedPubSub.get(getContext().system()).mediator(); mediator.tell(new DistributedPubSubMediator.Subscribe(EventStore.EVENTSTOREMESSAGES, getSelf()), getSelf()); } catch (ConfigurationException e){ log.info("Not subscribing to eventstore event, no cluster system"); } subscribe(); }
pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(WonNodeEvent.class.getName(), getSelf()), getSelf()); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(HintEvent.class.getName(), getSelf()), getSelf()); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(BulkHintEvent.class.getName(), getSelf()), getSelf());
pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(ThingEvent.TYPE_PREFIX, UPDATER_GROUP, self()), self()); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(PolicyEvent.TYPE_PREFIX, UPDATER_GROUP, self()), self());
pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(WonNodeEvent.class.getName(), getSelf()), getSelf()); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(CrawlUriMessage.class.getName(), getSelf()), getSelf()); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe( ResourceCrawlUriMessage.class.getName(), getSelf()), getSelf());
private ThingsUpdater(final int numberOfShards, final ShardRegionFactory shardRegionFactory, final ThingsSearchUpdaterPersistence searchUpdaterPersistence, final CircuitBreaker circuitBreaker, final boolean eventProcessingActive, final Duration thingUpdaterActivityCheckInterval, final int maxBulkSize) { final ActorSystem actorSystem = context().system(); // Start the proxy for the Things and Policies sharding, too. final ActorRef thingsShardRegion = shardRegionFactory.getThingsShardRegion(numberOfShards); final ActorRef policiesShardRegion = shardRegionFactory.getPoliciesShardRegion(numberOfShards); final ActorRef pubSubMediator = DistributedPubSub.get(actorSystem).mediator(); final Props thingUpdaterProps = ThingUpdater.props(searchUpdaterPersistence, circuitBreaker, thingsShardRegion, policiesShardRegion, thingUpdaterActivityCheckInterval, ThingUpdater.DEFAULT_THINGS_TIMEOUT, maxBulkSize) .withMailbox("akka.actor.custom-updater-mailbox"); shardRegion = shardRegionFactory.getSearchUpdaterShardRegion(numberOfShards, thingUpdaterProps); this.searchUpdaterPersistence = searchUpdaterPersistence; materializer = ActorMaterializer.create(getContext()); retrieveStatisticsDetailsResponseSupplier = RetrieveStatisticsDetailsResponseSupplier.of(shardRegion, ThingsSearchConstants.SHARD_REGION, log); if (eventProcessingActive) { pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(ThingEvent.TYPE_PREFIX, UPDATER_GROUP, self()), self()); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(PolicyEvent.TYPE_PREFIX, UPDATER_GROUP, self()), self()); } }
private ReconnectActor(final ActorRef connectionShardRegion, final ActorRef pubSubMediator) { this.connectionShardRegion = connectionShardRegion; final Config config = getContext().system().settings().config(); snapshotThreshold = config.getLong(ConfigKeys.Reconnect.SNAPSHOT_THRESHOLD); if (snapshotThreshold < 0) { throw new ConfigurationException(String.format("Config setting '%s' must be positive, but is: %d.", ConfigKeys.Reconnect.SNAPSHOT_THRESHOLD, snapshotThreshold)); } snapshotAdapter = new MongoReconnectSnapshotAdapter(getContext().system()); connectionIds = new HashSet<>(); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(ConnectionCreated.TYPE, ACTOR_NAME, getSelf()), getSelf()); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(ConnectionOpened.TYPE, ACTOR_NAME, getSelf()), getSelf()); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(ConnectionClosed.TYPE, ACTOR_NAME, getSelf()), getSelf()); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(ConnectionDeleted.TYPE, ACTOR_NAME, getSelf()), getSelf()); }
@Override public void preStart() { registerSagas(); try { ActorRef mediator = DistributedPubSub.get(getContext().system()).mediator(); mediator.tell(new DistributedPubSubMediator.Subscribe(EventStore.EVENTSTOREMESSAGES, getSelf()), getSelf()); } catch (ConfigurationException e){ log.info("Not subscribing to eventstore event, no cluster system"); } repository.open(); subscribe(); timeoutstore = getContext().actorOf(TimeOutStore.mkProps(repository)); }
private DistributedPubSubMediator.Subscribe subscribe(final String topic, final String group) { return new DistributedPubSubMediator.Subscribe(topic, group, getSelf()); }
private void subscribePubSub(final ActorRef pubSubMediator) { pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(Shutdown.TYPE, self), self); }
private void subscribeForNamespaceCommands() { final ActorRef self = getSelf(); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(PurgeNamespace.TYPE, self), self); }
@Override public void preStart() { log.debug(getSelf().path().toString()); try { ActorRef mediator = DistributedPubSub.get(getContext().system()).mediator(); mediator.tell(new DistributedPubSubMediator.Subscribe(EventStore.EVENTSTOREMESSAGES, getSelf()), getSelf()); } catch (ConfigurationException e){ log.info("Not subscribing to eventstore event, no cluster system"); } subscribe(); }
private void subscribeToDevopsTopic(final ActorRef pubSubMediator, final String topic, final String serviceName, final String instance) { pubSubMediator.tell(new Subscribe(topic, getSelf()), getSelf()); pubSubMediator.tell(new Subscribe( String.join(":", topic, serviceName), getSelf()), getSelf()); pubSubMediator.tell(new Subscribe( String.join(":", topic, serviceName, instance), getSelf()), getSelf()); }
@Override public void preStart() { // subscribe for load need events pubSubMediator = DistributedPubSub.get(getContext().system()).mediator(); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(LoadNeedEvent.class.getName(), getSelf()), getSelf()); }
private void subscribeToDevopsTopic(final ActorRef pubSubMediator, final String topic, final String serviceName, final String instance) { pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(topic, getSelf()), getSelf()); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe( String.join(":", topic, serviceName), getSelf()), getSelf()); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe( String.join(":", topic, serviceName, instance), getSelf()), getSelf()); }
@Override public void preStart() { // Subscribe for need events pubSubMediator = DistributedPubSub.get(getContext().system()).mediator(); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(NeedEvent.class.getName(), getSelf()), getSelf()); }
private BlockedNamespacesUpdater(final BlockedNamespaces blockedNamespaces, final ActorRef pubSubMediator) { this.blockedNamespaces = blockedNamespaces; // register self for pub-sub on restart pubSubMediator.tell(new Put(getSelf()), getSelf()); // subscribe to namespace-blocking commands pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(BlockNamespace.TYPE, getSelf()), getSelf()); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(UnblockNamespace.TYPE, getSelf()), getSelf()); }
@Override public void preStart() { pubSubMediator.tell(new DistributedPubSubMediator.Put(getSelf()), getSelf()); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(BatchExecutionFinished.TYPE, ACTOR_NAME, getSelf()), getSelf()); }
public ReservationCacheActor() { // subscribe to the topic named "content" ActorRef mediator = DistributedPubSub.get(getContext().system()).mediator(); mediator.tell(new DistributedPubSubMediator.Subscribe("content", getSelf()), getSelf()); }