chibenwa commented on code in PR #2028:
URL: https://github.com/apache/james-project/pull/2028#discussion_r1502996220
##########
event-bus/distributed/src/main/java/org/apache/james/events/EventDispatcher.java:
##########
@@ -168,18 +178,32 @@ private Mono<Void> remoteGroupsDispatch(byte[]
serializedEvent, Event event) {
.then(Mono.error(ex)));
}
- private Mono<Void> remoteKeysDispatch(byte[] serializedEvent,
Set<RegistrationKey> keys) {
- return remoteDispatch(serializedEvent,
+ private Mono<Void> remoteKeysDispatch(String eventAsJson,
Set<RegistrationKey> keys) {
+ return remoteDispatch(eventAsJson,
keys.stream()
.map(RoutingKey::of)
.collect(ImmutableList.toImmutableList()));
}
- private Mono<Void> remoteDispatch(byte[] serializedEvent,
Collection<RoutingKey> routingKeys) {
+ private Mono<Void> remoteDispatch(String eventAsJson,
Collection<RoutingKey> routingKeys) {
if (routingKeys.isEmpty()) {
return Mono.empty();
}
- return sender.send(toMessages(serializedEvent, routingKeys));
+
+ return Flux.fromIterable(routingKeys)
+ .flatMap(routingKey -> getTargetChannels(routingKey)
+ .flatMap(channel -> {
+ // message format: event|||eventbusId|||routingKey.
+ // It seems quite dummy but the general idea is to embed
the eventBusId and routingKey into the channel message without refactoring the
Event (not good to put them into Event IMO).
+ String channelMessageToPublish = eventAsJson +
REDIS_CHANNEL_MESSAGE_DELIMITER + eventBusId.asString() +
REDIS_CHANNEL_MESSAGE_DELIMITER + routingKey.asString();
Review Comment:
And if for whatever reason we have a mailbox named `|||` then crazy thing
happens...
We could reverse the order: eventBusId.asString() then routingKey.asString()
then the JSON
and lookup the two first delimiters
Which would make this way more robust
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]