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());
}
}
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();
}
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();
}
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();
}
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();
}
Aggregations