How to properly process messages in blocking manner

313 views
Skip to first unread message

Petar Gadjev

unread,
Oct 12, 2021, 2:06:32 AM10/12/21
to SmallRye
Hello,

I am trying to process messages in a blocking manner using a combination of @Blocking and @Channel Emitter. Processing works fine for approximately couple of hours and then suddenly the Emitter.send starts throwing "Insufficient downstream requests to emit item".

It looks normal, because of the backpressure. But the strange thing is that the Emitter no longer accepts messages, seems like it stopped publishing to the downstream channel. No logs produced whatsoever.

I'd like to know what I did wrong in the setup and how to properly implement blocking code with SmallRye Reactive. Here's a overview of how this is implemented:

@Blocking
@Incoming("orders")
@Acknowledgment(Acknowledgment.Strategy.POST_PROCESSING)
public void consume(Object payload) {
   DomainModel order = parse(payload);

   // blocking call to the DB
   repository.save(order);

   // we add metadata attrobutes
   Message<DomainModel> downstreamMessage = generateDownstreamMessage(order);
   
    emitter.send(downstreamMessage);
}

Kind regards

clement escoffier

unread,
Oct 12, 2021, 2:13:48 AM10/12/21
to smal...@googlegroups.com
Hello,

Emitters bridge reactive and imperative, so before sending you should verify that you can send (hasRequests()). It will indicate if the downstream components has the capacity to handle the message. If it returns false, you should not send and wait.

Alternatively, you can configure the overflow strategy on the emitter using the OnOverflow annotation.

Finally, and that would be my recommendation, except if you really need it, I would not use an emitter but just use a regular @Outgoing which then would use back-pressure signals correctly and pace the emissions accordingly.

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/813fb0a1-071e-4289-87c9-7d1b1bf7ae87n%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages