Unable to access Google Cloud Pub/Sub component using Java API (System is hanging forever)

515 views
Skip to first unread message

Tridib Bolar

unread,
Aug 27, 2017, 2:30:25 PM8/27/17
to Google Cloud Pub/Sub Discussions

I was successfully able to publish message into Pub/Sub topic till yesterday. But from today morning code is getting hanged forever during publishing. My problem is same as describe here. Then I have tried to create a topic using Java API as describe in the code snippet below

TopicName topic = TopicName.create(projectId, topicId);

try {
  TopicAdminClient topicAdminClient = TopicAdminClient.create();
  topicAdminClient.createTopic(topic); //HANG FOREVER
}catch(Exception e){
  e.printStackTrace();
} 

The code is hanging again at topicAdminClient.createTopic.

I am using com.google.pubsub.v1 package for GCP Pub/Sub along with com.google.cloud.pubsub.v1.TopicAdminClient. I have tried with default authentication credential as well as setting GOOGLE_APPLICATION_CREDENTIAL with Service Account Key. I am not sure where I am doing wrong. Can anyone help me to resolve this issue?

My code to publish message is as below

FileInputStream fis = new FileInputStream(new File("JSON file path"));
ApiFuture<String> messageId = publishMessage(publisher, 
ByteString.copyFrom(IOUtils.toByteArray(fis)));

where publishMessage is defined as below

private static ApiFuture<String> publishMessage(Publisher publisher, ByteString message)
            throws Exception {
    // convert message to bytes
    PubsubMessage pubsubMessage = 
    PubsubMessage.newBuilder().setData(message).build();
    return publisher.publish(pubsubMessage);
}

Additional Info: I have tried to execute datastore Java api and it is executing seamlessly. Maybe the problem is only with Pubsub I guess.

Alex Mordkovich

unread,
Aug 28, 2017, 10:18:46 AM8/28/17
to Tridib Bolar, Google Cloud Pub/Sub Discussions
Hi Tridib,
Is it only the Java client library that is having issues talking to Pub/Sub? Are you able to 'ping pubsub.googleapis.com' ? Could you provide any logs from the code making the requests? Are there any errors?


--
You received this message because you are subscribed to the Google Groups "Google Cloud Pub/Sub Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-pubsub-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-pubsub-discuss/0c3cab10-6784-4d61-bdd4-e511e0a190ee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages