- writeChatRoomInfo(
- chatHomeService
- .getChatRoomInfo()
- .doOnNext(chatRoomInfo -> writeChatRoomData(
- chatRoomInfo.getId(),
- chatHomeService
- .getChatRoomData(chatRoomInfo.getId())
- .flatMapMany(chatRoomData -> chatRoomData.getMessages()),
- this::logSuccessChatRoom,
- this::logFailureChatRoom)));
+ return writeChatRoomInfo(chatHomeService.getChatRoomInfo())
+ .flatMap(chatRoomInfo -> writeChatRoomData(
+ chatRoomInfo.getId(),
+ chatHomeService
+ .getChatRoomData(chatRoomInfo.getId())
+ .flatMapMany(chatRoomData -> chatRoomData.getMessages())
+ )
+ .count()
+ .doOnSuccess(count -> log.info("Stored {} messages for {}", count, chatRoomInfo))
+ .doOnError(throwable -> log.error("Could not store {}: {}", chatRoomInfo, throwable)))
+ .count()
+ .doOnSuccess(count -> log.info("Stored {} chat-rooms for {}", count, chatHomeService))
+ .doOnError(throwable -> log.error("Could not store {}: {}", chatHomeService, throwable))
+ .then();