Fixed missed store/load of guid for StoredPublishEvent

This commit is contained in:
andsel
2015-11-15 13:21:28 +01:00
parent 02b23ef926
commit 7fb9198373
4 changed files with 12 additions and 9 deletions
@@ -81,14 +81,8 @@ public interface IMessagesStore {
*/ */
List<PublishEvent> listMessagesInSession(Collection<String> guids); List<PublishEvent> listMessagesInSession(Collection<String> guids);
// void removeMessage(String clientID, Integer packetID);
void dropMessagesInSession(String clientID); void dropMessagesInSession(String clientID);
// void cleanTemporaryPublish(String clientID, int packetID);
// void storeTemporaryPublish(PublishEvent evt, String clientID, int packetID);
/** /**
* Return the next valid packetIdentifer for the given client session. * Return the next valid packetIdentifer for the given client session.
* */ * */
@@ -33,6 +33,7 @@ public class StoredPublishEvent implements Serializable {
String m_clientID; String m_clientID;
//Optional attribute, available only fo QoS 1 and 2 //Optional attribute, available only fo QoS 1 and 2
Integer m_msgID; Integer m_msgID;
String m_guid;
public StoredPublishEvent(PublishEvent wrapped) { public StoredPublishEvent(PublishEvent wrapped) {
m_topic = wrapped.getTopic(); m_topic = wrapped.getTopic();
@@ -45,6 +46,7 @@ public class StoredPublishEvent implements Serializable {
m_message = new byte[buffer.remaining()]; m_message = new byte[buffer.remaining()];
buffer.get(m_message); buffer.get(m_message);
buffer.rewind(); buffer.rewind();
m_guid = wrapped.getGuid();
} }
public String getTopic() { public String getTopic() {
@@ -70,4 +72,8 @@ public class StoredPublishEvent implements Serializable {
public Integer getMessageID() { public Integer getMessageID() {
return m_msgID; return m_msgID;
} }
public String getGuid() {
return m_guid;
}
} }
@@ -428,7 +428,9 @@ public class MapDBPersistentStore implements IMessagesStore, ISessionsStore {
byte[] message = evt.getMessage(); byte[] message = evt.getMessage();
ByteBuffer bbmessage = ByteBuffer.wrap(message); ByteBuffer bbmessage = ByteBuffer.wrap(message);
//bbmessage.flip(); //bbmessage.flip();
return new PublishEvent(evt.getTopic(), evt.getQos(), PublishEvent pubEvt = new PublishEvent(evt.getTopic(), evt.getQos(),
bbmessage, evt.isRetain(), evt.getClientID(), evt.getMessageID()); bbmessage, evt.isRetain(), evt.getClientID(), evt.getMessageID());
pubEvt.setGuid(evt.getGuid());
return pubEvt;
} }
} }
@@ -61,8 +61,9 @@ public class ServerIntegrationPahoTest {
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
String dbPath = IntegrationUtils.localMapDBPath(); String dbPath = IntegrationUtils.localMapDBPath();
File dbFile = new File(dbPath); IntegrationUtils.cleanPersistenceFile(dbPath);
assertFalse(String.format("The DB storagefile %s already exists", dbPath), dbFile.exists()); // File dbFile = new File(dbPath);
// assertFalse(String.format("The DB storagefile %s already exists", dbPath), dbFile.exists());
startServer(); startServer();