gpt4 book ai didi

io.zeebe.client.ZeebeClient类的使用及代码示例

转载 作者:知者 更新时间:2024-03-18 00:57:31 26 4
gpt4 key购买 nike

本文整理了Java中io.zeebe.client.ZeebeClient类的一些代码示例,展示了ZeebeClient类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ZeebeClient类的具体详情如下:
包路径:io.zeebe.client.ZeebeClient
类名称:ZeebeClient

ZeebeClient介绍

[英]The client to communicate with a Zeebe broker/cluster.
[中]客户端与Zeebe代理/集群通信。

代码示例

代码示例来源:origin: zeebe-io/zeebe

/**
 * @return a new Zeebe client with default configuration values. In order to customize
 *     configuration, use the methods {@link #newClientBuilder()} or {@link
 *     #newClient(ZeebeClientConfiguration)}. See {@link ZeebeClientBuilder} for the configuration
 *     options and default values.
 */
static ZeebeClient newClient() {
 return newClientBuilder().build();
}

代码示例来源:origin: zeebe-io/zeebe

public void destroyClient() {
  client.close();
  client = null;
 }
}

代码示例来源:origin: zeebe-io/zeebe

public static void main(final String[] args) {
 final String broker = "127.0.0.1:26500";
 final ZeebeClientBuilder builder = ZeebeClient.newClientBuilder().brokerContactPoint(broker);
 try (ZeebeClient client = builder.build()) {
  final Order order = new Order();
  order.setOrderId(31243);
  client
    .newCreateInstanceCommand()
    .bpmnProcessId("demoProcess")
    .latestVersion()
    .payload(order)
    .send()
    .join();
  client.newWorker().jobType("foo").handler(new DemoJobHandler()).open();
  // run until System.in receives exit command
  waitUntilSystemInput("exit");
 }
}

代码示例来源:origin: zeebe-io/zeebe

public static void main(final String[] args) {
  final String broker = "localhost:26500";

  final ZeebeClientBuilder clientBuilder =
    ZeebeClient.newClientBuilder().brokerContactPoint(broker);

  try (ZeebeClient client = clientBuilder.build()) {

   final DeploymentEvent deploymentEvent =
     client.newDeployCommand().addResourceFromClasspath("demoProcess.bpmn").send().join();

   System.out.println("Deployment created with key: " + deploymentEvent.getKey());
  }
 }
}

代码示例来源:origin: zeebe-io/zeebe

public static void main(final String[] args) {

  final String broker = "localhost:26500";

  final ZeebeClientBuilder clientBuilder =
    ZeebeClient.newClientBuilder().brokerContactPoint(broker);

  try (ZeebeClient client = clientBuilder.build()) {

   final Workflows workflows = client.newWorkflowRequest().send().join();

   System.out.println("Printing all deployed workflows:");

   workflows
     .getWorkflows()
     .forEach(
       wf -> {
        System.out.println("Workflow resource for " + wf + ":");

        final WorkflowResource resource =
          client.newResourceRequest().workflowKey(wf.getWorkflowKey()).send().join();

        System.out.println(resource);
       });

   System.out.println("Done");
  }
 }
}

代码示例来源:origin: zeebe-io/zeebe

public static void main(final String[] args) {
  final String broker = "127.0.0.1:26500";

  final ZeebeClientBuilder builder = ZeebeClient.newClientBuilder().brokerContactPoint(broker);

  try (ZeebeClient client = builder.build()) {
   System.out.println("Requesting topology with initial contact point " + broker);

   final Topology topology = client.newTopologyRequest().send().join();

   System.out.println("Topology:");
   topology
     .getBrokers()
     .forEach(
       b -> {
        System.out.println("    " + b.getAddress());
        b.getPartitions()
          .forEach(
            p ->
              System.out.println(
                "      " + p.getPartitionId() + " - " + p.getRole()));
       });

   System.out.println("Done.");
  }
 }
}

代码示例来源:origin: zeebe-io/zeebe

public static void main(final String[] args) {
  final String broker = "127.0.0.1:26500";

  final String bpmnProcessId = "demoProcess";

  final ZeebeClientBuilder builder = ZeebeClient.newClientBuilder().brokerContactPoint(broker);

  try (ZeebeClient client = builder.build()) {

   System.out.println("Creating workflow instance");

   final WorkflowInstanceEvent workflowInstanceEvent =
     client
       .newCreateInstanceCommand()
       .bpmnProcessId(bpmnProcessId)
       .latestVersion()
       .send()
       .join();

   System.out.println(
     "Workflow instance created with key: " + workflowInstanceEvent.getWorkflowInstanceKey());
  }
 }
}

代码示例来源:origin: zeebe-io/zeebe

public static void main(final String[] args) {
 final String broker = "127.0.0.1:26500";
 final String jobType = "foo";
 final ZeebeClientBuilder builder = ZeebeClient.newClientBuilder().brokerContactPoint(broker);
 try (ZeebeClient client = builder.build()) {
  System.out.println("Opening job worker.");
  final JobWorker workerRegistration =
    client
      .newWorker()
      .jobType(jobType)
      .handler(new ExampleJobHandler())
      .timeout(Duration.ofSeconds(10))
      .open();
  System.out.println("Job worker opened and receiving jobs.");
  // call workerRegistration.close() to close it
  // run until System.in receives exit command
  waitUntilSystemInput("exit");
 }
}

代码示例来源:origin: berndruecker/flowing-retail

@Bean
public ZeebeClient zeebe() {
 System.out.println("Connect to Zeebe at '" + zeebeBrokerContactPoint + "'");
 
 // Cannot yet use Spring Zeebe in current alpha
 ZeebeClient zeebeClient = ZeebeClient.newClientBuilder() //
   .brokerContactPoint(zeebeBrokerContactPoint) //
   .build();
 
 // Trigger deployment
 zeebeClient.workflowClient().newDeployCommand() //
  .addResourceFromClasspath("order-kafka.bpmn") //
  .send().join();
 
 return zeebeClient;
}

代码示例来源:origin: zeebe-io/zeebe

/**
 * Creates a new job worker that will handle jobs of type {@param type}.
 *
 * <p>Make sure to close the returned job worker.
 *
 * @param type type of the jobs to handle
 * @param handler handler
 * @return a new JobWorker
 */
public JobWorker createJobWorker(String type, JobHandler handler) {
 return clientRule.getClient().newWorker().jobType(type).handler(handler).open();
}

代码示例来源:origin: zeebe-io/zeebe

/**
 * Deploys the given workflow to the broker. Note that the filename must have the "bpmn" file
 * extension, e.g. "resource.bpmn".
 *
 * @param workflow workflow to deploy
 * @param filename resource name, e.g. "workflow.bpmn"
 */
public void deployWorkflow(BpmnModelInstance workflow, String filename) {
 clientRule.getClient().newDeployCommand().addWorkflowModel(workflow, filename).send().join();
}

代码示例来源:origin: zeebe-io/zeebe

private void determineDefaultPartition() {
 final Topology topology = client.newTopologyRequest().send().join();
 defaultPartition = -1;
 final List<BrokerInfo> topologyBrokers = topology.getBrokers();
 for (final BrokerInfo leader : topologyBrokers) {
  final List<PartitionInfo> partitions = leader.getPartitions();
  for (final PartitionInfo brokerPartitionState : partitions) {
   if (brokerPartitionState.isLeader()) {
    defaultPartition = brokerPartitionState.getPartitionId();
    break;
   }
  }
 }
 if (defaultPartition < 0) {
  throw new RuntimeException("Could not detect leader for default partition");
 }
}

代码示例来源:origin: zeebe-io/zeebe

/**
 * Creates a workflow instance for the given process ID, with the given payload.
 *
 * @param processId BPMN process ID
 * @param payload initial payload for the instance
 * @return unique ID used to interact with the instance
 */
public long createWorkflowInstance(String processId, Map<String, Object> payload) {
 return clientRule
   .getClient()
   .newCreateInstanceCommand()
   .bpmnProcessId(processId)
   .latestVersion()
   .payload(payload)
   .send()
   .join()
   .getWorkflowInstanceKey();
}

代码示例来源:origin: berndruecker/flowing-retail

@PostConstruct
public void subscribe() {
 subscription = zeebe.jobClient().newWorker()
  .jobType("fetch-goods")
  .handler(this)
  .timeout(Duration.ofMinutes(1))
  .open();      
}

代码示例来源:origin: io.zeebe/zeebe-test

/**
 * Creates a new job worker that will handle jobs of type {@param type}.
 *
 * <p>Make sure to close the returned job worker.
 *
 * @param type type of the jobs to handle
 * @param handler handler
 * @return a new JobWorker
 */
public JobWorker createJobWorker(String type, JobHandler handler) {
 return clientRule.getClient().newWorker().jobType(type).handler(handler).open();
}

代码示例来源:origin: io.zeebe/zeebe-test

/**
 * Deploys the given workflow to the broker. Note that the filename must have the "bpmn" file
 * extension, e.g. "resource.bpmn".
 *
 * @param workflow workflow to deploy
 * @param filename resource name, e.g. "workflow.bpmn"
 */
public void deployWorkflow(BpmnModelInstance workflow, String filename) {
 clientRule.getClient().newDeployCommand().addWorkflowModel(workflow, filename).send().join();
}

代码示例来源:origin: io.zeebe/zeebe-test

private void determineDefaultPartition() {
 final Topology topology = client.newTopologyRequest().send().join();
 defaultPartition = -1;
 final List<BrokerInfo> topologyBrokers = topology.getBrokers();
 for (final BrokerInfo leader : topologyBrokers) {
  final List<PartitionInfo> partitions = leader.getPartitions();
  for (final PartitionInfo brokerPartitionState : partitions) {
   if (brokerPartitionState.isLeader()) {
    defaultPartition = brokerPartitionState.getPartitionId();
    break;
   }
  }
 }
 if (defaultPartition < 0) {
  throw new RuntimeException("Could not detect leader for default partition");
 }
}

代码示例来源:origin: io.zeebe/zeebe-test

/**
 * Creates a workflow instance for the given process ID, with the given payload.
 *
 * @param processId BPMN process ID
 * @param payload initial payload for the instance
 * @return unique ID used to interact with the instance
 */
public long createWorkflowInstance(String processId, Map<String, Object> payload) {
 return clientRule
   .getClient()
   .newCreateInstanceCommand()
   .bpmnProcessId(processId)
   .latestVersion()
   .payload(payload)
   .send()
   .join()
   .getWorkflowInstanceKey();
}

代码示例来源:origin: berndruecker/flowing-retail

@PostConstruct
public void subscribe() {
 subscription = zeebe.jobClient().newWorker()
  .jobType("ship-goods")
  .handler(this)
  .timeout(Duration.ofMinutes(1))
  .open();      
}

代码示例来源:origin: io.zeebe/zeebe-client-java

/**
 * @return a new Zeebe client with default configuration values. In order to customize
 *     configuration, use the methods {@link #newClientBuilder()} or {@link
 *     #newClient(ZeebeClientConfiguration)}. See {@link ZeebeClientBuilder} for the configuration
 *     options and default values.
 */
static ZeebeClient newClient() {
 return newClientBuilder().build();
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com