6

I have a java code initiate a PubsubSubscriber with an executor Provider. It works for like 16 hr of idling. However, about 1 day of idling it stopped receive message from the subscription. If I restart the program it will go back to work again. I read from the documentation https://googleapis.dev/java/google-cloud-clients/latest/index.html?com/google/cloud/pubsub/v1/package-summary.html That to keep the subscriber running forever, need a executor provider. I initiated with one

ExecutorProvider executorProvider = FixedExecutorProvider.create(myScheduledExecutorService);
this.subscriber = Subscriber
                    .newBuilder(subscriptionName, this)
                    .setExecutorProvider(executorProvider)
                    .setCredentialsProvider(myCredentialsProvider)
                    .build();

The executorProvider above is created by

Is there something else need to be set up to make sure the subscriber keep receiving the messages?

Sam Tsai
  • 373
  • 1
  • 2
  • 15
  • Where is your Pub/Sub subscriber running? (eg. on premises, on GCP in a Compute Engine, in Kubernetes) – Kolban Oct 28 '19 at 19:13
  • Kolban The subscriber is running on permises in linux box. – Sam Tsai Oct 28 '19 at 20:13
  • This might be a duplicate of ... https://stackoverflow.com/questions/48834419/google-pub-sub-subscriber-not-receiving-messages-after-a-while There is a really good answer there. If nothing else, please review the answer supplied there and update the question with responses to these possibilities .. if nothing else to exclude them as potentials. You might also consider raising an issue here https://github.com/googleapis/nodejs-pubsub ... however I suspect that you will be asked for the answers asked for in this post too. – Kolban Oct 28 '19 at 23:06
  • I read that post before. In my case the credential was right, messages got acknowledged after receiving. We only have one subscriber for the subscription. Pretty much every thing mentioned on that post has been checked for my case. One difference is the post was using Python and I am using Java. This should not make much of differences in terms of the subscriber behaivor. – Sam Tsai Oct 29 '19 at 15:48
  • Do you have any logs available? Is it possible your Java application is crashing or your machine is rebooting? – Travis Webb Nov 02 '19 at 05:34
  • Yes. It has log. We did not see any sign of restart or the crash. There is no error show up on the log for pubsub subscriber or credential provider. – Sam Tsai Nov 05 '19 at 17:43

1 Answers1

0

Where is it running? I had problems with my java bot using google cloud, a quick fix was using screen.

apt-get install screen
screen

to resume to your bot view use:

screen -r

maybe works for you.

Nowbie
  • 15
  • 1
  • 6
  • This code is running in a server as a service. The service is written in Java with Guice for dependency injection. At the moment, I wrote my own rest client to go against Pubsub rest api and worked just fine for over a week of running. – Sam Tsai Nov 12 '19 at 16:20
  • @SamTsai is it still running, if it is still running would you mind sharing in a bit more detail what you did? – Soni Sol Dec 05 '19 at 02:32