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

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

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

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

class SnowdropAmqpReceiver implements AmqpReceiver {

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

    private final MessageConverter messageConverter;

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

    @Override
    public Mono mono() {
        return delegate.toMulti()
            .convert()
            .with(MultiReactorConverters.toMono())
            .map(messageConverter::toSnowdropMessage);
    }

    @Override
    public Flux flux() {
        return delegate.toMulti()
            .convert()
            .with(MultiReactorConverters.toFlux())
            .map(messageConverter::toSnowdropMessage);
    }

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

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy