-
Notifications
You must be signed in to change notification settings - Fork 818
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix, recreate sessions when server restarts (#563)
When server restars the session must be recreated in the SessionRegistry pool, else the session is not found in lookup operation and the following published messages are not queued to the session.
- Loading branch information
Showing
9 changed files
with
92 additions
and
6 deletions.
There are no files selected for viewing
3 changes: 3 additions & 0 deletions
3
broker/src/main/java/io/moquette/broker/IQueueRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
package io.moquette.broker; | ||
|
||
import java.util.Map; | ||
import java.util.Queue; | ||
|
||
public interface IQueueRepository { | ||
|
||
Queue<SessionRegistry.EnqueuedMessage> createQueue(String cli, boolean clean); | ||
|
||
Map<String, Queue<SessionRegistry.EnqueuedMessage>> listAllQueues(); | ||
} |
14 changes: 13 additions & 1 deletion
14
broker/src/main/java/io/moquette/broker/MemoryQueueRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,24 @@ | ||
package io.moquette.broker; | ||
|
||
import java.util.Collections; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Queue; | ||
import java.util.concurrent.ConcurrentLinkedQueue; | ||
|
||
public class MemoryQueueRepository implements IQueueRepository { | ||
|
||
private Map<String, Queue<SessionRegistry.EnqueuedMessage>> queues = new HashMap<>(); | ||
|
||
@Override | ||
public Queue<SessionRegistry.EnqueuedMessage> createQueue(String cli, boolean clean) { | ||
return new ConcurrentLinkedQueue<>(); | ||
final ConcurrentLinkedQueue<SessionRegistry.EnqueuedMessage> queue = new ConcurrentLinkedQueue<>(); | ||
queues.put(cli, queue); | ||
return queue; | ||
} | ||
|
||
@Override | ||
public Map<String, Queue<SessionRegistry.EnqueuedMessage>> listAllQueues() { | ||
return Collections.unmodifiableMap(queues); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters