</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-starter-data-mongodb</artifactId>
+ <artifactId>spring-boot-starter-data-mongodb-reactive</artifactId>
</dependency>
<dependency>
<groupId>org.apache.kafka</groupId>
package de.juplo.kafka.chat.backend.storage.mongodb;
-import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
-public interface ChatRoomRepository extends MongoRepository<ChatRoomTo, String>
+public interface ChatRoomRepository extends ReactiveMongoRepository<ChatRoomTo, String>
{
}
package de.juplo.kafka.chat.backend.storage.mongodb;
-import org.springframework.data.mongodb.repository.MongoRepository;
+import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
+import reactor.core.publisher.Flux;
-import java.util.List;
-
-public interface MessageRepository extends MongoRepository<MessageTo, String>
+public interface MessageRepository extends ReactiveMongoRepository<MessageTo, String>
{
- List<MessageTo> findByChatRoomIdOrderBySerialAsc(String chatRoomId);
+ Flux<MessageTo> findByChatRoomIdOrderBySerialAsc(String chatRoomId);
}
@Override
public Flux<ChatRoomInfo> readChatRoomInfo()
{
- return Flux
- .fromIterable(chatRoomRepository.findAll())
+ return chatRoomRepository.findAll()
.map(chatRoomTo ->
{
UUID chatRoomId = UUID.fromString(chatRoomTo.getId());
@Override
public Flux<Message> readChatRoomData(UUID chatRoomId)
{
- return Flux
- .fromIterable(messageRepository.findByChatRoomIdOrderBySerialAsc(chatRoomId.toString()))
+ return messageRepository.findByChatRoomIdOrderBySerialAsc(chatRoomId.toString())
.map(messageTo -> messageTo.toMessage());
}
}