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

dev.snowdrop.vertx.amqp.SnowdropAmqpSender Maven / Gradle / Ivy

There is a newer version: 1.4.1
Show newest version
package dev.snowdrop.vertx.amqp;

import java.util.function.Consumer;

import io.smallrye.mutiny.converters.uni.UniReactorConverters;
import reactor.core.publisher.Mono;

class SnowdropAmqpSender implements AmqpSender {

    private final io.vertx.mutiny.amqp.AmqpSender delegate;

    private final MessageConverter messageConverter;

    SnowdropAmqpSender(io.vertx.mutiny.amqp.AmqpSender delegate, MessageConverter messageConverter) {
        this.delegate = delegate;
        this.messageConverter = messageConverter;
    }

    @Override
    public io.vertx.core.streams.WriteStream vertxWriteStream() {
        return delegate.getDelegate();
    }

    @Override
    public AmqpSender exceptionHandler(Consumer handler) {
        delegate.exceptionHandler(handler);

        return this;
    }

    @Override
    public AmqpSender drainHandler(Consumer handler) {
        delegate.drainHandler(handler);

        return this;
    }

    @Override
    public AmqpSender setWriteQueueMaxSize(int maxSize) {
        delegate.setWriteQueueMaxSize(maxSize);

        return this;
    }

    @Override
    public boolean writeQueueFull() {
        return delegate.writeQueueFull();
    }

    @Override
    public Mono write(AmqpMessage message) {
        return delegate.write(messageConverter.toMutinyMessage(message))
            .convert()
            .with(UniReactorConverters.toMono());
    }

    @Override
    public Mono end() {
        return delegate.end()
            .convert()
            .with(UniReactorConverters.toMono());
    }

    @Override
    public Mono end(AmqpMessage message) {
        return delegate.end(messageConverter.toMutinyMessage(message))
            .convert()
            .with(UniReactorConverters.toMono());
    }

    @Override
    public AmqpSender send(AmqpMessage message) {
        delegate.send(messageConverter.toMutinyMessage(message));

        return this;
    }

    @Override
    public Mono sendWithAck(AmqpMessage message) {
        return delegate.sendWithAck(messageConverter.toMutinyMessage(message))
            .convert()
            .with(UniReactorConverters.toMono());
    }

    @Override
    public AmqpConnection connection() {
        return new SnowdropAmqpConnection(delegate.connection(), messageConverter);
    }

    @Override
    public String address() {
        return delegate.address();
    }

    @Override
    public Mono close() {
        return delegate.close()
            .convert()
            .with(UniReactorConverters.toMono());
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy