Search in sources :

Example 1 with Subscriber

use of io.zeebe.client.task.impl.subscription.Subscriber in project zeebe by zeebe-io.

the class TaskSubscriptionTest method shouldCloseSubscriptionOnChannelClose.

@Test
public void shouldCloseSubscriptionOnChannelClose() throws InterruptedException {
    // given
    broker.stubTaskSubscriptionApi(123L);
    final TaskSubscription subscription = clientRule.tasks().newTaskSubscription(clientRule.getDefaultTopicName()).handler((c, t) -> c.complete(t).withoutPayload().execute()).lockOwner("owner").lockTime(1000L).taskFetchSize(5).taskType("foo").open();
    // when
    broker.closeTransport();
    // let subscriber attempt reopening
    Thread.sleep(500L);
    // make request time out immediately
    clientRule.getClock().addTime(Duration.ofSeconds(60));
    // then
    TestUtil.waitUntil(() -> subscription.isClosed());
    assertThat(subscription.isClosed()).isTrue();
}
Also used : TasksClient(io.zeebe.client.TasksClient) TaskEvent(io.zeebe.client.event.TaskEvent) PollableTaskSubscription(io.zeebe.client.task.PollableTaskSubscription) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) ControlMessageType(io.zeebe.protocol.clientapi.ControlMessageType) HashMap(java.util.HashMap) ZeebeClientImpl(io.zeebe.client.impl.ZeebeClientImpl) ControlMessageRequest(io.zeebe.test.broker.protocol.brokerapi.ControlMessageRequest) ZeebeClient(io.zeebe.client.ZeebeClient) StubBrokerRule(io.zeebe.test.broker.protocol.brokerapi.StubBrokerRule) ErrorCode(io.zeebe.protocol.clientapi.ErrorCode) RemoteAddress(io.zeebe.transport.RemoteAddress) ClientRule(io.zeebe.client.util.ClientRule) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Duration(java.time.Duration) Map(java.util.Map) After(org.junit.After) ExpectedException(org.junit.rules.ExpectedException) JsonParseException(com.fasterxml.jackson.core.JsonParseException) MsgPackConverter(io.zeebe.client.impl.data.MsgPackConverter) Before(org.junit.Before) MsgPackHelper(io.zeebe.test.broker.protocol.MsgPackHelper) TestUtil.waitUntil(io.zeebe.test.util.TestUtil.waitUntil) Properties(java.util.Properties) Predicate(java.util.function.Predicate) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) IOException(java.io.IOException) Test(org.junit.Test) TaskSubscription(io.zeebe.client.task.TaskSubscription) Instant(java.time.Instant) Assertions.entry(org.assertj.core.api.Assertions.entry) Collectors(java.util.stream.Collectors) TasksClientImpl(io.zeebe.client.impl.TasksClientImpl) SubscriptionType(io.zeebe.protocol.clientapi.SubscriptionType) TimeUnit(java.util.concurrent.TimeUnit) RuleChain(org.junit.rules.RuleChain) List(java.util.List) Stream(java.util.stream.Stream) Rule(org.junit.Rule) EventType(io.zeebe.protocol.clientapi.EventType) ClientProperties(io.zeebe.client.ClientProperties) TaskHandler(io.zeebe.client.task.TaskHandler) ExecuteCommandRequest(io.zeebe.test.broker.protocol.brokerapi.ExecuteCommandRequest) JsonMappingException(com.fasterxml.jackson.databind.JsonMappingException) Subscriber(io.zeebe.client.task.impl.subscription.Subscriber) TestUtil(io.zeebe.test.util.TestUtil) PollableTaskSubscription(io.zeebe.client.task.PollableTaskSubscription) TaskSubscription(io.zeebe.client.task.TaskSubscription) Test(org.junit.Test)

Aggregations

JsonParseException (com.fasterxml.jackson.core.JsonParseException)1 JsonMappingException (com.fasterxml.jackson.databind.JsonMappingException)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ClientProperties (io.zeebe.client.ClientProperties)1 TasksClient (io.zeebe.client.TasksClient)1 ZeebeClient (io.zeebe.client.ZeebeClient)1 TaskEvent (io.zeebe.client.event.TaskEvent)1 TasksClientImpl (io.zeebe.client.impl.TasksClientImpl)1 ZeebeClientImpl (io.zeebe.client.impl.ZeebeClientImpl)1 MsgPackConverter (io.zeebe.client.impl.data.MsgPackConverter)1 PollableTaskSubscription (io.zeebe.client.task.PollableTaskSubscription)1 TaskHandler (io.zeebe.client.task.TaskHandler)1 TaskSubscription (io.zeebe.client.task.TaskSubscription)1 Subscriber (io.zeebe.client.task.impl.subscription.Subscriber)1 ClientRule (io.zeebe.client.util.ClientRule)1 ControlMessageType (io.zeebe.protocol.clientapi.ControlMessageType)1 ErrorCode (io.zeebe.protocol.clientapi.ErrorCode)1 EventType (io.zeebe.protocol.clientapi.EventType)1 SubscriptionType (io.zeebe.protocol.clientapi.SubscriptionType)1 MsgPackHelper (io.zeebe.test.broker.protocol.MsgPackHelper)1