/** * Apply a message to the profile. * * @param message The message to apply. * @param timestamp The timestamp of the message. */ @Override public void apply(JSONObject message, long timestamp) { LOG.debug("Applying message to profile; profile={}, entity={}, timestamp={}", profileName, entity, timestamp); try { if (!isInitialized()) { LOG.debug("Initializing profile; profile={}, entity={}, timestamp={}", profileName, entity, timestamp); // execute each 'init' expression assign(definition.getInit(), message, "init"); isInitialized = true; } // execute each 'update' expression assign(definition.getUpdate(), message, "update"); // keep track of the 'latest' timestamp seen for use when flushing the profile if(timestamp > maxTimestamp) { maxTimestamp = timestamp; } } catch(Throwable e) { LOG.error(format("Unable to apply message to profile: %s", e.getMessage()), e); } }