use of io.zeebe.client.ClientProperties in project zeebe by zeebe-io.
the class TopologyViewer method main.
public static void main(final String[] args) {
final String[] brokers = new String[] { "localhost:51015", "localhost:41015", "localhost:31015" };
for (final String broker : brokers) {
final Properties clientProperties = new Properties();
clientProperties.put(ClientProperties.BROKER_CONTACTPOINT, broker);
try (ZeebeClient zeebeClient = ZeebeClient.create(clientProperties)) {
final TopologyResponse topology = zeebeClient.requestTopology().execute();
System.out.println("Requesting topology with initial contact point " + broker);
System.out.println(" Topology:");
topology.getBrokers().forEach(b -> {
System.out.println(" " + b.getSocketAddress());
b.getPartitions().forEach(p -> System.out.println(" " + p.getTopicName() + "." + p.getPartitionId() + " - " + p.getState()));
});
} catch (final Exception e) {
System.out.println("Broker " + broker + " not available");
}
}
}
use of io.zeebe.client.ClientProperties in project zeebe by zeebe-io.
the class WorkflowInstanceStarter method main.
public static void main(String[] args) {
final String brokerContactPoint = "127.0.0.1:51015";
final String bpmnProcessId = "demoProcess";
final String topicName = "default-topic";
final int partitionId = 0;
final Properties clientProperties = new Properties();
clientProperties.put(ClientProperties.BROKER_CONTACTPOINT, brokerContactPoint);
final ZeebeClient zeebeClient = new ZeebeClientImpl(clientProperties);
System.out.println(String.format("> Connecting to %s", brokerContactPoint));
System.out.println(String.format("> Deploying workflow to topic '%s' and partition '%d'", topicName, partitionId));
final DeploymentEvent deploymentResult = zeebeClient.workflows().deploy(topicName).addResourceFromClasspath("demoProcess.bpmn").execute();
try {
final String deployedWorkflows = deploymentResult.getDeployedWorkflows().stream().map(wf -> String.format("<%s:%d>", wf.getBpmnProcessId(), wf.getVersion())).collect(Collectors.joining(","));
System.out.println(String.format("> Deployed: %s", deployedWorkflows));
System.out.println(String.format("> Create workflow instance for workflow: %s", bpmnProcessId));
zeebeClient.workflows().create(topicName).bpmnProcessId(bpmnProcessId).payload("{\"a\": \"b\"}").execute();
System.out.println("> Created.");
} catch (ClientCommandRejectedException exception) {
System.out.println(String.format("> Fail to deploy: %s", exception.getMessage()));
}
System.out.println("> Closing...");
zeebeClient.close();
System.out.println("> Closed.");
}
Aggregations