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