You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2023/01/18 22:02:23 UTC

[GitHub] [pulsar] frankjkelly commented on issue #16249: Pulsar Admin API client should support retries on operations

frankjkelly commented on issue #16249:
URL: https://github.com/apache/pulsar/issues/16249#issuecomment-1396150858

   @martijngonlag Sorry I took so long to get back to you.
   
   The problem then becomes our code is littered with the following since some of the exceptions are not retryable and others are. And then we have to catch this further up and (using Spring) do the retries. It's an awful lot of boilerplate and particularly problematic for customers like us that create and delete a lot of topics. Especially with ZK being such a non-performant beast (and involved on the create/delete topic flow).
   
   ```
       private void createTopic(final URI topic) throws StreamManagerAdminException {
           try {
               val start = System.currentTimeMillis();
               pulsarAdmin.topics().createNonPartitionedTopic(topic.toString());
               val durationMs = System.currentTimeMillis() - start;
               recordDurationMetric("createTopic", durationMs);
           } catch (final PulsarAdminException e) {
               castAndRethrowException(e);
           }
       }
   
   
       private void castAndRethrowException(final PulsarAdminException e) throws StreamManagerAdminException {
           //Need to be able to distinguish between exceptions to be able to know which are retryable or not
           // However we do not want to expose Pulsar Internals beyond this layer
           if (e.getStatusCode() == 503) {
               throw new StreamManagerServiceUnavailableException(e);
           } else if (didPulsarAdminExhaustRetries(e)) {
               throw new StreamManagerRetryException(e);
           } else {
               throw new StreamManagerAdminException(e);
           }
       }
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org