Interface Aggregate<T>

  • Type Parameters:
    T - Message type.

    public interface Aggregate<T>
    Aggregate operation.

    This interface represents a request/response-style broadcast operation of a MessagingChannel. This operation submits the same request message to multiple remote nodes and aggregates their responses.

    Usage Example

    Typical use of this interface is:

    1. Obtain an instance of this interface via the MessagingChannel.newAggregate(Object) method call
    2. Set options (if needed):
    3. Execute this operation via the submit() method
    4. Process results (synchronously or asynchronously)

    
    MessagingChannel<String> channel = hekate.messaging().channel("example.channel", String.class);
    
    AggregateFuture<String> future = channel.newAggregate("some-message") // Some dummy message.
        .withAffinity("100500") // Some dummy affinity key for consistent routing.
        .withTimeout(3, TimeUnit.SECONDS) // Timeout.
        .withRetry(retry -> retry
            .whileError(err -> err.isCausedBy(IOException.class)) // Only if I/O error.
            .withFixedDelay(100) // Delay between retries.
            .maxAttempts(3) // Retry up to 3 times.
        )
        .submit(); // Asynchronously execute the operation.
    
    // Await and print results.
    System.out.println("Results: " + future.results());
    

    Shortcut Methods

    MessagingChannel interface provides a set of synchronous and asynchronous shortcut methods for common use cases: