protected BasePublisherActor() { addressMetric = ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Started at " + Instant.now(), 0, null); }
protected BasePublisherActor() { addressMetric = ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Started at " + Instant.now(), 0, null); }
/** * Constructs a new instance and records its association to the passed-in channel. * * @param channel the channel to which this consumer is attached */ private RabbitMQMessageConsumer(final ActorRef consumerActor, final Channel channel) { super(channel); this.consumerActor = consumerActor; consumerActor.tell(ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Consumer initialized at " + Instant.now(), 0, null), null); }
/** * Constructs a new instance and records its association to the passed-in channel. * * @param channel the channel to which this consumer is attached */ private RabbitMQMessageConsumer(final ActorRef consumerActor, final Channel channel) { super(channel); this.consumerActor = consumerActor; consumerActor.tell(ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Consumer initialized at " + Instant.now(), 0, null), null); }
@Override public void handleConsumeOk(final String consumerTag) { super.handleConsumeOk(consumerTag); LogUtil.enhanceLogWithCustomField(log, BaseClientData.MDC_CONNECTION_ID, connectionId()); final String consumingQueueByTag = consumedTagsToAddresses.get(consumerTag); if (null != consumingQueueByTag) { log.info("Consume OK for consumer queue <{}> on connection <{}>.", consumingQueueByTag, connectionId()); } consumerActor.tell(ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Consumer started at " + Instant.now(), 0, null), null); }
@Override public void handleCancel(final String consumerTag) throws IOException { super.handleCancel(consumerTag); LogUtil.enhanceLogWithCustomField(log, BaseClientData.MDC_CONNECTION_ID, connectionId()); final String consumingQueueByTag = consumedTagsToAddresses.get(consumerTag); if (null != consumingQueueByTag) { log.warning("Consumer with queue <{}> was cancelled on connection <{}>. This can happen for " + "example when the queue was deleted.", consumingQueueByTag, connectionId()); } consumerActor.tell(ConnectivityModelFactory.newAddressMetric(ConnectionStatus.FAILED, "Consumer for queue cancelled at " + Instant.now(), 0, null), null); }
@Override public void handleShutdownSignal(final String consumerTag, final ShutdownSignalException sig) { super.handleShutdownSignal(consumerTag, sig); LogUtil.enhanceLogWithCustomField(log, BaseClientData.MDC_CONNECTION_ID, connectionId()); final String consumingQueueByTag = consumedTagsToAddresses.get(consumerTag); if (null != consumingQueueByTag) { log.warning("Consumer with queue <{}> shutdown as the channel or the underlying connection has " + "been shut down on connection <{}>.", consumingQueueByTag, connectionId()); } consumerActor.tell(ConnectivityModelFactory.newAddressMetric(ConnectionStatus.FAILED, "Channel or the underlying connection has been shut down at " + Instant.now(), 0, null), null); }
@Override public void handleConsumeOk(final String consumerTag) { super.handleConsumeOk(consumerTag); LogUtil.enhanceLogWithCustomField(log, BaseClientData.MDC_CONNECTION_ID, connectionId()); final String consumingQueueByTag = consumedTagsToAddresses.get(consumerTag); if (null != consumingQueueByTag) { log.info("Consume OK for consumer queue <{}> on connection <{}>.", consumingQueueByTag, connectionId()); } consumerActor.tell(ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Consumer started at " + Instant.now(), 0, null), null); }
@Override public void handleShutdownSignal(final String consumerTag, final ShutdownSignalException sig) { super.handleShutdownSignal(consumerTag, sig); LogUtil.enhanceLogWithCustomField(log, BaseClientData.MDC_CONNECTION_ID, connectionId()); final String consumingQueueByTag = consumedTagsToAddresses.get(consumerTag); if (null != consumingQueueByTag) { log.warning("Consumer with queue <{}> shutdown as the channel or the underlying connection has " + "been shut down on connection <{}>.", consumingQueueByTag, connectionId()); } consumerActor.tell(ConnectivityModelFactory.newAddressMetric(ConnectionStatus.FAILED, "Channel or the underlying connection has been shut down at " + Instant.now(), 0, null), null); }
@Override public void handleCancel(final String consumerTag) throws IOException { super.handleCancel(consumerTag); LogUtil.enhanceLogWithCustomField(log, BaseClientData.MDC_CONNECTION_ID, connectionId()); final String consumingQueueByTag = consumedTagsToAddresses.get(consumerTag); if (null != consumingQueueByTag) { log.warning("Consumer with queue <{}> was cancelled on connection <{}>. This can happen for " + "example when the queue was deleted.", consumingQueueByTag, connectionId()); } consumerActor.tell(ConnectivityModelFactory.newAddressMetric(ConnectionStatus.FAILED, "Consumer for queue cancelled at " + Instant.now(), 0, null), null); }
private MqttConsumerActor(final ActorRef messageMappingProcessor, final AuthorizationContext sourceAuthorizationContext, @Nullable final Enforcement enforcement, final boolean dryRun) { this.messageMappingProcessor = messageMappingProcessor; this.sourceAuthorizationContext = sourceAuthorizationContext; this.dryRun = dryRun; addressMetric = ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Started at " + Instant.now(), 0, null); deadLetters = getContext().system().deadLetters(); if (enforcement != null) { this.topicEnforcementFilterFactory = EnforcementFactoryFactory.newEnforcementFilterFactory(enforcement, PlaceholderFactory.newSourceAddressPlaceholder()); } else { topicEnforcementFilterFactory = null; } }
private MqttConsumerActor(final ActorRef messageMappingProcessor, final AuthorizationContext sourceAuthorizationContext, @Nullable final Enforcement enforcement, final boolean dryRun) { this.messageMappingProcessor = messageMappingProcessor; this.sourceAuthorizationContext = sourceAuthorizationContext; this.dryRun = dryRun; addressMetric = ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Started at " + Instant.now(), 0, null); deadLetters = getContext().system().deadLetters(); if (enforcement != null) { this.topicEnforcementFilterFactory = EnforcementFactoryFactory.newEnforcementFilterFactory(enforcement, PlaceholderFactory.newSourceAddressPlaceholder()); } else { topicEnforcementFilterFactory = null; } }
private AmqpConsumerActor(final String sourceAddress, final MessageConsumer messageConsumer, final ActorRef messageMappingProcessor, final Source source) { this.sourceAddress = checkNotNull(sourceAddress, "sourceAddress"); this.messageConsumer = checkNotNull(messageConsumer); this.messageMappingProcessor = checkNotNull(messageMappingProcessor, "messageMappingProcessor"); checkNotNull(source, "source"); authorizationContext = source.getAuthorizationContext(); final Enforcement enforcement = source.getEnforcement().orElse(null); headerMapping = source.getHeaderMapping().orElse(null); addressMetric = ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Started at " + Instant.now(), 0, null); headerEnforcementFilterFactory = enforcement != null ? EnforcementFactoryFactory.newEnforcementFilterFactory(enforcement, PlaceholderFactory.newHeadersPlaceholder()) : input -> null; }
private AmqpConsumerActor(final String sourceAddress, final MessageConsumer messageConsumer, final ActorRef messageMappingProcessor, final Source source) { this.sourceAddress = checkNotNull(sourceAddress, "sourceAddress"); this.messageConsumer = checkNotNull(messageConsumer); this.messageMappingProcessor = checkNotNull(messageMappingProcessor, "messageMappingProcessor"); checkNotNull(source, "source"); authorizationContext = source.getAuthorizationContext(); final Enforcement enforcement = source.getEnforcement().orElse(null); headerMapping = source.getHeaderMapping().orElse(null); addressMetric = ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Started at " + Instant.now(), 0, null); headerEnforcementFilterFactory = enforcement != null ? EnforcementFactoryFactory.newEnforcementFilterFactory(enforcement, PlaceholderFactory.newHeadersPlaceholder()) : input -> null; }
private MqttPublisherActor(final MqttConnectionFactory factory, final ActorRef mqttClientActor, final boolean dryRun) { this.mqttClientActor = mqttClientActor; this.dryRun = dryRun; final Sink<MqttMessage, CompletionStage<Done>> mqttSink = factory.newSink(); final Pair<ActorRef, CompletionStage<Done>> materializedValues = Source.<MqttMessage>actorRef(100, OverflowStrategy.dropHead()) .map(this::countPublishedMqttMessage) .toMat(mqttSink, Keep.both()) .run(ActorMaterializer.create(getContext())); materializedValues.second().handle(this::reportReadiness); sourceActor = materializedValues.first(); addressMetric = ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Started at " + Instant.now(), 0, null); }
private MqttPublisherActor(final MqttConnectionFactory factory, final ActorRef mqttClientActor, final boolean dryRun) { this.mqttClientActor = mqttClientActor; this.dryRun = dryRun; final Sink<MqttMessage, CompletionStage<Done>> mqttSink = factory.newSink(); final Pair<ActorRef, CompletionStage<Done>> materializedValues = Source.<MqttMessage>actorRef(100, OverflowStrategy.dropHead()) .map(this::countPublishedMqttMessage) .toMat(mqttSink, Keep.both()) .run(ActorMaterializer.create(getContext())); materializedValues.second().handle(this::reportReadiness); sourceActor = materializedValues.first(); addressMetric = ConnectivityModelFactory.newAddressMetric(ConnectionStatus.OPEN, "Started at " + Instant.now(), 0, null); }
@Override public Receive createReceive() { return ReceiveBuilder.create() .match(JmsMessage.class, this::handleJmsMessage) .match(AddressMetric.class, this::handleAddressMetric) .match(RetrieveAddressMetric.class, ram -> { getSender().tell(ConnectivityModelFactory.newAddressMetric( addressMetric.getStatus(), addressMetric.getStatusDetails().orElse(null), consumedMessages, lastMessageConsumedAt), getSelf()); }) .matchAny(m -> { log.warning("Unknown message: {}", m); unhandled(m); }).build(); }
@Override public Receive createReceive() { return ReceiveBuilder.create() .match(Delivery.class, this::handleDelivery) .match(AddressMetric.class, this::handleAddressMetric) .match(RetrieveAddressMetric.class, ram -> { getSender().tell(ConnectivityModelFactory.newAddressMetric( addressMetric != null ? addressMetric.getStatus() : ConnectionStatus.UNKNOWN, addressMetric != null ? addressMetric.getStatusDetails().orElse(null) : null, consumedMessages, lastMessageConsumedAt), getSelf()); }) .matchAny(m -> { log.warning("Unknown message: {}", m); unhandled(m); }).build(); }
@Override public Receive createReceive() { return ReceiveBuilder.create() .match(Delivery.class, this::handleDelivery) .match(AddressMetric.class, this::handleAddressMetric) .match(RetrieveAddressMetric.class, ram -> { getSender().tell(ConnectivityModelFactory.newAddressMetric( addressMetric != null ? addressMetric.getStatus() : ConnectionStatus.UNKNOWN, addressMetric != null ? addressMetric.getStatusDetails().orElse(null) : null, consumedMessages, lastMessageConsumedAt), getSelf()); }) .matchAny(m -> { log.warning("Unknown message: {}", m); unhandled(m); }).build(); }
@Override public Receive createReceive() { return ReceiveBuilder.create() .match(JmsMessage.class, this::handleJmsMessage) .match(AddressMetric.class, this::handleAddressMetric) .match(RetrieveAddressMetric.class, ram -> { getSender().tell(ConnectivityModelFactory.newAddressMetric( addressMetric.getStatus(), addressMetric.getStatusDetails().orElse(null), consumedMessages, lastMessageConsumedAt), getSelf()); }) .matchAny(m -> { log.warning("Unknown message: {}", m); unhandled(m); }).build(); }