Skip to content

Commit

Permalink
add message header property to keep track of the received timestamp
Browse files Browse the repository at this point in the history
Signed-off-by: riccardomodanese <riccardo.modanese@eurotech.com>
  • Loading branch information
riccardomodanese committed Sep 25, 2019
1 parent 0ec900f commit c8ebebb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ private MessageConstants() {
public static final String METRIC_NODE_ID = "nodeId";

public static final String HEADER_KAPUA_CONNECTION_ID = "KAPUA_CONNECTION_ID";
public static final String HEADER_KAPUA_RECEIVED_TIMESTAMP = "KAPUA_RECEIVED_TIMESTAMP";
public static final String HEADER_KAPUA_CLIENT_ID = "KAPUA_CLIENT_ID";
public static final String HEADER_KAPUA_CONNECTOR_DEVICE_PROTOCOL = "KAPUA_DEVICE_PROTOCOL";
public static final String HEADER_KAPUA_SESSION = "KAPUA_SESSION";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
import org.eclipse.kapua.commons.security.KapuaSession;
import org.eclipse.kapua.commons.setting.system.SystemSetting;
import org.eclipse.kapua.commons.util.ClassUtil;
import org.eclipse.kapua.commons.util.KapuaDateUtils;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.service.account.Account;
import org.eclipse.kapua.service.account.AccountService;
Expand Down Expand Up @@ -551,6 +552,7 @@ private void internalSend(ProducerBrokerExchange producerExchange, Message messa
String message = MessageFormat.format("The caracters '+' and '#' cannot be included in a topic! Destination: {0}", messageSend.getDestination());
throw new SecurityException(message);
}
messageSend.setProperty(MessageConstants.HEADER_KAPUA_RECEIVED_TIMESTAMP, KapuaDateUtils.getKapuaSysDate().toEpochMilli());
if (!isBrokerContext(producerExchange.getConnectionContext())) {
KapuaSecurityContext kapuaSecurityContext = getKapuaSecurityContext(producerExchange.getConnectionContext());
if (!messageSend.getDestination().isTemporary()) {
Expand Down

0 comments on commit c8ebebb

Please sign in to comment.