public SearchPagedResponse runExample(
GoogleAdsClient googleAdsClient, long customerId, @Nullable Long 
campaignId,String searchQuery) {
try (GoogleAdsServiceClient googleAdsServiceClient =
googleAdsClient.getLatestVersion().createGoogleAdsServiceClient()) {
// String searchQuery = "SELECT campaign.id, ad_group.id, ad_group.name 
FROM ad_group";

// Creates a request that will retrieve all ad groups using pages of the 
specified page size.
SearchGoogleAdsRequest request =
SearchGoogleAdsRequest.newBuilder()
.setCustomerId(Long.toString(customerId))
// .setPageSize(PAGE_SIZE)
.setQuery(searchQuery)
.build();
// Issues the search request.
SearchPagedResponse searchPagedResponse = 
googleAdsServiceClient.search(request);
return searchPagedResponse;

}
}

On Thursday, February 25, 2021 at 8:25:36 PM UTC+8 kathy pitter wrote:

>
>
>
> Report an error every time you turn to next page,why?
>
> my code:
> public void pullAdsMarketingMaterial() {
> long start = System.currentTimeMillis();
>
> List<GoogleCustomer> googleCustomers = googleCustomerMapper.selectAll();
>
>
> for (GoogleCustomer customer : googleCustomers) {
> if (customer.getManager()) {
> continue;
> }
> GoogleAdsClient googleAdsClient = getGoogleAdsClient();
> try {
> String searchQuery = "SELECT asset.id,asset.name,asset.type" +
> ", asset.image_asset.full_size.url" +
> ",asset.text_asset.text" +
> ",asset.youtube_video_asset.youtube_video_id" +
> " FROM asset";
> GoogleAdsServiceClient.SearchPagedResponse searchPagedResponse = new 
> GetAdGroups()
> .runExample(googleAdsClient, customer.getCustomerId(), null, searchQuery);
>
> try {
> for (GoogleAdsRow row : searchPagedResponse.iterateAll()) {
>
> GoogleMaterial googleMaterial = googleMaterialMapper
> .selectByMaterialId(row.getAsset().getId());
>
> if (googleMaterial == null) {
> GoogleMaterial googleMaterialUpdate = new GoogleMaterial();
> googleMaterialUpdate.setAdAccountId(customer.getCustomerId());
> googleMaterialUpdate.setMaterialId(row.getAsset().getId());
> googleMaterialUpdate.setMaterialName(row.getAsset().getName());
> if (row.getAsset().hasTextAsset()) {
> googleMaterialUpdate.setMaterialType(2);
>
> googleMaterialUpdate.setMaterialContent(row.getAsset().getTextAsset().getText());
> } else if (row.getAsset().hasYoutubeVideoAsset()) {
> googleMaterialUpdate.setMaterialType(1);
> //https://www.youtube.com/watch?v=EwyXaGseI0E,youtube
> googleMaterialUpdate.setMaterialContent("https://www.youtube.com/watch?v="; 
> + row.getAsset().getYoutubeVideoAsset().getYoutubeVideoId());
> } else if (row.getAsset().hasImageAsset()) {
> googleMaterialUpdate.setMaterialType(0);
>
> googleMaterialUpdate.setMaterialContent(row.getAsset().getImageAsset().getFullSize().getUrl());
> }
>
> googleMaterialUpdate.setCreateTime(new Date());
> googleMaterialMapper.insert(googleMaterialUpdate);
> }
>
> }
> } catch (RejectedExecutionException e) {
> logger.error(e.getMessage());
> logger.error("pullAdsMarketingMaterial,customerId:{}", 
> customer.getCustomerId());
> }
>
> } catch (GoogleAdsException gae) {
> logger.error("Request ID {} failed due to GoogleAdsException. Underlying 
> errors:%n",
> gae.getRequestId());
> int n = 0;
> for (GoogleAdsError googleAdsError : 
> gae.getGoogleAdsFailure().getErrorsList()) {
> logger.error(" Error {}: {}%n", n++, googleAdsError);
> }
> System.exit(1);
> }
> }
>
> long cost = System.currentTimeMillis() - start;
>
> }
>
>
> error:
> java.util.concurrent.RejectedExecutionException: Task 
> java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@30004eeb 
> rejected from 
> java.util.concurrent.ScheduledThreadPoolExecutor@63e21ccb[Terminated, pool 
> size = 0, active threads = 0, queued tasks = 0, completed tasks = 3]
>
>  at 
> java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2047)
>  at 
> java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:823)
>  at 
> java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:326)
>  at 
> java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:533)
>  at 
> java.util.concurrent.ScheduledThreadPoolExecutor.execute(ScheduledThreadPoolExecutor.java:622)
>  at 
> io.grpc.internal.SerializingExecutor.schedule(SerializingExecutor.java:93)
>  at 
> io.grpc.internal.SerializingExecutor.execute(SerializingExecutor.java:86)
>  at 
> io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.closedInternal(ClientCallImpl.java:750)
>  at 
> io.grpc.internal.ClientCallImpl$ClientStreamListenerImpl.closed(ClientCallImpl.java:686)
>  at io.grpc.internal.FailingClientStream.start(FailingClientStream.java:54)
>  at io.grpc.internal.ClientCallImpl.startInternal(ClientCallImpl.java:274)
>  at io.grpc.internal.ClientCallImpl.start(ClientCallImpl.java:204)
>  at io.grpc.ForwardingClientCall.start(ForwardingClientCall.java:32)
>  at 
> com.google.api.gax.grpc.GrpcHeaderInterceptor$1.start(GrpcHeaderInterceptor.java:94)
>  at io.grpc.ForwardingClientCall.start(ForwardingClientCall.java:32)
>  at 
> com.google.ads.googleads.lib.logging.LoggingInterceptor$1.start(LoggingInterceptor.java:77)
>  at io.grpc.stub.ClientCalls.startCall(ClientCalls.java:332)
>  at io.grpc.stub.ClientCalls.asyncUnaryRequestCall(ClientCalls.java:306)
>  at io.grpc.stub.ClientCalls.futureUnaryCall(ClientCalls.java:218)
>  at 
> com.google.api.gax.grpc.GrpcDirectCallable.futureCall(GrpcDirectCallable.java:58)
>  at 
> com.google.api.gax.grpc.GrpcUnaryRequestParamCallable.futureCall(GrpcUnaryRequestPara
>
>
>
>

-- 
-- 
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~
Also find us on our blog:
https://googleadsdeveloper.blogspot.com/
=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~

You received this message because you are subscribed to the Google
Groups "AdWords API and Google Ads API Forum" group.
To post to this group, send email to adwords-api@googlegroups.com
To unsubscribe from this group, send email to
adwords-api+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/adwords-api?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"AdWords API and Google Ads API Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to adwords-api+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/adwords-api/e2cfef84-d23b-47f1-b741-574ed04f3fc1n%40googlegroups.com.

Reply via email to