use of io.zeebe.client.event.DeploymentEvent 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.");
}
use of io.zeebe.client.event.DeploymentEvent in project zeebe by zeebe-io.
the class CreateDeploymentTest method shouldCreateDeployment.
@Test
public void shouldCreateDeployment() {
// given
final List<Map<String, Object>> deployedWorkflows = new ArrayList<>();
Map<String, Object> deployedWorkflow = new HashMap<>();
deployedWorkflow.put("bpmnProcessId", "foo");
deployedWorkflow.put("version", 1);
deployedWorkflows.add(deployedWorkflow);
deployedWorkflow = new HashMap<>();
deployedWorkflow.put("bpmnProcessId", "bar");
deployedWorkflow.put("version", 2);
deployedWorkflows.add(deployedWorkflow);
brokerRule.onExecuteCommandRequest(r -> r.eventType() == DEPLOYMENT_EVENT).respondWith().key(2L).event().put("state", "CREATED").put("deployedWorkflows", deployedWorkflows).done().register();
// when
final DeploymentEvent deployment = clientRule.workflows().deploy(clientRule.getDefaultTopicName()).addWorkflowModel(WORKFLOW_MODEL, "model.bpmn").execute();
// then
assertThat(brokerRule.getReceivedCommandRequests()).hasSize(1);
final ExecuteCommandRequest commandRequest = brokerRule.getReceivedCommandRequests().get(0);
assertThat(commandRequest.key()).isEqualTo(-1);
assertThat(commandRequest.getCommand()).containsEntry("state", "CREATE");
assertThat(deployment.getMetadata().getKey()).isEqualTo(2L);
assertThat(deployment.getDeployedWorkflows()).hasSize(2);
assertThat(deployment.getDeployedWorkflows()).extracting("bpmnProcessId").contains("foo", "bar");
assertThat(deployment.getDeployedWorkflows()).extracting("version").contains(1, 2);
}
use of io.zeebe.client.event.DeploymentEvent in project zeebe by zeebe-io.
the class CreateDeploymentTest method shouldSendDeploymentRequestToSystemTopic.
@Test
public void shouldSendDeploymentRequestToSystemTopic() {
// given
brokerRule.onExecuteCommandRequest(Protocol.SYSTEM_PARTITION, DEPLOYMENT_EVENT, "CREATE").respondWith().key(2L).event().put("state", "CREATED").done().register();
// when
final DeploymentEvent deployment = clientRule.workflows().deploy("test-topic").addWorkflowModel(WORKFLOW_MODEL, "model.bpmn").execute();
// then
assertThat(brokerRule.getReceivedCommandRequests()).hasSize(1);
final ExecuteCommandRequest commandRequest = brokerRule.getReceivedCommandRequests().get(0);
assertThat(commandRequest.partitionId()).isEqualTo(Protocol.SYSTEM_PARTITION);
assertThat(commandRequest.getCommand()).containsEntry("topicName", "test-topic");
assertThat(deployment.getMetadata().getTopicName()).isEqualTo(Protocol.SYSTEM_TOPIC);
}
use of io.zeebe.client.event.DeploymentEvent in project zeebe by zeebe-io.
the class DeploymentClusteredTest method shouldDeployOnRemainingBrokers.
@Test
public void shouldDeployOnRemainingBrokers() {
// given
clusteringRule.createTopic("test", PARTITION_COUNT);
// when
clusteringRule.stopBroker(ClusteringRule.BROKER_3_CLIENT_ADDRESS);
// then
final DeploymentEvent deploymentEvent = client.workflows().deploy("test").addWorkflowModel(WORKFLOW, "workflow.bpmn").execute();
assertThat(deploymentEvent.getDeployedWorkflows().size()).isEqualTo(1);
assertThat(deploymentEvent.getErrorMessage()).isEmpty();
}
use of io.zeebe.client.event.DeploymentEvent in project zeebe by zeebe-io.
the class DeploymentClusteredTest method shouldDeployOnTopicWithManyPartitions.
@Test
@Ignore("https://github.com/zeebe-io/zeebe/issues/644")
public void shouldDeployOnTopicWithManyPartitions() {
// given
clusteringRule.createTopic("test", 15);
// when
final DeploymentEvent deploymentEvent = client.workflows().deploy("test").addWorkflowModel(WORKFLOW, "workflow.bpmn").execute();
// then
assertThat(deploymentEvent.getDeployedWorkflows().size()).isEqualTo(1);
assertThat(deploymentEvent.getErrorMessage()).isEmpty();
}
Aggregations