Search in sources :

Example 21 with ZeebeClientBuilder

use of io.camunda.zeebe.client.ZeebeClientBuilder in project zeebe by zeebe-io.

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 22 with ZeebeClientBuilder

use of io.camunda.zeebe.client.ZeebeClientBuilder in project zeebe by zeebe-io.

the class Worker method createZeebeClient.

private ZeebeClient createZeebeClient() {
    final WorkerCfg workerCfg = appCfg.getWorker();
    final ZeebeClientBuilder builder = ZeebeClient.newClientBuilder().gatewayAddress(appCfg.getBrokerUrl()).numJobWorkerExecutionThreads(workerCfg.getThreads()).defaultJobWorkerName(workerCfg.getWorkerName()).defaultJobTimeout(workerCfg.getCompletionDelay().multipliedBy(6)).defaultJobWorkerMaxJobsActive(workerCfg.getCapacity()).defaultJobPollInterval(workerCfg.getPollingDelay()).withProperties(System.getProperties()).withInterceptors(monitoringInterceptor);
    if (!appCfg.isTls()) {
        builder.usePlaintext();
    }
    return builder.build();
}
Also used : WorkerCfg(io.camunda.zeebe.config.WorkerCfg) ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder)

Example 23 with ZeebeClientBuilder

use of io.camunda.zeebe.client.ZeebeClientBuilder in project zeebe by zeebe-io.

the class BrokerSnapshotTest method setup.

@Before
public void setup() {
    final RaftPartition raftPartition = (RaftPartition) brokerRule.getBroker().getBrokerContext().getPartitionManager().getPartitionGroup().getPartition(PartitionId.from(PartitionManagerImpl.GROUP_NAME, PARTITION_ID));
    journalReader = raftPartition.getServer().openReader();
    brokerAdminService = brokerRule.getBroker().getBrokerContext().getBrokerAdminService();
    final String contactPoint = NetUtil.toSocketAddressString(brokerRule.getGatewayAddress());
    final ZeebeClientBuilder zeebeClientBuilder = ZeebeClient.newClientBuilder().usePlaintext().gatewayAddress(contactPoint);
    client = zeebeClientBuilder.build();
}
Also used : RaftPartition(io.atomix.raft.partition.RaftPartition) ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder) Before(org.junit.Before)

Example 24 with ZeebeClientBuilder

use of io.camunda.zeebe.client.ZeebeClientBuilder in project zeebe by zeebe-io.

the class ResponsiveHealthIndicator method createZeebeClient.

static ZeebeClient createZeebeClient(final GatewayCfg gatewayCfg, final Duration defaultTimeout) {
    final String gatewayAddress = getContactPoint(gatewayCfg);
    ZeebeClientBuilder clientBuilder = ZeebeClient.newClientBuilder().gatewayAddress(gatewayAddress).defaultRequestTimeout(defaultTimeout);
    if (gatewayCfg.getSecurity().isEnabled()) {
        clientBuilder = clientBuilder.caCertificatePath(gatewayCfg.getSecurity().getCertificateChainPath().getAbsolutePath());
    } else {
        clientBuilder = clientBuilder.usePlaintext();
    }
    return clientBuilder.build();
}
Also used : ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder)

Example 25 with ZeebeClientBuilder

use of io.camunda.zeebe.client.ZeebeClientBuilder in project zeebe by camunda-cloud.

the class Worker method createZeebeClient.

private ZeebeClient createZeebeClient() {
    final WorkerCfg workerCfg = appCfg.getWorker();
    final ZeebeClientBuilder builder = ZeebeClient.newClientBuilder().gatewayAddress(appCfg.getBrokerUrl()).numJobWorkerExecutionThreads(workerCfg.getThreads()).defaultJobWorkerName(workerCfg.getWorkerName()).defaultJobTimeout(workerCfg.getCompletionDelay().multipliedBy(6)).defaultJobWorkerMaxJobsActive(workerCfg.getCapacity()).defaultJobPollInterval(workerCfg.getPollingDelay()).withProperties(System.getProperties()).withInterceptors(monitoringInterceptor);
    if (!appCfg.isTls()) {
        builder.usePlaintext();
    }
    return builder.build();
}
Also used : WorkerCfg(io.camunda.zeebe.config.WorkerCfg) ZeebeClientBuilder(io.camunda.zeebe.client.ZeebeClientBuilder)

Aggregations

ZeebeClientBuilder (io.camunda.zeebe.client.ZeebeClientBuilder)40 ZeebeClient (io.camunda.zeebe.client.ZeebeClient)24 ProcessInstanceEvent (io.camunda.zeebe.client.api.response.ProcessInstanceEvent)6 Topology (io.camunda.zeebe.client.api.response.Topology)6 RaftPartition (io.atomix.raft.partition.RaftPartition)3 DeploymentEvent (io.camunda.zeebe.client.api.response.DeploymentEvent)3 ProcessInstanceResult (io.camunda.zeebe.client.api.response.ProcessInstanceResult)3 JobWorker (io.camunda.zeebe.client.api.worker.JobWorker)3 WorkerCfg (io.camunda.zeebe.config.WorkerCfg)3 Before (org.junit.Before)3 Test (org.junit.jupiter.api.Test)3 GenericContainer (org.testcontainers.containers.GenericContainer)3