Search in sources :

Example 16 with ZeebeClient

use of io.camunda.zeebe.client.ZeebeClient in project zeebe by camunda.

the class ResponsiveHealthIndicatorTest method testCreateZeebeClientShouldConfigureContactPoint.

@Test
public void testCreateZeebeClientShouldConfigureContactPoint() {
    // when
    final ZeebeClient actual = ResponsiveHealthIndicator.createZeebeClient(TEST_CFG, TEST_DURATION);
    // then
    assertThat(actual.getConfiguration().getGatewayAddress()).isEqualTo("testhost:1234");
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) Test(org.junit.Test)

Example 17 with ZeebeClient

use of io.camunda.zeebe.client.ZeebeClient in project zeebe by camunda.

the class ResponsiveHealthIndicatorTest method testCreateZeebeClientShouldEnablePlainTextCommunicationIfSecurityIsDisabled.

@Test
public void testCreateZeebeClientShouldEnablePlainTextCommunicationIfSecurityIsDisabled() {
    // when
    final ZeebeClient actual = ResponsiveHealthIndicator.createZeebeClient(TEST_CFG, TEST_DURATION);
    // then
    assertThat(actual.getConfiguration().isPlaintextConnectionEnabled()).isTrue();
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) Test(org.junit.Test)

Example 18 with ZeebeClient

use of io.camunda.zeebe.client.ZeebeClient in project zeebe by camunda.

the class JobWorkerCreator method main.

public static void main(final String[] args) {
    final String defaultAddress = "localhost:26500";
    final String envVarAddress = System.getenv("ZEEBE_ADDRESS");
    final ZeebeClientBuilder clientBuilder;
    if (envVarAddress != null) {
        /* Connect to Camunda Cloud Cluster, assumes that credentials are set in environment variables.
       * See JavaDoc on class level for details
       */
        clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(envVarAddress);
    } else {
        // connect to local deployment; assumes that authentication is disabled
        clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(defaultAddress).usePlaintext();
    }
    final String jobType = "foo";
    try (final ZeebeClient client = clientBuilder.build()) {
        System.out.println("Opening job worker.");
        try (final JobWorker workerRegistration = client.newWorker().jobType(jobType).handler(new ExampleJobHandler()).timeout(Duration.ofSeconds(10)).open()) {
            System.out.println("Job worker opened and receiving jobs.");
            // run until System.in receives exit command
            waitUntilSystemInput("exit");
        }
    }
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder) JobWorker(io.camunda.zeebe.client.api.worker.JobWorker)

Example 19 with ZeebeClient

use of io.camunda.zeebe.client.ZeebeClient in project zeebe by camunda.

the class ProcessInstanceCreator method main.

public static void main(final String[] args) {
    final String defaultAddress = "localhost:26500";
    final String envVarAddress = System.getenv("ZEEBE_ADDRESS");
    final ZeebeClientBuilder clientBuilder;
    if (envVarAddress != null) {
        /* Connect to Camunda Cloud Cluster, assumes that credentials are set in environment variables.
       * See JavaDoc on class level for details
       */
        clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(envVarAddress);
    } else {
        // connect to local deployment; assumes that authentication is disabled
        clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(defaultAddress).usePlaintext();
    }
    final String bpmnProcessId = "demoProcess";
    try (final ZeebeClient client = clientBuilder.build()) {
        System.out.println("Creating process instance");
        final ProcessInstanceEvent processInstanceEvent = client.newCreateInstanceCommand().bpmnProcessId(bpmnProcessId).latestVersion().send().join();
        System.out.println("Process instance created with key: " + processInstanceEvent.getProcessInstanceKey());
    }
}
Also used : ZeebeClient(io.camunda.zeebe.client.ZeebeClient) ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder) ProcessInstanceEvent(io.camunda.zeebe.client.api.response.ProcessInstanceEvent)

Example 20 with ZeebeClient

use of io.camunda.zeebe.client.ZeebeClient in project zeebe by camunda.

the class ProcessInstanceWithResultCreator method main.

public static void main(final String[] args) {
    final String defaultAddress = "localhost:26500";
    final String envVarAddress = System.getenv("ZEEBE_ADDRESS");
    final ZeebeClientBuilder clientBuilder;
    if (envVarAddress != null) {
        /* Connect to Camunda Cloud Cluster, assumes that credentials are set in environment variables.
       * See JavaDoc on class level for details
       */
        clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(envVarAddress);
    } else {
        // connect to local deployment; assumes that authentication is disabled
        clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(defaultAddress).usePlaintext();
    }
    final String bpmnProcessId = "demoProcessSingleTask";
    try (final ZeebeClient client = clientBuilder.build()) {
        // open job workers so that task are executed and process is completed
        openJobWorker(client);
        System.out.println("Creating process instance");
        final ProcessInstanceResult processInstanceResult = client.newCreateInstanceCommand().bpmnProcessId(bpmnProcessId).latestVersion().withResult().send().join();
        System.out.println("Process instance created with key: " + processInstanceResult.getProcessInstanceKey() + " and completed with results: " + processInstanceResult.getVariables());
    }
}
Also used : ProcessInstanceResult(io.camunda.zeebe.client.api.response.ProcessInstanceResult) ZeebeClient(io.camunda.zeebe.client.ZeebeClient) ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder)

Aggregations

ZeebeClient (io.camunda.zeebe.client.ZeebeClient)90 ZeebeClientBuilder (io.camunda.zeebe.client.ZeebeClientBuilder)27 Test (org.junit.jupiter.api.Test)23 Topology (io.camunda.zeebe.client.api.response.Topology)16 ProcessInstanceEvent (io.camunda.zeebe.client.api.response.ProcessInstanceEvent)13 JobWorker (io.camunda.zeebe.client.api.worker.JobWorker)13 BpmnModelInstance (io.camunda.zeebe.model.bpmn.BpmnModelInstance)13 Test (org.junit.Test)12 Timeout (org.junit.jupiter.api.Timeout)11 Duration (java.time.Duration)10 DeploymentEvent (io.camunda.zeebe.client.api.response.DeploymentEvent)9 Bpmn (io.camunda.zeebe.model.bpmn.Bpmn)9 Awaitility (org.awaitility.Awaitility)8 Map (java.util.Map)7 BrokerInfo (io.camunda.zeebe.client.api.response.BrokerInfo)6 HashMap (java.util.HashMap)6 List (java.util.List)6 Optional (java.util.Optional)6 ArrayBlockingQueue (java.util.concurrent.ArrayBlockingQueue)6 Future (java.util.concurrent.Future)6