reactive messaging - producing messages continuosly

29 views
Skip to first unread message

Vincenzo D'Amore

unread,
Jun 7, 2022, 7:37:34 AM6/7/22
to SmallRye
Hi All,

I hope this is the right forum where talk about smallrye reactive messaging.
I wrote a sample where try to understand how to produce messages continuosly.

So I have a method that produces continuosly messages:

    @Outgoing("from-producer-to-processor")
    public Multi<ClassA> periodicallySendMessage() {

        return Multi.createFrom()
                .ticks()
                .every(Duration.ofMillis(50))
                .onItem().transform(t -> new ClassA("Hello " + t))
                .onFailure(mm -> {
                    log.info("Producer NOT EMITTING");
                    return true;
                })
                .retry()
                .withBackOff(Duration.ofSeconds(1), Duration.ofSeconds(10))
                .indefinitely()
                .onItem()
                .invoke(msg -> log.info("Producer emitting " + msg));
    }

What I realized is that if a failure happens, for example if the method that consumes message through the @Incoming  annotation is slow, the failure is rised but the ticks starts again from 1, am I right?
I have also noticed that the failure is raised only when a considerable amount of messages are sent (at least 256). I suppose this is the default behaviour, given that the default buffer size is 256. But even trying to change the buffer size, I was unable to control the number of messages sent, before a failure (caused by a slow consumer) is raised.

Best regards,
Vincenzo




clement escoffier

unread,
Jun 9, 2022, 2:15:49 AM6/9/22
to SmallRye
Hello,

You cannot constraint time, so the back pressure protocol cannot be used when using ticks. So, you need:

Multi.createFrom().ticks().every(Duration.ofMillis(50)).onOverflow().drop()

It will drop the ticks if the subscriber cannot handle the load. 

Clement

--
You received this message because you are subscribed to the Google Groups "SmallRye" group.
To unsubscribe from this group and stop receiving emails from it, send an email to smallrye+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/smallrye/e96af6e2-668e-422d-951f-ec21a80e6f88n%40googlegroups.com.

Vincenzo D'Amore

unread,
Jun 21, 2022, 10:09:28 AM6/21/22
to smal...@googlegroups.com
Hi Clement,

thanks for answering.
What about removing the ticks() part with a generator? Could you help me out with that?



--
Vincenzo D'Amore

clement escoffier

unread,
Jun 21, 2022, 10:37:11 AM6/21/22
to smal...@googlegroups.com
A generator will help as we will stop calling it when we do not have requests.

Clement

Reply all
Reply to author
Forward
0 new messages