use of io.zeebe.client.impl.data.MsgPackConverter in project zeebe by zeebe-io.
the class ZeebeClientTest method shouldThrottleTopologyRefreshRequestsWhenPartitionLeaderCannotBeDetermined.
@Test
public void shouldThrottleTopologyRefreshRequestsWhenPartitionLeaderCannotBeDetermined() {
// when
final int nonExistingPartition = 999;
final TaskEventImpl taskEvent = new TaskEventImpl("CREATED", new MsgPackConverter());
taskEvent.setPartitionId(nonExistingPartition);
assertThatThrownBy(() -> {
client.tasks().complete(taskEvent).execute();
});
// +2 (one for the extra request when client is started)
final long requestTimeout = Long.parseLong(client.getInitializationProperties().getProperty(ClientProperties.CLIENT_REQUEST_TIMEOUT_SEC));
final long requestTimeoutMs = TimeUnit.SECONDS.toMillis(requestTimeout);
final long expectedMaximumTopologyRequests = (requestTimeoutMs / ClientTopologyManager.MIN_REFRESH_INTERVAL_MILLIS.toMillis()) + 2;
final long actualTopologyRequests = broker.getReceivedControlMessageRequests().stream().filter(r -> r.messageType() == ControlMessageType.REQUEST_TOPOLOGY).count();
assertThat(actualTopologyRequests).isLessThanOrEqualTo(expectedMaximumTopologyRequests);
}
use of io.zeebe.client.impl.data.MsgPackConverter in project zeebe by zeebe-io.
the class Events method exampleTask.
public static TaskEventImpl exampleTask() {
final TaskEventImpl baseEvent = new TaskEventImpl("CREATED", new MsgPackConverter());
baseEvent.setHeaders(Maps.newHashMap("defaultHeaderKey", "defaultHeaderVal"));
baseEvent.setCustomHeaders(Maps.newHashMap("customHeaderKey", "customHeaderVal"));
baseEvent.setKey(79);
baseEvent.setLockOwner("foo");
baseEvent.setLockTime(System.currentTimeMillis());
baseEvent.setPartitionId(StubBrokerRule.TEST_PARTITION_ID);
baseEvent.setPayload("{\"key\":\"val\"}");
baseEvent.setRetries(123);
baseEvent.setTopicName(ClientApiRule.DEFAULT_TOPIC_NAME);
baseEvent.setType("taskTypeFoo");
baseEvent.setEventPosition(456);
return baseEvent;
}
use of io.zeebe.client.impl.data.MsgPackConverter in project zeebe by zeebe-io.
the class Events method exampleWorfklowInstance.
public static WorkflowInstanceEventImpl exampleWorfklowInstance() {
final WorkflowInstanceEventImpl baseEvent = new WorkflowInstanceEventImpl("CREATED", new MsgPackConverter());
baseEvent.setActivityId("some_activity");
baseEvent.setBpmnProcessId("some_proceess");
baseEvent.setKey(89);
baseEvent.setPayloadAsJson("{\"key\":\"val\"}");
baseEvent.setPartitionId(StubBrokerRule.TEST_PARTITION_ID);
baseEvent.setTopicName(ClientApiRule.DEFAULT_TOPIC_NAME);
baseEvent.setVersion(123);
baseEvent.setWorkflowInstanceKey(456L);
baseEvent.setWorkflowKey(789L);
return baseEvent;
}
Aggregations