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.
--
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.