The following code works fine when deployed to the app engine flexible environment and calls the relevant /push endpoint.
Publisher publisher = null;
try {
publisher = Publisher.defaultBuilder(topic).build();
ByteString data = ByteString.copyFromUtf8("my-message");
PubsubMessage pubsubMessage = PubsubMessage.newBuilder().setData(data).build();
ApiFuture<String> messageIdFuture = publisher.publish(pubsubMessage);
} finally {
if (publisher != null) {
publisher.shutdown();
}
}
However, when changed the "publisher" instantiation to the following (using the JSON), the publish code executes fine, but the /push endpoint is not called.
Resource resource = new ClassPathResource("xxxx.json");
final InputStream inputStream = resource.getInputStream();
CredentialsProvider credentialsProvider = FixedCredentialsProvider.create(
ServiceAccountCredentials.fromStream(inputStream));
publisher = Publisher.defaultBuilder(TopicName.create("microservice-qa", "testtopic1"))
.setCredentialsProvider(credentialsProvider)
.build();
Any idea on why this is the case?
The following code works fine when deployed to the app engine flexible environment and calls the relevant /push endpoint.
However, when changed the "publisher" instantiation to the following (using the JSON), the publish code executes fine, but the /push endpoint is not called.
Any idea on why this is the case?