Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google Cloud Tasks integration #31138

Closed
kamal-j opened this issue Feb 14, 2023 · 2 comments
Closed

Google Cloud Tasks integration #31138

kamal-j opened this issue Feb 14, 2023 · 2 comments
Labels

Comments

@kamal-j
Copy link

kamal-j commented Feb 14, 2023

Describe the bug

I'm trying to create a quarkus app that creates tasks in Google Cloud Tasks. I'm using the Google Cloud Java Client Library. I'm unable to build my app after integrating the sdk.

This is my quarkus app code :

package org.acme;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;

import com.google.cloud.tasks.v2.*;
import com.google.protobuf.ByteString;

@Path("/create-task")
public class GreetingResource {

    @Inject
    CloudTasksClient cloudTasksClient;

    @GET
    public String createTask() throws Exception {
        QueueName queueName = QueueName.of("project-id", "location-id", "queue-id");
        Task task = Task.newBuilder()
                .setHttpRequest(
                        HttpRequest.newBuilder()
                                .setUrl("https://task-handler-service.com/handle-task")
                                .setHttpMethod(HttpMethod.POST)
                                .setBody(ByteString.copyFromUtf8("{\"message\":\"test task\",\"reschedule\":true}"))
                                .build())
                .build();
        cloudTasksClient.createTask(queueName, task);
        return "Task created!";
    }
}

I'm getting the following error when building the app :

[INFO] --- quarkus-maven-plugin:2.16.2.Final:build (default) @ task-producer ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  5.665 s
[INFO] Finished at: 2023-02-14T11:26:59+05:30
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal io.quarkus.platform:quarkus-maven-plugin:2.16.2.Final:build (default) on project task-producer: Failed to build quarkus application: io.quarkus.builder.BuildException: Build failure: Build failed due to errors
[ERROR]         [error]: Build step io.quarkus.arc.deployment.ArcProcessor#validate threw an exception: javax.enterprise.inject.spi.DeploymentException: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type com.google.cloud.tasks.v2.CloudTasksClient and qualifiers [@Default]
[ERROR]         - java member: org.acme.GreetingResource#cloudTasksClient
[ERROR]         - declared on CLASS bean [types=[org.acme.GreetingResource, java.lang.Object], qualifiers=[@Default, @Any], target=org.acme.GreetingResource]
[ERROR]         at io.quarkus.arc.processor.BeanDeployment.processErrors(BeanDeployment.java:1223)
[ERROR]         at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:288)
[ERROR]         at io.quarkus.arc.processor.BeanProcessor.initialize(BeanProcessor.java:148)
[ERROR]         at io.quarkus.arc.deployment.ArcProcessor.validate(ArcProcessor.java:526)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[ERROR]         at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
[ERROR]         at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
[ERROR]         at java.base/java.lang.reflect.Method.invoke(Method.java:566)
[ERROR]         at io.quarkus.deployment.ExtensionLoader$3.execute(ExtensionLoader.java:909)
[ERROR]         at io.quarkus.builder.BuildContext.run(BuildContext.java:281)
[ERROR]         at org.jboss.threads.ContextHandler$1.runWith(ContextHandler.java:18)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$Task.run(EnhancedQueueExecutor.java:2449)
[ERROR]         at org.jboss.threads.EnhancedQueueExecutor$ThreadBody.run(EnhancedQueueExecutor.java:1478)
[ERROR]         at java.base/java.lang.Thread.run(Thread.java:829)
[ERROR]         at org.jboss.threads.JBossThread.run(JBossThread.java:501)
[ERROR] Caused by: javax.enterprise.inject.UnsatisfiedResolutionException: Unsatisfied dependency for type com.google.cloud.tasks.v2.CloudTasksClient and qualifiers [@Default]
[ERROR]         - java member: org.acme.GreetingResource#cloudTasksClient
[ERROR]         - declared on CLASS bean [types=[org.acme.GreetingResource, java.lang.Object], qualifiers=[@Default, @Any], target=org.acme.GreetingResource]
[ERROR]         at io.quarkus.arc.processor.Beans.resolveInjectionPoint(Beans.java:440)
[ERROR]         at io.quarkus.arc.processor.BeanInfo.init(BeanInfo.java:539)
[ERROR]         at io.quarkus.arc.processor.BeanDeployment.init(BeanDeployment.java:276)
[ERROR]         ... 13 more
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

Darwin Kamaldeeps-MacBook-Pro.local 21.4.0 Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64 x86_64

Output of java -version

openjdk version "11.0.12" 2021-07-20 OpenJDK Runtime Environment Homebrew (build 11.0.12+0) OpenJDK 64-Bit Server VM Homebrew (build 11.0.12+0, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

No response

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.6 (84538c9988a25aec085021c365c560670ad80f63) Maven home: /Users/kamaldeepjayaprakash/.m2/wrapper/dists/apache-maven-3.8.6-bin/67568434/apache-maven-3.8.6 Java version: 11.0.12, vendor: Homebrew, runtime: /usr/local/Cellar/openjdk@11/11.0.12/libexec/openjdk.jdk/Contents/Home Default locale: en_IN, platform encoding: US-ASCII OS name: "mac os x", version: "12.3.1", arch: "x86_64", family: "mac"

Additional information

No response

@kamal-j kamal-j added the kind/bug Something isn't working label Feb 14, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Feb 14, 2023

/cc @loicmathieu (google-cloud)

@zanmagerl
Copy link

@kamal-j Google Cloud official clients are not exposed as beans in the libraries. If you want to use them in CDI you need to create a producer method, something like this:

@Singleton
public CloudTasksClient cloudTaskClient() {
    return CloudTasksClient.create();
}

But there is an open issue regarding that in the Quarkiverse repository, where such producer could be added in the future: quarkiverse/quarkus-google-cloud-services#300

@kamal-j kamal-j closed this as completed Feb 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants