Search in sources :

Example 6 with Task

use of com.google.cloud.tasks.v2.Task in project kie-wb-common by kiegroup.

the class ActivityPropertyWriterTest method testEmptyInputOutputSet.

@Test
public void testEmptyInputOutputSet() {
    Task task = bpmn2.createTask();
    ActivityPropertyWriter activityPropertyWriter = new ActivityPropertyWriter(task, new FlatVariableScope(), new HashSet<>());
    activityPropertyWriter.setAssignmentsInfo(new AssignmentsInfo("||||"));
    assertNull(task.getIoSpecification());
}
Also used : Task(org.eclipse.bpmn2.Task) AssignmentsInfo(org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo) Test(org.junit.Test)

Example 7 with Task

use of com.google.cloud.tasks.v2.Task in project kie-wb-common by kiegroup.

the class TestDefinitionsWriter method mockNode.

public FlowNode mockNode(String id, Bounds bounds) {
    Task node = bpmn2.createTask();
    node.setId(id);
    BPMNShape shape = di.createBPMNShape();
    shape.setBounds(bounds);
    shape.setBpmnElement(node);
    bpmnPlane.getPlaneElement().add(shape);
    return node;
}
Also used : Task(org.eclipse.bpmn2.Task) BPMNShape(org.eclipse.bpmn2.di.BPMNShape)

Example 8 with Task

use of com.google.cloud.tasks.v2.Task in project workbench by all-of-us.

the class ForwardingCloudTasksStub method createTaskCallable.

@Override
public UnaryCallable<CreateTaskRequest, Task> createTaskCallable() {
    return new UnaryCallable<CreateTaskRequest, Task>() {

        @Override
        public ApiFuture<Task> futureCall(CreateTaskRequest request, ApiCallContext context) {
            final QueueName queueName = QueueName.parse(request.getParent());
            final AppEngineHttpRequest gaeReq = request.getTask().getAppEngineHttpRequest();
            final Request apiReq = new Request.Builder().url(baseUrl + gaeReq.getRelativeUri()).headers(Headers.of(gaeReq.getHeadersMap())).addHeader("X-AppEngine-QueueName", queueName.getQueue()).post(RequestBody.create(MediaType.parse("application/json; charset=utf-8"), gaeReq.getBody().toStringUtf8())).build();
            log.info(String.format("asynchronously forwarding task request for queue '%s', to handler '%s'", queueName.getQueue(), apiReq.url()));
            OkHttpClient client = new OkHttpClient();
            client.setReadTimeout(10, TimeUnit.MINUTES);
            client.newCall(apiReq).enqueue(new Callback() {

                @Override
                public void onFailure(Request request, IOException e) {
                    log.log(Level.SEVERE, "task execution failed", e);
                }

                @Override
                public void onResponse(Response response) {
                }
            });
            return ApiFutures.immediateFuture(request.getTask());
        }
    };
}
Also used : Task(com.google.cloud.tasks.v2.Task) OkHttpClient(com.squareup.okhttp.OkHttpClient) UnaryCallable(com.google.api.gax.rpc.UnaryCallable) CreateTaskRequest(com.google.cloud.tasks.v2.CreateTaskRequest) AppEngineHttpRequest(com.google.cloud.tasks.v2.AppEngineHttpRequest) Request(com.squareup.okhttp.Request) ApiCallContext(com.google.api.gax.rpc.ApiCallContext) IOException(java.io.IOException) AppEngineHttpRequest(com.google.cloud.tasks.v2.AppEngineHttpRequest) Response(com.squareup.okhttp.Response) Callback(com.squareup.okhttp.Callback) CreateTaskRequest(com.google.cloud.tasks.v2.CreateTaskRequest) QueueName(com.google.cloud.tasks.v2.QueueName)

Example 9 with Task

use of com.google.cloud.tasks.v2.Task in project java-docs-samples by GoogleCloudPlatform.

the class CreateQueue method createQueue.

public static void createQueue(String projectId, String locationId, String queueBlueName, String queueRedName) throws Exception {
    try (CloudTasksClient client = CloudTasksClient.create()) {
        // TODO(developer): Uncomment these lines and replace with your values.
        // String projectId = "your-project-id";
        // String locationId = "us-central1";
        // String queueBlueName = "queue-blue";
        // String queueRedName = "queue-red";
        LocationName parent = LocationName.of(projectId, locationId);
        Queue queueBlue = Queue.newBuilder().setName(QueueName.of(projectId, locationId, queueBlueName).toString()).setRateLimits(RateLimits.newBuilder().setMaxDispatchesPerSecond(5.0)).setAppEngineRoutingOverride(AppEngineRouting.newBuilder().setVersion("v2").setService("task-module")).build();
        Queue queueRed = Queue.newBuilder().setName(QueueName.of(projectId, locationId, queueRedName).toString()).setRateLimits(RateLimits.newBuilder().setMaxDispatchesPerSecond(1.0)).build();
        Queue[] queues = new Queue[] { queueBlue, queueRed };
        for (Queue queue : queues) {
            Queue response = client.createQueue(parent, queue);
            System.out.println(response);
        }
    }
}
Also used : CloudTasksClient(com.google.cloud.tasks.v2.CloudTasksClient) Queue(com.google.cloud.tasks.v2.Queue) LocationName(com.google.cloud.tasks.v2.LocationName)

Example 10 with Task

use of com.google.cloud.tasks.v2.Task in project java-docs-samples by GoogleCloudPlatform.

the class CreateTask method createTask.

public static void createTask(String projectId, String locationId, String queueId) throws Exception {
    try (CloudTasksClient client = CloudTasksClient.create()) {
        // TODO(developer): Uncomment these lines and replace with your values.
        // String projectId = "your-project-id";
        // String locationId = "us-central1";
        // String queueId = "default";
        String key = "key";
        // Construct the fully qualified queue name.
        String queueName = QueueName.of(projectId, locationId, queueId).toString();
        // Construct the task body.
        Task taskParam = Task.newBuilder().setAppEngineHttpRequest(AppEngineHttpRequest.newBuilder().setRelativeUri("/worker?key=" + key).setHttpMethod(HttpMethod.GET).build()).build();
        Task taskPayload = Task.newBuilder().setAppEngineHttpRequest(AppEngineHttpRequest.newBuilder().setBody(ByteString.copyFrom(key, Charset.defaultCharset())).setRelativeUri("/worker").setHttpMethod(HttpMethod.POST).build()).build();
        // Send create task request.
        Task[] tasks = new Task[] { taskParam, taskPayload };
        for (Task task : tasks) {
            Task response = client.createTask(queueName, task);
            System.out.println(response);
        }
    }
}
Also used : Task(com.google.cloud.tasks.v2.Task) CloudTasksClient(com.google.cloud.tasks.v2.CloudTasksClient) ByteString(com.google.protobuf.ByteString)

Aggregations

Task (com.google.cloud.tasks.v2.Task)33 Test (org.junit.jupiter.api.Test)19 Task (org.eclipse.bpmn2.Task)17 Test (org.junit.Test)12 CloudTasksClient (com.google.cloud.tasks.v2.CloudTasksClient)11 ByteString (com.google.protobuf.ByteString)7 FlowElement (org.eclipse.bpmn2.FlowElement)5 InputSet (org.eclipse.bpmn2.InputSet)5 AssignmentsInfo (org.kie.workbench.common.stunner.bpmn.definition.property.dataio.AssignmentsInfo)5 Queue (com.google.cloud.tasks.v2.Queue)4 AdHocSubProcess (org.eclipse.bpmn2.AdHocSubProcess)4 BusinessRuleTask (org.eclipse.bpmn2.BusinessRuleTask)4 GlobalTask (org.eclipse.bpmn2.GlobalTask)4 OutputSet (org.eclipse.bpmn2.OutputSet)4 Process (org.eclipse.bpmn2.Process)4 ReceiveTask (org.eclipse.bpmn2.ReceiveTask)4 RootElement (org.eclipse.bpmn2.RootElement)4 ScriptTask (org.eclipse.bpmn2.ScriptTask)4 SendTask (org.eclipse.bpmn2.SendTask)4 ServiceTask (org.eclipse.bpmn2.ServiceTask)4