Search in sources :

Example 1 with OnOverflow

use of org.eclipse.microprofile.reactive.messaging.OnOverflow in project smallrye-reactive-messaging by smallrye.

the class MutinyEmitterInjectionTest 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 Strategy.BUFFER;
        }

        @Override
        public long bufferSize() {
            return 128;
        }
    };
    EmitterConfiguration config = new EmitterConfiguration("my-channel", true, overflow, null);
    MutinyEmitterImpl<String> emitter = new MutinyEmitterImpl<>(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) MutinyEmitterImpl(io.smallrye.reactive.messaging.providers.extension.MutinyEmitterImpl) Message(org.eclipse.microprofile.reactive.messaging.Message) TestSubscriber(io.reactivex.subscribers.TestSubscriber) OnOverflow(org.eclipse.microprofile.reactive.messaging.OnOverflow) Test(org.junit.jupiter.api.Test)

Aggregations

TestSubscriber (io.reactivex.subscribers.TestSubscriber)1 EmitterConfiguration (io.smallrye.reactive.messaging.providers.extension.EmitterConfiguration)1 MutinyEmitterImpl (io.smallrye.reactive.messaging.providers.extension.MutinyEmitterImpl)1 Message (org.eclipse.microprofile.reactive.messaging.Message)1 OnOverflow (org.eclipse.microprofile.reactive.messaging.OnOverflow)1 Test (org.junit.jupiter.api.Test)1