public void notification(int processId, String channel, String payload) { if (LOG.isDebugEnabled()) { LOG.debug("Notification processId: {}, channel: {}, payload: {}", processId, channel, payload); } Exchange exchange = endpoint.createExchange(); Message msg = exchange.getIn(); msg.setHeader("channel", channel); msg.setBody(payload); try { getProcessor().process(exchange); } catch (Exception ex) { String cause = "Unable to process incoming notification from PostgreSQL: processId='" + processId + "', channel='" + channel + "', payload='" + payload + "'"; getExceptionHandler().handleException(cause, ex); } }
if (sendReply && !exchange.getPattern().isOutCapable()) { log.debug("In an inOut capable route"); exchange.setPattern(ExchangePattern.InOut); long deliveryTag = envelope.getDeliveryTag(); try { consumer.getProcessor().process(exchange); } catch (Exception e) { exchange.setException(e); if (exchange.getException() != null) { consumer.getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException()); exchange.setException(e); consumer.getExceptionHandler().handleException("Error processing exchange", exchange, e); msg.setBody(exchange.getException()); exchange.setOut(msg); exchange.getOut().setHeader(RabbitMQConstants.CORRELATIONID, exchange.getIn().getHeader(RabbitMQConstants.CORRELATIONID)); try { consumer.getEndpoint().publishExchangeToChannel(exchange, channel, properties.getReplyTo()); } catch (RuntimeCamelException e) { consumer.getExceptionHandler().handleException("Error processing exchange", exchange, e);
client.setServerKeyVerifier(new ResourceBasedSSHKeyVerifier(exchange.getContext(), knownHostResource, endpoint.isFailOnUnknownHost())); SshResult result = SshHelper.sendExecCommand(exchange.getIn().getHeaders(), command, endpoint, client); exchange.getIn().setBody(result.getStdout()); exchange.getIn().setHeader(SshResult.EXIT_VALUE, result.getExitValue()); exchange.getIn().setHeader(SshResult.STDERR, result.getStderr()); getProcessor().process(exchange); return 1; // number of messages polled } finally { if (exchange.getException() != null) { getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
private void sendEvent(Exchange exchange) { try { getProcessor().process(exchange); } catch (Exception e) { exchange.setException(e); } finally { // log exception if an exception occurred and was not handled if (exchange.getException() != null) { getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException()); } } }
exchange.getIn().setHeader(Headers.JOB_ID, job.getJobId()); exchange.getIn().setBody(job.getData(), byte[].class); for (String key : STATS_KEY_STR) { if (jobStats.containsKey(key)) { exchange.getIn().setHeader(Headers.PREFIX + key, jobStats.get(key).trim()); getExceptionHandler().handleException("Beanstalk client error", e); resetClient(); return null;
Message message = new DefaultMessage(this.getEndpoint().getCamelContext()); String fileName = StringUtils.substringAfterLast(status.getPath().toString(), "/"); message.setHeader(Exchange.FILE_NAME, fileName); if (key.value != null) { message.setHeader(HdfsHeader.KEY.name(), key.value); message.setBody(value.value); exchange.setIn(message); processor.process(exchange); } catch (Exception e) { exchange.setException(e); if (exchange.getException() != null) { getExceptionHandler().handleException(exchange.getException());
/** * Strategy to delete the message after being processed. * * @param exchange the exchange */ protected void processCommit(Exchange exchange) { try { if (getConfiguration().isDeleteAfterRead()) { String bucketName = exchange.getIn().getHeader(S3Constants.BUCKET_NAME, String.class); String key = exchange.getIn().getHeader(S3Constants.KEY, String.class); LOG.trace("Deleting object from bucket {} with key {}...", bucketName, key); getAmazonS3Client().deleteObject(bucketName, key); LOG.trace("Deleted object from bucket {} with key {}...", bucketName, key); } } catch (AmazonClientException e) { getExceptionHandler().handleException("Error occurred during deleting object. This exception is ignored.", exchange, e); } }
@Override public void run() { IQueue<Object> queue = hazelcastInstance.getQueue(cacheName); if (config.getQueueConsumerMode() == HazelcastQueueConsumerMode.LISTEN) { queue.addItemListener(camelItemListener, true); } if (config.getQueueConsumerMode() == HazelcastQueueConsumerMode.POLL) { while (isRunAllowed()) { try { final Object body = queue.poll(config.getPollingTimeout(), TimeUnit.MILLISECONDS); Exchange exchange = getEndpoint().createExchange(); exchange.getOut().setBody(body); try { processor.process(exchange); } catch (Exception e) { getExceptionHandler().handleException("Error during processing", exchange, e); } } catch (InterruptedException e) { if (LOG.isDebugEnabled()) { LOG.debug("Hazelcast Queue Consumer Interrupted: {}", e, e); continue; } } } } } }
String uid = (String) exchange.removeProperty(MAIL_MESSAGE_UID); org.apache.camel.Message in = exchange.getIn(); MailConfiguration config = getEndpoint().getConfiguration(); String copyTo = in.getHeader("copyTo", config.getCopyTo(), String.class); boolean delete = in.getHeader("delete", config.isDelete(), boolean.class); getExceptionHandler().handleException("Error occurred during committing mail message: " + mail, exchange, e);
@Override public void onMessage(HazelcastMQMessage msg) { String replyToDestination = msg.getReplyTo(); String correlationId = msg.getCorrelationId(); // Build an exchange. Message camelMsg = messageConverter.toCamelMessage(msg); Exchange camelExchange = getEndpoint().createExchange(); // Change the pattern to out/in if we have a reply destination // and the exchange isn't already out capable. if (replyToDestination != null && !camelExchange.getPattern(). isOutCapable()) { camelExchange.setPattern(ExchangePattern.OutIn); } camelExchange.setIn(camelMsg); try { getProcessor().process(camelExchange); } catch (Throwable e) { camelExchange.setException(e); } if (!camelExchange.isFailed() && replyToDestination != null && camelExchange.getPattern().isOutCapable()) { sendReply(correlationId, replyToDestination, camelExchange); } if (camelExchange.isFailed()) { getExceptionHandler().handleException("Error processing exchange.", camelExchange, camelExchange.getException()); } }
/** * Consume the java.awt.BufferedImage from the webcam, all params required. * * @param image The image to process. * @param processor Processor that handles the exchange. * @param endpoint WebcamEndpoint receiving the exchange. */ public static void consumeBufferedImage(BufferedImage image, Processor processor, WebcamEndpoint endpoint, ExceptionHandler exceptionHandler) { Validate.notNull(image); Validate.notNull(processor); Validate.notNull(endpoint); try { Exchange exchange = createOutOnlyExchangeWithBodyAndHeaders(endpoint, image); processor.process(exchange); } catch (Exception e) { exceptionHandler.handleException(e); } }
exchange.setIn(new SpringIntegrationMessage(siInMessage)); getProcessor().process(exchange); } catch (Exception e) { getExceptionHandler().handleException("Error processing exchange", exchange, e); return; SpringIntegrationBinding.storeToSpringIntegrationMessage(exchange.getOut());
public void done(boolean doneSync) { if (exchange.getException() != null) { getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException()); } } });
@Override protected int poll() throws Exception { Exchange exchange = endpoint.createExchange(); try { // send message to next processor in the route getProcessor().process(exchange); return 1; // number of messages polled } finally { // log exception if an exception occurred and was not handled if (exchange.getException() != null) { getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException()); } } } }
if (cx.targetException().equals(ec)) { ExceptionHandler h = cx.targetCatchHandler().newInstance(); h.handleException(e); break;
public boolean process(Exchange exchange, final AsyncCallback callback) { boolean flag = true; if ((((RouteboxDirectEndpoint)getRouteboxEndpoint()).getConsumer() == null) && ((getRouteboxEndpoint()).getConfig().isSendToConsumer())) { exchange.setException(new CamelExchangeException("No consumers available on endpoint: " + getRouteboxEndpoint(), exchange)); callback.done(true); flag = true; } else { try { LOG.debug("Dispatching to Inner Route {}", exchange); RouteboxDispatcher dispatcher = new RouteboxDispatcher(producer); exchange = dispatcher.dispatchAsync(getRouteboxEndpoint(), exchange); if (getRouteboxEndpoint().getConfig().isSendToConsumer()) { AsyncProcessor processor = ((RouteboxDirectEndpoint)getRouteboxEndpoint()).getConsumer().getAsyncProcessor(); flag = processor.process(exchange, callback); } } catch (Exception e) { getExceptionHandler().handleException("Error processing exchange", exchange, e); } } return flag; }
Exchange exchange = synchronizedExchange.getExchange(); final boolean ignore = exchange.hasProperties() && exchange .getProperties().containsKey(DisruptorEndpoint.DISRUPTOR_IGNORE_EXCHANGE); if (ignore) { result.addOnCompletion(new Synchronization() { @Override public void onComplete(Exchange exchange) { getExceptionHandler().handleException("Error processing exchange", exchange, e); } else { getExceptionHandler().handleException(e);
@Override public void onEvent(Exchange exchange) { if (!isRunAllowed()) { return; } try { getProcessor().process(exchange); } catch (Exception e) { exchange.setException(e); } if (exchange.getException() != null) { getExceptionHandler().handleException("Error processing exchange on status update", exchange, exchange.getException()); } }