Search in sources :

Example 11 with ZeebeClientImpl

use of io.zeebe.client.impl.ZeebeClientImpl in project zeebe by zeebe-io.

the class TopicSubscriptionTest method shouldCloseSubscriptionWhenAckFails.

@Test
public void shouldCloseSubscriptionWhenAckFails() {
    // given
    final long subscriberKey = 123L;
    broker.stubTopicSubscriptionApi(subscriberKey);
    broker.onExecuteCommandRequest(EventType.SUBSCRIPTION_EVENT, "ACKNOWLEDGE").respondWithError().errorCode(ErrorCode.REQUEST_PROCESSING_FAILURE).errorData("foo").register();
    final TopicSubscription subscription = clientRule.topics().newSubscription(clientRule.getDefaultTopicName()).startAtHeadOfTopic().handler(DO_NOTHING).name(SUBSCRIPTION_NAME).open();
    final RemoteAddress clientAddress = receivedSubscribeCommands().findFirst().get().getSource();
    final int subscriptionCapacity = ((ZeebeClientImpl) client).getSubscriptionPrefetchCapacity();
    // when
    for (int i = 0; i < subscriptionCapacity; i++) {
        broker.pushTopicEvent(clientAddress, subscriberKey, i, i);
    }
    // then
    waitUntil(() -> subscription.isClosed());
    assertThat(subscription.isClosed()).isTrue();
}
Also used : RemoteAddress(io.zeebe.transport.RemoteAddress) ZeebeClientImpl(io.zeebe.client.impl.ZeebeClientImpl) Test(org.junit.Test)

Example 12 with ZeebeClientImpl

use of io.zeebe.client.impl.ZeebeClientImpl in project zeebe by zeebe-io.

the class ClientRule method before.

@Override
protected void before() throws Throwable {
    clock = new ControlledActorClock();
    client = new ZeebeClientImpl(properties, clock);
}
Also used : ControlledActorClock(io.zeebe.util.sched.clock.ControlledActorClock) ZeebeClientImpl(io.zeebe.client.impl.ZeebeClientImpl)

Aggregations

ZeebeClientImpl (io.zeebe.client.impl.ZeebeClientImpl)12 ZeebeClient (io.zeebe.client.ZeebeClient)7 Properties (java.util.Properties)7 ClientProperties (io.zeebe.client.ClientProperties)6 RemoteAddress (io.zeebe.transport.RemoteAddress)4 Duration (java.time.Duration)4 Test (org.junit.Test)4 ExecuteCommandRequest (io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest)3 Scanner (java.util.Scanner)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 TaskSubscription (io.zeebe.client.task.TaskSubscription)2 ClientRule (io.zeebe.client.util.ClientRule)2 ControlMessageType (io.zeebe.protocol.clientapi.ControlMessageType)2 ErrorCode (io.zeebe.protocol.clientapi.ErrorCode)2 EventType (io.zeebe.protocol.clientapi.EventType)2 ControlMessageRequest (io.zeebe.test.broker.protocol.brokerapi.ControlMessageRequest)2 ResponseController (io.zeebe.test.broker.protocol.brokerapi.ResponseController)2 StubBrokerRule (io.zeebe.test.broker.protocol.brokerapi.StubBrokerRule)2 TestUtil (io.zeebe.test.util.TestUtil)2 TestUtil.waitUntil (io.zeebe.test.util.TestUtil.waitUntil)2