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());
.match(DistributedPubSubMediator.SubscribeAck.class, subscribeAck -> log.debug("Successfully subscribed to distributed pub/sub on topic '{}'", subscribeAck.subscribe().topic())
pubSubMediator.tell(new DistributedPubSubMediator.Subscribe( startStreaming.getStreamingType().getDistributedPubSubTopic(), connectionCorrelationId, .match(DistributedPubSubMediator.SubscribeAck.class, subscribeAck -> { LogUtil.enhanceLogWithCorrelationId(logger, connectionCorrelationId); final String topic = subscribeAck.subscribe().topic(); final StreamingType streamingType = StreamingType.fromTopic(topic); final ActorRef self = getSelf();
.match(DistributedPubSubMediator.SubscribeAck.class, subscribeAck -> getLogger().debug("Successfully subscribed to distributed pub/sub on topic '{}'", subscribeAck.subscribe().topic())
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());
@Override public Receive createReceive() { return ReceiveBuilder.create() .match(RetrieveConnectionStatusResponse.class, command -> { if (!ConnectionStatus.OPEN.equals(command.getConnectionStatus())) { connectionIds.remove(command.getConnectionId()); } }) .match(ConnectionCreated.class, event -> persistEvent(event, e -> connectionIds.add(e.getConnectionId()))) .match(ConnectionOpened.class, event -> persistEvent(event, e -> connectionIds.add(e.getConnectionId()))) .match(ConnectionClosed.class, event -> persistEvent(event, e -> connectionIds.remove(e.getConnectionId()))) .match(ConnectionDeleted.class, event -> persistEvent(event, e -> connectionIds.remove(e.getConnectionId()))) .match(DistributedPubSubMediator.SubscribeAck.class, subscribeAck -> log.debug("Successfully subscribed to distributed pub/sub on topic '{}'", subscribeAck.subscribe().topic()) ) .matchAny(m -> { log.warning("Unknown message: {}", m); unhandled(m); }).build(); }
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 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()); }); }
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 subscribeAck(final DistributedPubSubMediator.SubscribeAck subscribeAck) { log.debug("Successfully subscribed to distributed pub/sub on topic '{}'", subscribeAck.subscribe().topic()); }
private void subscribeAck(final DistributedPubSubMediator.SubscribeAck subscribeAck) { log.debug("Successfully subscribed to distributed pub/sub on topic '{}'", subscribeAck.subscribe().topic()); }
@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(); }
@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 subscribeForNamespaceCommands() { final ActorRef self = getSelf(); pubSubMediator.tell(new DistributedPubSubMediator.Subscribe(PurgeNamespace.TYPE, self), self); }
private void handleSubscribeAck(final DistributedPubSubMediator.SubscribeAck subscribeAck) { log.debug("Successfully subscribed to distributed pub/sub on topic <{}>.", subscribeAck.subscribe().topic()); }