Search code examples
spring-bootspring-cloud-streamamazon-kinesis

Delay on StreamListener or condition


I'm reading docs but I'm not sure if this is possible on spring-cloud-stream using binder for kinesis. I want to wait consuming messages from stream with some delay or configuration or by positive condition.

For example, I want wait 30 minutes after consumer process the message.

First aproximation is use condition with SPEL based on header message and current time, but the condition is created on startup. Then new Date is always the same.

I know that condition in below code is invalid.

@StreamListener(StreamProcessor.MY_STREAM, condition="#{headers['creation-date'] + 30minutes < new java.util.Date().getTime()}")
public void checkOut(Message<String> myMessage) {

   //Do something
}

Do you know if is this possible without sleeping threads?


Solution

  • All you need is use Polled Consumer, this way you have full control over frequency, acks etc.