Removed the CleanInFlight evente, because the clean is done once the Publish QoS 1 is just published

This commit is contained in:
selva.andre
2012-09-10 21:56:00 +02:00
parent db161599e9
commit 87a51cf4c2
2 changed files with 5 additions and 26 deletions
@@ -139,9 +139,6 @@ public class SimpleMessaging implements IMessaging, EventHandler<ValueEvent> {
DisconnectEvent disEvt = (DisconnectEvent) evt; DisconnectEvent disEvt = (DisconnectEvent) evt;
String clientID = (String) disEvt.getSession().getAttribute(Constants.ATTR_CLIENTID); String clientID = (String) disEvt.getSession().getAttribute(Constants.ATTR_CLIENTID);
processDisconnect(disEvt.getSession(), clientID); processDisconnect(disEvt.getSession(), clientID);
} else if (evt instanceof CleanInFlightEvent) {
//remove the message from inflight storage
m_storageService.cleanInFlight(((CleanInFlightEvent) evt).getMsgId());
} else if (evt instanceof RepublishEvent) { } else if (evt instanceof RepublishEvent) {
processRepublish((RepublishEvent) evt); processRepublish((RepublishEvent) evt);
} else if (evt instanceof ProtocolEvent) { } else if (evt instanceof ProtocolEvent) {
@@ -284,13 +281,11 @@ public class SimpleMessaging implements IMessaging, EventHandler<ValueEvent> {
final byte[] message = evt.getMessage(); final byte[] message = evt.getMessage();
boolean retain = evt.isRetain(); boolean retain = evt.isRetain();
CleanInFlightEvent cleanEvt = null; String publishKey = null;
if (qos == QOSType.LEAST_ONE) { if (qos == QOSType.LEAST_ONE) {
//store the temporary message //store the temporary message
String publishKey = String.format("%s%d", evt.getClientID(), evt.getMessageID()); publishKey = String.format("%s%d", evt.getClientID(), evt.getMessageID());
m_storageService.addInFlight(evt, publishKey); m_storageService.addInFlight(evt, publishKey);
cleanEvt = new CleanInFlightEvent(publishKey);
} }
for (final Subscription sub : subscriptions.matches(topic)) { for (final Subscription sub : subscriptions.matches(topic)) {
@@ -310,8 +305,9 @@ public class SimpleMessaging implements IMessaging, EventHandler<ValueEvent> {
} }
} }
if (cleanEvt != null) { if (qos == QOSType.LEAST_ONE) {
refill(cleanEvt); assert publishKey != null;
m_storageService.cleanInFlight(publishKey);
sendPubAck(new PubAckEvent(evt.getMessageID(), evt.getClientID())); sendPubAck(new PubAckEvent(evt.getMessageID(), evt.getClientID()));
} }
@@ -1,17 +0,0 @@
package org.dna.mqtt.moquette.messaging.spi.impl.events;
/**
* Message to remove the message of type QoS 1 or 2 from in flight store
*/
public class CleanInFlightEvent extends MessagingEvent {
private String m_msgId;
public CleanInFlightEvent(String msgId) {
m_msgId = msgId;
}
public String getMsgId() {
return m_msgId;
}
}