简体   繁体   中英

io.grpc.StatusRuntimeException: DEADLINE_EXCEEDED while getting the topic(publisher) name from Google cloud PubSub

Our application uses Google PubSub(Publisher-Subscriber) for asynchronous communication across the services. At one of the services in the application, it checks if the topic(publisher) name exists or not in PubSub. If it doesn't exist in PubSub, the service has a logic to create topic(publisher) name at restart else it logs the message that the topic(publisher) name already exists in Google PubSub.

Description of Issue:

  • A new feature was built at one of the services where JSON is stored in a file and upload to AWS S3.
  • As a part of the feature, AWS S3 dependency was required to add to the Gradle file.
  • After enabling the AWS S3 dependency at Gradle, PubSub had an issue with getting the topic name(which already existed at PubSub) and threw an exception "io.grpc.StatusRuntimeException: DEADLINE_EXCEEDED" . Also, service wasn't able to publish the messages to the topic which threw an exception "java.util.concurrent.TimeoutException" .
  • After disabling the AWS S3 dependency at Gradle, PubSub was able to get the topic(publisher) name and was able to publish the message to the topic also which worked as expected.

Summary:

  • Disable AWS s3 at Gradle, PubSub is working as expected.
  • Enable AWS s3 at Gradle, PubSub is throwing an exception.
// Reading the PubSub Configurations from file
File file = new File(ServiceConfigJson.PUBSUB_CONFIG_FILE_PATH); 
InputStream stream = new FileInputStream(file);

// Authenticating and Checking whether topic name exists or not 
AuthCredentials.ServiceAccountAuthCredentials auth = AuthCredentials.createForJson(stream);
pubsub = PubSubOptions.builder().projectId("anna-us").authCredentials(auth).build().service();
Topic pubSubTopic = pubsub.getTopic(topicName);

if (pubSubTopic == null)
{
   // Creates the new topic
   Topic topic = pubsub.create(TopicInfo.of(topicName));
   logger.debug("PubSubTopic with topic name {} created", topic.name());
}
else
{
   logger.info("PubSubTopic with topic name {} already exists", topicName);
}

It would be of great help if someone could give an insight on this.

Versions used:

compile group: 'com.google.cloud', name: 'google-cloud-pubsub', version: '0.4.0'
compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.931'

I have changed my dependency on Gradle by adding a library only for AWS S3 instead of the whole AWS SDK.

compile group: 'com.amazonaws', name: 'aws-java-sdk', version: '1.11.931' to compile group: 'com.amazonaws', name: 'aws-java-sdk-s3', version: '1.11.934'

After changing this, PubSub started to work fine for me.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM