We can add retry settings and failure handlers while publishing message on pubsub.
So in case of errors Publisher will retry to publish the message. So does it invokes onFailure handler every time it tries the same message and fails ?
Any further impact when message ordering is enabled ?
Good day @ankit-pradhan ,
Welcome back to Google Cloud Community!
Publishers will apply retry time out settings and retry delay on the publishers requests or publisher client. You can check this link to learn more and see a sample code: https://cloud.google.com/pubsub/docs/samples/pubsub-publisher-retry-settings
If you use retry settings or requests while the ordering is enabled, the client library will retry the request continuously disregarding the retry settings. Here is a sample scenario in the documentation:
If a non-retryable error occurs, the client library doesn't publish the message and stops publishing other messages with the same ordering key. For example, when a publisher sends a message to a topic that doesn't exist, a non-retryable error occurs. To continue publishing messages with the same ordering key, call a method to resume publishing and then start publishing again.
You can learn more using this documentation and see sample code: https://cloud.google.com/pubsub/docs/publisher#retry_ordering
Please note that enabling ordering might increase the latency. You can check this documentation to learn more: https://cloud.google.com/pubsub/docs/publisher#using-ordering-keys
Hope this will help!
As per below comment I understand that it will continuously retry . Just curious if there is any threshold or it will retry forever ?
If it retries forever how to handle that ?
@kvandres wrote:If you use retry settings or requests while the ordering is enabled, the client library will retry the request continuously disregarding the retry settings. Here is a sample scenario in the documentation:
Hi @ankit-pradhan,
When message ordering is enabled, the Publisher will retry the message until it is successfully published in the correct order. The number of retries is determined by the retry policy that is configured for the subscription. The default retry policy retries the message up to 10 times.
If the message is still not successfully published after 10 retries, it will be sent to the dead letter queue. The dead letter queue is a special queue that is used to store messages that have failed to be published. You can then manually process the messages in the dead letter queue [or delete it].
Hope this helps,