use of io.zeebe.client.task.impl.subscription.SubscriberGroup in project zeebe by zeebe-io.
the class PartitionedTopicSubscriptionTest method shouldSumWorkCountOfPollableSubscription.
@Test
public void shouldSumWorkCountOfPollableSubscription() {
// given
final int subscriberKey1 = 456;
broker1.stubTopicSubscriptionApi(subscriberKey1);
final int subscriberKey2 = 789;
broker2.stubTopicSubscriptionApi(subscriberKey2);
final RecordingEventHandler eventHandler = new RecordingEventHandler();
final PollableTopicSubscription subscription = client.topics().newPollableSubscription(TOPIC).name("hohoho").open();
final RemoteAddress clientAddressFromBroker1 = broker1.getReceivedCommandRequests().get(0).getSource();
final RemoteAddress clientAddressFromBroker2 = broker2.getReceivedCommandRequests().get(0).getSource();
broker1.pushTopicEvent(clientAddressFromBroker1, b -> b.partitionId(PARTITION_1).subscriberKey(subscriberKey1).key(3));
broker2.pushTopicEvent(clientAddressFromBroker2, b -> b.partitionId(PARTITION_2).subscriberKey(subscriberKey2).key(4));
waitUntil(() -> ((SubscriberGroup<?>) subscription).size() == 2);
// when
final int polledEvents = subscription.poll(eventHandler);
// then
assertThat(polledEvents).isEqualTo(2);
}
use of io.zeebe.client.task.impl.subscription.SubscriberGroup in project zeebe by zeebe-io.
the class PartitionedTaskSubscriptionTest method shouldSumWorkCountOfPollableSubscription.
@Test
public void shouldSumWorkCountOfPollableSubscription() {
// given
final int subscriberKey1 = 456;
broker1.stubTaskSubscriptionApi(subscriberKey1);
final int subscriberKey2 = 789;
broker2.stubTaskSubscriptionApi(subscriberKey2);
final RecordingTaskHandler eventHandler = new RecordingTaskHandler();
final PollableTaskSubscription subscription = client.tasks().newPollableTaskSubscription(TOPIC).taskType(TASK_TYPE).lockOwner("bumbum").lockTime(Duration.ofSeconds(6)).open();
final RemoteAddress clientAddressFromBroker1 = broker1.getReceivedControlMessageRequests().get(0).getSource();
final RemoteAddress clientAddressFromBroker2 = broker2.getReceivedControlMessageRequests().get(0).getSource();
final long key1 = 3;
broker1.newSubscribedEvent().eventType(EventType.TASK_EVENT).partitionId(PARTITION_1).subscriberKey(subscriberKey1).key(key1).subscriptionType(SubscriptionType.TASK_SUBSCRIPTION).event().done().push(clientAddressFromBroker1);
final long key2 = 4;
broker2.newSubscribedEvent().eventType(EventType.TASK_EVENT).partitionId(PARTITION_1).subscriberKey(subscriberKey1).key(key2).subscriptionType(SubscriptionType.TASK_SUBSCRIPTION).event().done().push(clientAddressFromBroker2);
waitUntil(() -> ((SubscriberGroup<?>) subscription).size() == 2);
// when
final int polledEvents = subscription.poll(eventHandler);
// then
assertThat(polledEvents).isEqualTo(2);
}
Aggregations