Class DelegateMessageQueueReceiverEndpoint

    • Constructor Detail

      • DelegateMessageQueueReceiverEndpoint

        public DelegateMessageQueueReceiverEndpoint​(@Nonnull
                                                    java.lang.String channelName,
                                                    @Nonnull
                                                    MessageQueueReceiverEndpointFactory messageQueueReceiverEndpointFactory)
    • Method Detail

      • consume

        public java.util.concurrent.CompletableFuture<java.lang.Void> consume()
        Description copied from interface: MessageQueueReceiverEndpoint
        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 earliest available and not-yet-consumed message and finishes when either the stopCondition is met, or the application is shutting down.

        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:
        consume in interface MessageQueueReceiverEndpoint
        Returns:
        completable future that can be used to wait until the endpoint has stopped message consumption.
      • 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.