本文整理了Java中org.apache.camel.Handler
类的一些代码示例,展示了Handler
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Handler
类的具体详情如下:
包路径:org.apache.camel.Handler
类名称:Handler
暂无
代码示例来源:origin: forcelate/forcelate-temple-java
@Handler
public String appendYoda(String msg) {
return msg + " © Yoda";
}
}
代码示例来源:origin: forcelate/forcelate-temple-java
@Handler
public String appendYoda(String msg) {
return msg + " © Yoda";
}
}
代码示例来源:origin: org.gytheio/gytheio-messaging-camel
@Override
@Handler
public void onReceive(Object message)
{
if (!(message instanceof Heartbeat))
{
logger.warn("Heartbeat message expected but received: " + message.toString());
return;
}
heartbeatDao.record((Heartbeat) message);
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
@Handler
public void printMessageHistory(Exchange exchange) {
// print message history
String routeStackTrace = MessageHelper.dumpMessageHistoryStacktrace(exchange, historyFormatter, false);
LOG.debug(routeStackTrace);
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
@Handler
public void setInsertQueueTimestamp(@Headers Map<String, Object> headers) {
headers.put(AsynchConstants.MSG_QUEUE_INSERT_HEADER, System.currentTimeMillis());
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
@Handler
public void printGreeting(@Body AsyncHelloRequest req) {
Assert.notNull(req, "req must not be null");
String greeting = "Hello " + req.getName();
LOG.debug("Greeting: " + greeting);
}
}
代码示例来源:origin: apache/servicemix
@Handler
public Map getProcessVariables(@Body String body,
@Header(Exchange.FILE_NAME) String filename,
@Simple("${date:now:yyyy-MM-dd kk:mm:ss}") String timestamp) {
Map<String, Object> variables = new HashMap<String, Object>();
variables.put("message", body);
variables.put("orderid", filename);
variables.put("timestamp", timestamp);
return variables;
}
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
@Handler
public void removeCallParams(@Header(CALL_ID_HEADER) String callId) {
Assert.hasText(callId, "the callId must not be empty");
callRegistry.removeParams(callId);
}
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
@Handler
public boolean checkParentMessage(@Header(MSG_HEADER) Message msg) {
Assert.notNull(msg, "the msg must not be null");
return msg.isParentMessage();
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
@Handler
public void logStartProcessing(@Body Message msg,
@Nullable @Header(AsynchConstants.MSG_QUEUE_INSERT_HEADER) Long msgInsertTime) {
LOG.debug("Starts processing of the message {}, waited in queue for {} ms", msg.toHumanString(),
msgInsertTime != null ? (System.currentTimeMillis() - msgInsertTime) : "-");
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
@Handler
public void setMsgPriority(@Body Message msg) {
// new messages will be processed earlier then PARTLY_FAILED or POSTPONED messages
msg.setProcessingPriority(NEW_MSG_PRIORITY);
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
/**
* Splits specified message into smaller messages.
*
* @param parentMsg the parent message
* @param body the body
*/
@Handler
void splitMessage(@Header(AsynchConstants.MSG_HEADER) Message parentMsg, @Body Object body);
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
/**
* Creates OK response.
*
* @param exchange the exchange
* @return CallbackResponse
*/
@Handler
public CallbackResponse createOkResponse(Exchange exchange) {
CallbackResponse callbackResponse = new CallbackResponse();
callbackResponse.setStatus(ConfirmationTypes.OK);
return callbackResponse;
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
/**
* Insert new message into database.
*
* @param msg message that will be saved
* @return saved message
*/
@Handler
public Message insertMessage(@Body final Message msg) {
Assert.notNull(msg, "msg can not be null");
LOG.debug("Insert new asynch message '" + msg.toHumanString() + "'.");
messageService.insertMessage(msg);
return msg;
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
@Handler
public boolean isAsynch(@Header(AsynchConstants.ASYNCH_MSG_HEADER) Boolean asynch) {
return BooleanUtils.isTrue(asynch);
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
/**
* Set log context parameters.
*
* @param message the message
* @param requestId the request ID
* @see LogContextHelper#setLogContextParams(Message, String)
*/
@Handler
public void setLogContextParams(@Body Message message,
@Header(LogContextFilter.CTX_REQUEST_ID) @Nullable String requestId) {
LogContextHelper.setLogContextParams(message, requestId);
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
/**
* Checks if current message wasn't converted to other state.
* It can happen when message is long time in queue that repairing process converts message back
* to PARTLY_FAILED state and evenly message can start with duplicate processing.
*
* @param msg the message
* @return {@code true} when message is in wrong state {@code false} otherwise
*/
@Handler
public boolean isMessageObsolete(@Body Message msg) {
Assert.notNull(msg, "the msg must not be null");
MessageService messageService = getBean(MessageService.class);
return !messageService.setStateProcessingForLock(msg);
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
/**
* Returns {@code true} if failed count exceeds limit for failing.
*
* @param msg the message
* @param ex error in processing {@link Message}, {@code NULL} - no error
* @return {@code true} when limit was exceeded, otherwise {@code false}
*/
@Handler
public boolean checkMessageFailed(@Header(MSG_HEADER) Message msg, @Nullable Exception ex) {
Assert.notNull(msg, "the msg must not be null");
boolean result = msg.getFailedCount() >= countPartlyFailsBeforeFailed.getValue();
if (!result && ex != null && ExceptionUtils.indexOfThrowable(ex, StoppingException.class) >= 0) {
LOG.warn("ESB not processing existing message. Message " + ex.getMessage()
+ " is changed to failed state.");
result = true;
}
return result;
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
@Handler
public void postponeMessage(Exchange exchange, @Body Message msg) {
// set Message to header because of event notification
exchange.getIn().setHeader(AsynchConstants.MSG_HEADER, msg);
// change state
getBean(MessageService.class).setStatePostponed(msg);
// generates event
AsynchEventHelper.notifyMsgPostponed(exchange);
}
代码示例来源:origin: OpenWiseSolutions/openhub-framework
/**
* 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);
}
内容来源于网络,如有侵权,请联系作者删除!