Class DelegateMessageLogReceiverEndpoint

    • Constructor Detail

      • DelegateMessageLogReceiverEndpoint

        public DelegateMessageLogReceiverEndpoint​(@Nonnull
                                                  java.lang.String channelName,
                                                  @Nonnull
                                                  MessageLogReceiverEndpointFactory messageLogReceiverEndpointFactory)
    • Method Detail

      • consumeUntil

        @Nonnull
        public java.util.concurrent.CompletableFuture<ChannelPosition> consumeUntil​(@Nonnull
                                                                                    ChannelPosition startFrom,
                                                                                    @Nonnull
                                                                                    java.util.function.Predicate<ShardResponse> stopCondition)
        Description copied from interface: MessageLogReceiverEndpoint
        Beginning at the startFrom position, messages are consumed from the message log, until the stopCondition is true.

        If the message-log is sharded, the predicate must be true for every shard: otherwise, message consumption would continue on other shards.

        Takes zero or more messages from the channel, calls MessageEndpoint.intercept(TextMessage) for every message, and notifies the registered consumers with the intercepted message, or drops the message, if intercept returns null.

        Consumption starts with the first message after startFrom and finishes when either the stopCondition is met, or the application is shutting down.

        The returned ChannelPosition is the position of the last message that was processed by the MessageLogReceiverEndpoint - whether it was dropped or consumed.

        The registered consumers are used as a callback for consumed messages. A MessageDispatcher can be used as a consumer, if multiple consumers, or consumers with message payloads other than String are required.

        Specified by:
        consumeUntil in interface MessageLogReceiverEndpoint
        Parameters:
        startFrom - the start position used to proceed message consumption
        stopCondition - the predicate used to test if message consumption should be stopped. In most cases, the predicates defined in StopCondition should be sufficient.
        Returns:
        ChannelPosition
      • register

        public void register​(MessageConsumer<?> messageConsumer)
        Description copied from interface: MessageReceiverEndpoint
        Registers a MessageConsumer at the receiver endpoint. consumers have to be thread safe as they might be called from multiple threads in parallel (e.g. for kinesis streams there is one thread per shard).
        Specified by:
        register in interface MessageReceiverEndpoint
        Parameters:
        messageConsumer - registered EventConsumer
      • getChannelName

        @Nonnull
        public java.lang.String getChannelName()
        Description copied from interface: MessageEndpoint
        Returns the name of the channel.

        The channel name corresponds to the name of the underlying stream, queue or message log.

        Specified by:
        getChannelName in interface MessageEndpoint
        Returns:
        name of the channel
      • intercept

        @Nullable
        public TextMessage intercept​(@Nonnull
                                     TextMessage message)
        Description copied from interface: MessageEndpoint
        Intercepts a message using all registered interceptors and returns the resulting message.

        The interceptors are called in order. The result of one interceptor is propagated to the next interceptor in the chain, until the end of the chain is reached, or one interceptor has returned null.

        If null is returned, the message must be dropped by the AbstractMessageEndpoint.

        Every interceptor may transform the message, or may take additional actions like, for example, logging, monitoring or other things.

        Specified by:
        intercept in interface MessageEndpoint
        Parameters:
        message - the message to intercept
        Returns:
        the (possibly modified) message, or null if the message should be dropped.