@Handler public void setInsertQueueTimestamp(@Headers Map<String, Object> headers) { headers.put(AsynchConstants.MSG_QUEUE_INSERT_HEADER, System.currentTimeMillis()); }
public String toSql(@XPath("order/@name") String name, @XPath("order/@amount") int amount, @XPath("order/@customer") String customer, @Headers Map<String, Object> outHeaders) { outHeaders.put("partName", name); outHeaders.put("quantity", amount); outHeaders.put("customer", customer); return "insert into incoming_orders (part_name, quantity, customer) values (:?partName, :?quantity, :?customer)"; } }
/** * Saves log request ID into header {@link LogContextFilter#CTX_REQUEST_ID}. * It's because child threads don't inherits this information from parent thread automatically. * * @param msg the message * @param headers the incoming message headers */ @Handler public void saveLogContextParams(@Body Message msg, @Headers Map<String, Object> headers) { // request ID should be set from LogContextFilter#initContext Map contextMap = MDC.getCopyOfContextMap(); String requestId = null; if (contextMap != null && contextMap.get(LogContextFilter.CTX_REQUEST_ID) != null) { requestId = (String) contextMap.get(LogContextFilter.CTX_REQUEST_ID); headers.put(LogContextFilter.CTX_REQUEST_ID, requestId); } LogContextHelper.setLogContextParams(msg, requestId); }
/** * Sets {@link AsynchConstants#OBJECT_ID_HEADER} and {@link AsynchConstants#ENTITY_TYPE_HEADER} * headers if there are available corresponding values in message. * * @param msg the message * @param headers the headers */ @Handler public void setEntityInfo(@Body Message msg, @Headers Map<String, Object> headers) { Assert.notNull(msg, "the msg must not be null"); if (msg.getObjectId() != null) { headers.put(OBJECT_ID_HEADER, msg.getObjectId()); } if (msg.getEntityType() != null) { headers.put(ENTITY_TYPE_HEADER, msg.getEntityType()); } }
public boolean filter(@Body Object input, @Headers Map<String, Object> headers) { final Object body = process(input, headers); try { CustomFilter filter = (CustomFilter) customFilterClass.newInstance(); plugin.getContext().getInjector().inject(filter, plugin.getContext()); return body != null && filter.filter(body); } catch (Exception e) { logger.warn("Failed to instantiate the filter class for plugin " + plugin.getId(), e); } return false; }