简体   繁体   中英

Is BigQuery java api thread safe?

I would like to use BigQuery java api 'com.google.cloud:google-cloud-bigquery' in our project. I am creating service instance like this

BigQuery bq =
        BigQueryOptions.newBuilder()
            .setCredentials(credentials)
            .build()
            .getService();

Should I store this com.google.cloud.bigquery.BigQuery instance somewhere in the app and reuse it for every call? Is it thread safe? What is the recommended way?

Thanks!

I suggest having this as a global variable and reuse it as you may hit a rate limit due to multiple authentication requests. Moreover, if you plan use Threads, I suggest checking the BigQuery API quotas to consider them in your development.

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM