I have a simple Spring boot application hosted in Google Cloud Run which publishes a Google Pub/Sub message to a topic in the same project.
This is taking a long time for about 5 min roughly. Below is the code that I use to publish the Google Pub/Sub message. But the same was working fine with no delay in App Engine environment.
ApiFuture<String> messageIdFuture = com.google.cloud.pubsub.v1.Publisher.publish(pubsubMessage);
ApiFutures.addCallback(messageIdFuture, new ApiFutureCallback<String>() {
@Override
public void onFailure(Throwable throwable) {
if (throwable instanceof ApiException) {
ApiException apiException = ((ApiException) throwable);
// details on the API exception
log.error("APIException Status Code: {}", apiException.getStatusCode().getCode());
log.error("APIException is Retryable: {}", apiException.isRetryable());
}
log.error("Error publishing message: {}", pubSubMsg);
}
@Override
public void onSuccess(String messageId) {
log.info("Success msg after publish: {}", messageId);
}
}, MoreExecutors.directExecutor());
How can I overcome this delay in publishing the Pub/Sub message?