use of io.zeebe.transport.RemoteAddress in project zeebe by zeebe-io.
the class TopicSubscriptionTest method shouldReceiveEventsAfterChannelInterruption.
@Test
public void shouldReceiveEventsAfterChannelInterruption() {
// given
broker.stubTopicSubscriptionApi(123L);
final RecordingEventHandler recordingHandler = new RecordingEventHandler();
clientRule.topics().newSubscription(clientRule.getDefaultTopicName()).startAtHeadOfTopic().handler(recordingHandler).name(SUBSCRIPTION_NAME).open();
broker.interruptAllServerChannels();
TestUtil.waitUntil(() -> receivedSubscribeCommands().count() >= 2);
final RemoteAddress clientAddress = receivedSubscribeCommands().skip(1).findFirst().get().getSource();
// when
broker.pushTopicEvent(clientAddress, 124L, 1L, 2L);
// then
TestUtil.waitUntil(() -> recordingHandler.getRecordedEvents().size() > 0);
assertThat(recordingHandler.getRecordedEvents()).hasSize(1);
}
use of io.zeebe.transport.RemoteAddress in project zeebe by zeebe-io.
the class TopicSubscriptionTest method shouldInvokeWorkflowHandlerForWorkflowEvent.
@Test
public void shouldInvokeWorkflowHandlerForWorkflowEvent() {
// given
broker.stubTopicSubscriptionApi(123L);
final RecordingTopicEventHandler eventHandler = subscribeToAllEvents();
final RemoteAddress clientAddress = broker.getReceivedCommandRequests().get(0).getSource();
// when pushing two events
broker.pushTopicEvent(clientAddress, 123L, 1L, 1L, EventType.WORKFLOW_EVENT);
broker.pushTopicEvent(clientAddress, 123L, 1L, 2L, EventType.WORKFLOW_EVENT);
// then
waitUntil(() -> eventHandler.numWorkflowEvents() >= 2);
final WorkflowEvent event1 = eventHandler.workflowEvents.get(0);
final WorkflowEvent event2 = eventHandler.workflowEvents.get(1);
assertMetadata(event1, 1L, 1L, TopicEventType.WORKFLOW);
assertMetadata(event2, 1L, 2L, TopicEventType.WORKFLOW);
assertThat(eventHandler.numTopicEvents()).isEqualTo(0);
assertThat(eventHandler.numTaskEvents()).isEqualTo(0);
assertThat(eventHandler.numWorkflowEvents()).isEqualTo(2);
assertThat(eventHandler.numWorkflowInstanceEvents()).isEqualTo(0);
assertThat(eventHandler.numIncidentEvents()).isEqualTo(0);
}
use of io.zeebe.transport.RemoteAddress in project zeebe by zeebe-io.
the class TopicSubscriptionTest method shouldInvokeWorkflowInstanceHandlerForWorkflowInstanceEvent.
@Test
public void shouldInvokeWorkflowInstanceHandlerForWorkflowInstanceEvent() {
// given
broker.stubTopicSubscriptionApi(123L);
final RecordingTopicEventHandler eventHandler = subscribeToAllEvents();
final RemoteAddress clientAddress = broker.getReceivedCommandRequests().get(0).getSource();
// when pushing two events
broker.pushTopicEvent(clientAddress, 123L, 1L, 1L, EventType.WORKFLOW_INSTANCE_EVENT);
broker.pushTopicEvent(clientAddress, 123L, 1L, 2L, EventType.WORKFLOW_INSTANCE_EVENT);
// then
waitUntil(() -> eventHandler.numWorkflowInstanceEvents() >= 2);
final WorkflowInstanceEvent event1 = eventHandler.workflowInstanceEvents.get(0);
final WorkflowInstanceEvent event2 = eventHandler.workflowInstanceEvents.get(1);
assertMetadata(event1, 1L, 1L, TopicEventType.WORKFLOW_INSTANCE);
assertMetadata(event2, 1L, 2L, TopicEventType.WORKFLOW_INSTANCE);
assertThat(eventHandler.numTopicEvents()).isEqualTo(0);
assertThat(eventHandler.numTaskEvents()).isEqualTo(0);
assertThat(eventHandler.numWorkflowEvents()).isEqualTo(0);
assertThat(eventHandler.numWorkflowInstanceEvents()).isEqualTo(2);
assertThat(eventHandler.numIncidentEvents()).isEqualTo(0);
}
use of io.zeebe.transport.RemoteAddress in project zeebe by zeebe-io.
the class TopicSubscriptionTest method shouldInvokeRaftEventHandlerForRaftEvent.
@Test
public void shouldInvokeRaftEventHandlerForRaftEvent() {
// given
broker.stubTopicSubscriptionApi(123L);
final RecordingTopicEventHandler eventHandler = subscribeToAllEvents();
final RemoteAddress clientAddress = broker.getReceivedCommandRequests().get(0).getSource();
// when pushing two events
broker.pushTopicEvent(clientAddress, 123L, 1L, 1L, EventType.RAFT_EVENT);
broker.pushTopicEvent(clientAddress, 123L, 1L, 2L, EventType.RAFT_EVENT);
// then
waitUntil(() -> eventHandler.numRaftEvents() >= 2);
final RaftEvent event1 = eventHandler.raftEvents.get(0);
final RaftEvent event2 = eventHandler.raftEvents.get(1);
assertMetadata(event1, 1L, 1L, TopicEventType.RAFT);
assertMetadata(event2, 1L, 2L, TopicEventType.RAFT);
assertThat(eventHandler.numTopicEvents()).isEqualTo(0);
assertThat(eventHandler.numTaskEvents()).isEqualTo(0);
assertThat(eventHandler.numWorkflowEvents()).isEqualTo(0);
assertThat(eventHandler.numWorkflowInstanceEvents()).isEqualTo(0);
assertThat(eventHandler.numIncidentEvents()).isEqualTo(0);
assertThat(eventHandler.numRaftEvents()).isEqualTo(2);
}
use of io.zeebe.transport.RemoteAddress in project zeebe by zeebe-io.
the class PartitionedTaskSubscriptionTest method shouldReceiveEventsFromMultiplePartitions.
@Test
public void shouldReceiveEventsFromMultiplePartitions() {
// given
final int subscriberKey1 = 456;
broker1.stubTaskSubscriptionApi(subscriberKey1);
final int subscriberKey2 = 789;
broker2.stubTaskSubscriptionApi(subscriberKey2);
final RecordingTaskHandler eventHandler = new RecordingTaskHandler();
client.tasks().newTaskSubscription(TOPIC).handler(eventHandler).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();
// when
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);
// then
waitUntil(() -> eventHandler.numHandledTasks() == 2);
assertThat(eventHandler.getHandledTasks()).extracting("metadata.key").containsExactlyInAnyOrder(key1, key2);
}
Aggregations