All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.quarkiverse.reactive.messaging.nats.jetstream.client.Connection Maven / Gradle / Ivy

There is a newer version: 3.17.0
Show newest version
package io.quarkiverse.reactive.messaging.nats.jetstream.client;

import java.time.Duration;
import java.time.ZonedDateTime;
import java.util.List;

import org.eclipse.microprofile.reactive.messaging.Message;

import io.quarkiverse.reactive.messaging.nats.jetstream.client.api.Consumer;
import io.quarkiverse.reactive.messaging.nats.jetstream.client.api.PurgeResult;
import io.quarkiverse.reactive.messaging.nats.jetstream.client.api.StreamState;
import io.quarkiverse.reactive.messaging.nats.jetstream.client.configuration.*;
import io.smallrye.mutiny.Multi;
import io.smallrye.mutiny.Uni;

public interface Connection extends StreamSetup, KeyValueStoreSetup, AutoCloseable {

    boolean isConnected();

    Uni flush(Duration duration);

    List listeners();

    void addListener(ConnectionListener listener);

    void removeListener(ConnectionListener listener);

    default void fireEvent(ConnectionEvent event, String message) {
        listeners().forEach(listener -> listener.onEvent(event, message));
    }

    Uni getConsumer(String stream, String consumerName);

    Uni> getStreams();

    Uni> getSubjects(String streamName);

    Uni> getConsumerNames(String streamName);

    Uni deleteConsumer(String streamName, String consumerName);

    Uni pauseConsumer(String streamName, String consumerName, ZonedDateTime pauseUntil);

    Uni resumeConsumer(String streamName, String consumerName);

    Uni purgeStream(String streamName);

    Uni getFirstSequence(String streamName);

    /**
     * Deletes a message, overwriting the message data with garbage
     * This can be considered an expensive (time-consuming) operation, but is more secure.
     *
     * @param stream name of the stream
     * @param sequence the sequence number of the message
     * @param erase whether to erase the message (overwriting with garbage) or only mark it as erased.
     * @throws DeleteException when message is not deleted
     */
    Uni deleteMessage(String stream, long sequence, boolean erase);

    Uni getStreamState(String streamName);

    Uni getStreamConfiguration(String streamName);

    Uni> purgeAllStreams();

     Uni> publish(final Message message, final PublishConfiguration configuration);

     Uni> publish(final Message message, final PublishConfiguration publishConfiguration,
            FetchConsumerConfiguration consumerConfiguration);

     Uni> nextMessage(FetchConsumerConfiguration configuration);

     Multi> nextMessages(FetchConsumerConfiguration configuration);

     Uni getKeyValue(String bucketName, String key, Class valueType);

     Uni putKeyValue(String bucketName, String key, T value);

    Uni deleteKeyValue(String bucketName, String key);

     Uni> resolve(String streamName, long sequence);

     Uni> subscribtion(PushConsumerConfiguration configuration);

     Uni> subscribtion(ReaderConsumerConfiguration configuration);

     void close(Subscription subscribtion);
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy