Interface BatchingStrategy

  • All Known Implementing Classes:
    SimpleBatchingStrategy

    public interface BatchingStrategy
    Strategy for batching messages. The methods will never be called concurrently.

    Experimental - APIs may change.

    Since:
    1.4.1
    Author:
    Gary Russell
    • Method Detail

      • addToBatch

        MessageBatch addToBatch​(java.lang.String exchange,
                                java.lang.String routingKey,
                                Message message)
        Add a message to the batch and optionally release the batch.
        Parameters:
        exchange - The exchange.
        routingKey - The routing key.
        message - The message.
        Returns:
        The batched message (MessageBatch), or null if not ready to release.
      • nextRelease

        java.util.Date nextRelease()
        Returns:
        the date the next scheduled release should run, or null if no data to release.
      • releaseBatches

        java.util.Collection<MessageBatch> releaseBatches()
        Release batch(es), perhaps due to a timeout.
        Returns:
        The batched message(s).
      • canDebatch

        default boolean canDebatch​(MessageProperties properties)
        Return true if this strategy can decode a batch of messages from a message body. Returning true means you must override deBatch(Message, Consumer).
        Parameters:
        properties - the message properties.
        Returns:
        true if we can decode the message.
        Since:
        2.2
        See Also:
        deBatch(Message, Consumer)
      • deBatch

        default void deBatch​(Message message,
                             java.util.function.Consumer<Message> fragmentConsumer)
        Decode a message into fragments.
        Parameters:
        message - the message.
        fragmentConsumer - a consumer for fragments.
        Since:
        2.2
        See Also:
        canDebatch(MessageProperties)