use of io.camunda.zeebe.client.ZeebeClient in project zeebe-test-container by camunda-community-hub.
the class ZeebeClusterTest method shouldStartSingleNodeCluster.
@Test
void shouldStartSingleNodeCluster() {
// given
cluster = ZeebeCluster.builder().withEmbeddedGateway(true).withReplicationFactor(1).withPartitionsCount(1).withBrokersCount(1).build();
// when
cluster.start();
// then
final ZeebeClient client = cluster.newClientBuilder().build();
final Topology topology = client.newTopologyRequest().send().join();
assertThat(topology.getPartitionsCount()).as("there is exactly one partition as configured").isEqualTo(1);
assertThat(topology.getReplicationFactor()).as("there is a replication factor of 1 as configured").isEqualTo(1);
TopologyAssert.assertThat(topology).as("the topology is complete for a one broker, one partition cluster").hasBrokersCount(1).isComplete(1, 1, 1);
}
use of io.camunda.zeebe.client.ZeebeClient in project zeebe-test-container by camunda-community-hub.
the class ZeebeClusterTest method shouldStartClusterWithStandaloneGateway.
@Test
void shouldStartClusterWithStandaloneGateway() {
// given
cluster = ZeebeCluster.builder().withEmbeddedGateway(false).withReplicationFactor(1).withPartitionsCount(1).withBrokersCount(1).withGatewaysCount(1).build();
// when
cluster.start();
// then
try (final ZeebeClient client = cluster.newClientBuilder().build()) {
final Topology topology = client.newTopologyRequest().send().join();
assertThat(topology.getPartitionsCount()).as("there is exactly one partition as configured").isEqualTo(1);
assertThat(topology.getReplicationFactor()).as("there is a replication factor of 1 as configured").isEqualTo(1);
TopologyAssert.assertThat(topology).as("the topology is complete for a one broker, one partition cluster").hasBrokersCount(1).isComplete(1, 1, 1);
}
}
use of io.camunda.zeebe.client.ZeebeClient in project zeebe-test-container by camunda-community-hub.
the class SingleNodeTest method shouldConnectToZeebe.
@Test
@Timeout(value = 5, unit = TimeUnit.MINUTES)
void shouldConnectToZeebe() {
// given
final BpmnModelInstance process = Bpmn.createExecutableProcess("process").startEvent().serviceTask().zeebeJobType("task").endEvent().done();
final Map<String, Integer> variables = Maps.newHashMap("foo", 1);
final DeploymentEvent deploymentEvent;
final ProcessInstanceResult workflowInstanceResult;
// when
try (final ZeebeClient client = newZeebeClient(zeebeContainer)) {
try (final JobWorker ignored = createJobWorker(variables, client)) {
deploymentEvent = client.newDeployCommand().addProcessModel(process, "process.bpmn").send().join();
workflowInstanceResult = client.newCreateInstanceCommand().bpmnProcessId("process").latestVersion().withResult().send().join();
}
}
// then
Assertions.assertThat(deploymentEvent.getProcesses()).as("the process instance was deployed").hasSize(1);
Assertions.assertThat(workflowInstanceResult.getBpmnProcessId()).as("a process instance for the deployed process was created and completed").isEqualTo("process");
}
use of io.camunda.zeebe.client.ZeebeClient in project zeebe-test-container by camunda-community-hub.
the class ZeebeGatewayContainerTest method shouldConnectToBroker.
@Test
void shouldConnectToBroker() {
// given
final Topology topology;
// when
try (final ZeebeClient client = ZeebeClientFactory.newZeebeClient(gatewayContainer)) {
topology = client.newTopologyRequest().send().join(5, TimeUnit.SECONDS);
}
// then
final List<BrokerInfo> brokers = topology.getBrokers();
Assertions.assertThat(brokers).as("the gateway should report one broker").hasSize(1);
Assertions.assertThat(brokers.get(0).getAddress()).as("the gateway should report the correct contact point").isEqualTo(brokerContainer.getInternalCommandAddress());
}
use of io.camunda.zeebe.client.ZeebeClient in project spring-zeebe by camunda-community-hub.
the class ZeebeWorkerPostProcessor method apply.
@Override
public Consumer<ZeebeClient> apply(final ClassInfo beanInfo) {
LOGGER.info("Registering Zeebe worker(s) of bean: {}", beanInfo.getBean());
final List<ZeebeWorkerValue> annotatedMethods = new ArrayList<>();
doWithMethods(beanInfo.getTargetClass(), method -> reader.apply(beanInfo.toMethodInfo(method)).ifPresent(annotatedMethods::add), ReflectionUtils.USER_DECLARED_METHODS);
return client -> annotatedMethods.forEach(zeebeWorkerValue -> {
final JobWorkerBuilderStep3 builder = client.newWorker().jobType(zeebeWorkerValue.getType()).handler(new JobHandlerInvokingSpringBeans(zeebeWorkerValue, commandExceptionHandlingStrategy));
// using defaults from config if null, 0 or negative
if (zeebeWorkerValue.getName() != null && zeebeWorkerValue.getName().length() > 0) {
builder.name(zeebeWorkerValue.getName());
} else {
builder.name(beanInfo.getBeanName() + "#" + zeebeWorkerValue.getMethodInfo().getMethodName());
}
if (zeebeWorkerValue.getMaxJobsActive() > 0) {
builder.maxJobsActive(zeebeWorkerValue.getMaxJobsActive());
}
if (zeebeWorkerValue.getTimeout() > 0) {
builder.timeout(zeebeWorkerValue.getTimeout());
}
if (zeebeWorkerValue.getPollInterval() > 0) {
builder.pollInterval(Duration.ofMillis(zeebeWorkerValue.getPollInterval()));
}
if (zeebeWorkerValue.getRequestTimeout() > 0) {
builder.requestTimeout(Duration.ofSeconds(zeebeWorkerValue.getRequestTimeout()));
}
if (zeebeWorkerValue.getFetchVariables().length > 0) {
builder.fetchVariables(zeebeWorkerValue.getFetchVariables());
}
builder.open();
LOGGER.info(". Register Zeebe worker: {}", zeebeWorkerValue);
});
}
Aggregations