Search in sources :

Example 1 with EmitterImpl

use of io.smallrye.reactive.messaging.providers.extension.EmitterImpl in project smallrye-reactive-messaging by smallrye.

the class EmitterInjectionTest method testWeCanHaveSeveralSubscribers.

// Reproduce #511
@Test
public void testWeCanHaveSeveralSubscribers() {
    OnOverflow overflow = new OnOverflow() {

        @Override
        public Class<? extends Annotation> annotationType() {
            return OnOverflow.class;
        }

        @Override
        public Strategy value() {
            return OnOverflow.Strategy.BUFFER;
        }

        @Override
        public long bufferSize() {
            return 128;
        }
    };
    EmitterConfiguration config = new EmitterConfiguration("my-channel", false, overflow, null);
    EmitterImpl<String> emitter = new EmitterImpl<>(config, 128);
    Publisher<Message<? extends String>> publisher = emitter.getPublisher();
    TestSubscriber<Message<? extends String>> sub1 = new TestSubscriber<>();
    publisher.subscribe(sub1);
    TestSubscriber<Message<? extends String>> sub2 = new TestSubscriber<>();
    publisher.subscribe(sub2);
    sub1.assertNoErrors();
    sub2.assertNoErrors();
}
Also used : EmitterConfiguration(io.smallrye.reactive.messaging.providers.extension.EmitterConfiguration) EmitterImpl(io.smallrye.reactive.messaging.providers.extension.EmitterImpl) TestSubscriber(io.reactivex.subscribers.TestSubscriber) Test(org.junit.jupiter.api.Test)

Aggregations

TestSubscriber (io.reactivex.subscribers.TestSubscriber)1 EmitterConfiguration (io.smallrye.reactive.messaging.providers.extension.EmitterConfiguration)1 EmitterImpl (io.smallrye.reactive.messaging.providers.extension.EmitterImpl)1 Test (org.junit.jupiter.api.Test)1