Search in sources :

Example 6 with ClientProperties

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");
        }
    }
}
Also used : ZeebeClient(io.zeebe.client.ZeebeClient) TopologyResponse(io.zeebe.client.clustering.impl.TopologyResponse) Properties(java.util.Properties) ClientProperties(io.zeebe.client.ClientProperties)

Example 7 with ClientProperties

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.");
}
Also used : Properties(java.util.Properties) ClientProperties(io.zeebe.client.ClientProperties) ClientCommandRejectedException(io.zeebe.client.cmd.ClientCommandRejectedException) DeploymentEvent(io.zeebe.client.event.DeploymentEvent) Collectors(java.util.stream.Collectors) ZeebeClientImpl(io.zeebe.client.impl.ZeebeClientImpl) ZeebeClient(io.zeebe.client.ZeebeClient) ZeebeClient(io.zeebe.client.ZeebeClient) ClientCommandRejectedException(io.zeebe.client.cmd.ClientCommandRejectedException) Properties(java.util.Properties) ClientProperties(io.zeebe.client.ClientProperties) ZeebeClientImpl(io.zeebe.client.impl.ZeebeClientImpl) DeploymentEvent(io.zeebe.client.event.DeploymentEvent)

Aggregations

ClientProperties (io.zeebe.client.ClientProperties)7 ZeebeClient (io.zeebe.client.ZeebeClient)7 Properties (java.util.Properties)7 ZeebeClientImpl (io.zeebe.client.impl.ZeebeClientImpl)5 Scanner (java.util.Scanner)3 TaskSubscription (io.zeebe.client.task.TaskSubscription)2 Duration (java.time.Duration)2 JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 TasksClient (io.zeebe.client.TasksClient)1 TopologyResponse (io.zeebe.client.clustering.impl.TopologyResponse)1 ClientCommandRejectedException (io.zeebe.client.cmd.ClientCommandRejectedException)1 io.zeebe.client.event (io.zeebe.client.event)1 DeploymentEvent (io.zeebe.client.event.DeploymentEvent)1 EventMetadata (io.zeebe.client.event.EventMetadata)1 TaskEvent (io.zeebe.client.event.TaskEvent)1 TopicSubscription (io.zeebe.client.event.TopicSubscription)1 TasksClientImpl (io.zeebe.client.impl.TasksClientImpl)1 MsgPackConverter (io.zeebe.client.impl.data.MsgPackConverter)1