Closed thayhoang closed 3 years ago
How can I manually ack/nack message using spring could pubsub streaming? With rabbitMq, I can do something like this
@StreamListener(target = BAR) public void handlerMethod(Foo foo, @Header(AmqpHeaders.CHANNEL) Channel channel, @Header(AmqpHeaders.DELIVERY_TAG) Long deliveryTag) { if (....) { channel.basickAck(deliveryTag, false); } else { channel.basicNack(deliveryTag, false, true); } }
Currently, with pubsub, I have to throw an Exception in order to nack the message. I'm wonder if there's a cleaner way.
There is! 1) Set manual acking through spring.cloud.stream.gcp.pubsub.bindings.{CONSUMER_NAME}.consumer.ack-mode property (docs)
spring.cloud.stream.gcp.pubsub.bindings.{CONSUMER_NAME}.consumer.ack-mode
2) Use GcpPubSubHeaders.ORIGINAL_MESSAGE header to ack/nack manually (docs)
GcpPubSubHeaders.ORIGINAL_MESSAGE
How can I manually ack/nack message using spring could pubsub streaming? With rabbitMq, I can do something like this
Currently, with pubsub, I have to throw an Exception in order to nack the message. I'm wonder if there's a cleaner way.