Run safely with several instances: ShedLock jobs, Redis WebSocket fan-out
- Scheduled jobs (nightly cleanup, moderation, search dictionary rebuild) take a ShedLock lock in Redis, so only one instance runs each; the moderation run stops before its lock can expire. - STOMP events (chat messages, unread counters, transcoding status) are published to the Redis channel ws:broadcast and every instance hands them to its local simple broker, so subscribers on other instances receive them. Falls back to local delivery if Redis is down; app.websocket.cluster-broadcast switches it off. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -25,7 +25,7 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.messaging.simp.SimpMessagingTemplate;
|
||||
import com.krylov.refound.config.ClusterMessaging;
|
||||
|
||||
class ChatServiceTest {
|
||||
|
||||
@@ -41,7 +41,7 @@ class ChatServiceTest {
|
||||
userRepository = mock(UserRepository.class);
|
||||
postRepository = mock(PostRepository.class);
|
||||
messageRepository = mock(MessageRepository.class);
|
||||
chatService = new ChatService(chatRepository, messageRepository, mock(SimpMessagingTemplate.class),
|
||||
chatService = new ChatService(chatRepository, messageRepository, mock(ClusterMessaging.class),
|
||||
userRepository, postRepository);
|
||||
|
||||
when(userRepository.existsById(anyLong())).thenReturn(true);
|
||||
|
||||
Reference in New Issue
Block a user