Search in sources :

Example 1 with TopicsClient

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");
    }
}
Also used : TopicsClient(io.zeebe.client.TopicsClient) List(java.util.List) ClientRule(io.zeebe.broker.it.ClientRule) TopicsClient(io.zeebe.client.TopicsClient) ExternalResource(org.junit.rules.ExternalResource) Predicate(java.util.function.Predicate) Collectors(java.util.stream.Collectors) io.zeebe.client.event(io.zeebe.client.event) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList)

Example 2 with TopicsClient

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);
}
Also used : TopicsClient(io.zeebe.client.TopicsClient) Topics(io.zeebe.client.topic.Topics) List(java.util.List) Test(org.junit.Test)

Example 3 with TopicsClient

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");
}
Also used : TopicsClient(io.zeebe.client.TopicsClient) TaskEvent(io.zeebe.client.event.TaskEvent) Event(io.zeebe.client.event.Event) Test(org.junit.Test)

Aggregations

TopicsClient (io.zeebe.client.TopicsClient)3 List (java.util.List)2 Test (org.junit.Test)2 ClientRule (io.zeebe.broker.it.ClientRule)1 io.zeebe.client.event (io.zeebe.client.event)1 Event (io.zeebe.client.event.Event)1 TaskEvent (io.zeebe.client.event.TaskEvent)1 Topics (io.zeebe.client.topic.Topics)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 Predicate (java.util.function.Predicate)1 Collectors (java.util.stream.Collectors)1 ExternalResource (org.junit.rules.ExternalResource)1