use of org.finos.symphony.toolkit.stream.log.SymphonyRoomSharedLog in project spring-bot by finos.
the class SymphonyLeaderEventFilterIT method testMultipleStreamingConsumers.
@Test
public void testMultipleStreamingConsumers() throws InterruptedException {
List<SimpleEventConsumer> consumers = IntStream.range(0, 4).mapToObj(i -> new Participant("p" + i)).map(p -> new SimpleEventConsumer(p)).collect(Collectors.toList());
List<SymphonyStreamHandler> wrapped = consumers.stream().map(c -> {
lmh = new SymphonyRoomSharedLog(clusterName, streamId, messagesApi, "UNIT", 6000);
SymphonyStreamHandler out = new SymphonyStreamHandler(singleApi, c, ec, false);
out.setFilter(new SymphonyLeaderEventFilter(c.p, lmh));
out.start();
return out;
}).collect(Collectors.toList());
// send some messsages through
for (int j = 0; j < 8; j++) {
createLeaderEvent(j % 4);
for (int k = 0; k < 3; k++) {
createMessageEvent(k);
}
}
boolean done = false;
while (!done) {
Thread.sleep(2000);
done = consumers.stream().map(c -> c.collection.size() == 6).reduce(true, (a, b) -> a && b);
}
wrapped.stream().forEach(c -> c.stop());
}
use of org.finos.symphony.toolkit.stream.log.SymphonyRoomSharedLog in project spring-bot by finos.
the class SharedStreamHandlerConfig method symphonySharedLog.
@Bean
@ConditionalOnMissingBean
@Scope(value = BeanDefinition.SCOPE_PROTOTYPE)
protected synchronized SymphonyRoomSharedLog symphonySharedLog(ApiInstance api) {
if (!StringUtils.hasText(streamProperties.getCoordinationStreamId())) {
throw new IllegalArgumentException("Shared Log needs a stream ID to write to. Please set symphony.stream.coordination-stream-id");
}
if (createdLogs.containsKey(api)) {
return createdLogs.get(api);
}
String clusterName = api.getIdentity().getEmail();
SymphonyRoomSharedLog out = new SymphonyRoomSharedLog(clusterName, streamProperties.getCoordinationStreamId(), api.getAgentApi(MessagesApi.class), streamProperties.getEnvironmentIdentifier(), streamProperties.getParticipantWriteIntervalMillis());
createdLogs.put(api, out);
LOG.info("Building Shared Log for " + clusterName);
return out;
}
Aggregations