throw new InvalidUsernameException(user);
Message.MessageKey key = Message.MessageKey.of(user, id);
+
+ Mono<Message> other = service
+ .persistMessage(key, LocalDateTime.now(clock), text)
+ .doOnNext(m ->
+ {
+ Sinks.EmitResult result = sink.tryEmitNext(m);
+ if (result.isFailure())
+ {
+ log.warn("Emitting of message failed with {} for {}", result.name(), m);
+ }
+ });
+
Mono<Message> mono = service
.getMessage(key)
.handle((existing, sink) ->
}
});
- return mono.<Mono<Message>>switchIfEmpty(service
- .persistMessage(key, LocalDateTime.now(clock), text)
- .<Mono<Message>>doOnNext(m ->
- {
- Sinks.EmitResult result = sink.tryEmitNext(m);
- if (result.isFailure())
- {
- log.warn("Emitting of message failed with {} for {}", result.name(), m);
- }
- }));
+ return mono.switchIfEmpty(other);
}