Creating a subscription on GCP Pub Sub with "Acknowledgement deadline" set as its max value (600 seconds), my java client in spring boot, keeps receiving messages every 60 seconds in case the task is still running.
We have a simple consumer very similar to this: https://spring.io/guides/gs/messaging-gcp-pubsub/
We need to perform operations which can run for some minutes each, but even setting 600 seconds, if the task hasn't finished after 60 seconds, the message arrives again.
Doesn't someone experienced something similar? Thanks
Update:
These are the main dependencies:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.10.RELEASE</version>
</parent>
<spring-cloud-gcp.version>1.2.6.RELEASE</spring-cloud-gcp.version>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-gcp-starter-pubsub</artifactId>
</dependency>
And this is the setup in the consumer (it's exactly as the spring boot guide linked above explains):
@Bean
public PubSubInboundChannelAdapter messageChannelAdapter(
@Qualifier("pubsubInputChannel") MessageChannel inputChannel,
PubSubTemplate pubSubTemplate) {
LOGGER.info("pubsubInputChannel");
PubSubInboundChannelAdapter adapter =
new PubSubInboundChannelAdapter(pubSubTemplate, subscription);
adapter.setOutputChannel(inputChannel);
adapter.setAckMode(AckMode.AUTO_ACK);
return adapter;
}
@Bean
public MessageChannel pubsubInputChannel() {
return new DirectChannel();
}
@Bean
@ServiceActivator(inputChannel = "pubsubInputChannel")
public MessageHandler messageReceiver() {
return message -> {
String json = new String((byte[]) message.getPayload());
LOGGER.info("Message arrived! Payload: " + json);
//Main code here
//Operations might take some minutes to be finished
};
}