use of io.zeebe.client.TopicsClient in project zeebe by zeebe-io.
the class TopicEventRecorder method startRecordingEvents.
public void startRecordingEvents() {
if (subscription == null) {
final TopicsClient client = clientRule.getClient().topics();
subscription = client.newSubscription(topicName).name(SUBSCRIPTION_NAME).taskEventHandler(e -> taskEvents.add(e)).workflowEventHandler(e -> wfEvents.add(e)).workflowInstanceEventHandler(e -> wfInstanceEvents.add(e)).incidentEventHandler(e -> incidentEvents.add(e)).open();
} else {
throw new RuntimeException("Subscription already open");
}
}
use of io.zeebe.client.TopicsClient in project zeebe by zeebe-io.
the class CreateTopicTest method shouldRequestTopics.
@Test
public void shouldRequestTopics() {
// given
final TopicsClient topics = clientRule.topics();
topics.create("foo", 2).execute();
// when
final Topics returnedTopics = clientRule.topics().getTopics().execute();
// then
assertThat(returnedTopics.getTopics()).hasSize(2);
final Map<String, List<Partition>> topicsByName = returnedTopics.getTopics().stream().collect(Collectors.toMap(Topic::getName, Topic::getPartitions));
assertThat(topicsByName.get("foo")).hasSize(2);
assertThat(topicsByName.get(ClientRule.DEFAULT_TOPIC)).hasSize(1);
}
use of io.zeebe.client.TopicsClient in project zeebe by zeebe-io.
the class CreateTopicTest method shouldCreateMultipleTopicsInParallel.
@Test
public void shouldCreateMultipleTopicsInParallel() throws Exception {
// given
final TopicsClient topics = clientRule.topics();
// when
final Future<Event> foo = topics.create("foo", 2).executeAsync();
final Future<Event> bar = topics.create("bar", 2).executeAsync();
// then
assertThat(bar.get(10, TimeUnit.SECONDS).getState()).isEqualTo("CREATED");
assertThat(foo.get(10, TimeUnit.SECONDS).getState()).isEqualTo("CREATED");
}
Aggregations