当前位置: 首页>>代码示例>>Java>>正文


Java Processor.process方法代码示例

本文整理汇总了Java中org.apache.camel.Processor.process方法的典型用法代码示例。如果您正苦于以下问题:Java Processor.process方法的具体用法?Java Processor.process怎么用?Java Processor.process使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.camel.Processor的用法示例。


在下文中一共展示了Processor.process方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: wrapProcessorInInterceptors

import org.apache.camel.Processor; //导入方法依赖的package包/类
@Override
	public Processor wrapProcessorInInterceptors(CamelContext context,
			final ProcessorDefinition<?> definition, final Processor target,
			final Processor nextTarget) throws Exception {
		return new DelegateAsyncProcessor(new Processor() {
			@Override
			public void process(Exchange exchange) throws Exception {
//				if(!camelConfig.isRunning()){
//					System.err.println("系统将关闭,不在处理任务");
//					return ;
//				}
				System.out.println("defainition :"+definition);
				System.out.println("nextTarget :"+nextTarget);
				target.process(exchange);
			}
		});
	}
 
开发者ID:eXcellme,项目名称:eds,代码行数:18,代码来源:DemoInterceptor.java

示例2: process

import org.apache.camel.Processor; //导入方法依赖的package包/类
public boolean process(final Exchange exchange, final AsyncCallback callback) {
    List<Processor> list = getProcessors();
    // too hard to do multiple async, so we do it sync
    for (Processor processor : list) {
        try {
            Exchange copy = copyExchangeStrategy(processor, exchange);
            processor.process(copy);
        } catch (Throwable e) {
            exchange.setException(e);
            // stop on failure
            break;
        }
    }
    callback.done(true);
    return true;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:TopicLoadBalancer.java

示例3: pollEndpoint

import org.apache.camel.Processor; //导入方法依赖的package包/类
/**
 * Creates a {@link PollingConsumer} and polls all pending messages on the endpoint
 * and invokes the given {@link Processor} to process each {@link Exchange} and then closes
 * down the consumer and throws any exceptions thrown.
 */
public static void pollEndpoint(Endpoint endpoint, Processor processor, long timeout) throws Exception {
    PollingConsumer consumer = endpoint.createPollingConsumer();
    try {
        ServiceHelper.startService(consumer);

        while (true) {
            Exchange exchange = consumer.receive(timeout);
            if (exchange == null) {
                break;
            } else {
                processor.process(exchange);
            }
        }
    } finally {
        try {
            ServiceHelper.stopAndShutdownService(consumer);
        } catch (Exception e) {
            LOG.warn("Failed to stop PollingConsumer: " + consumer + ". This example is ignored.", e);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:EndpointHelper.java

示例4: processExpired

import org.apache.camel.Processor; //导入方法依赖的package包/类
public void processExpired(ActivityState activityState) throws Exception {
        Processor processor = getOverdueAction();
        if (processor != null) {
            Date now = new Date();
/*
            TODO this doesn't work and returns null for some strange reason
            ProcessInstance instance = activityState.getProcessInstance();
            ActivityState secondState = second.getActivityState(instance);
            if (secondState == null) {
                log.error("Could not find the second state! Process is: " 
                + instance + " with first state: " + first.getActivityState(instance) 
                + " and the state I was called with was: " + activityState);
            }
*/

            ActivityState secondState = activityState;
            Date overdue = secondState.getTimeOverdue();
            if (now.compareTo(overdue) >= 0) {
                Exchange exchange = createExchange();
                exchange.getIn().setBody(activityState);
                processor.process(exchange);
            } else {
                LOG.warn("Process has not actually expired; the time is: " + now + " but the overdue time is: " + overdue);
            }
        }
    }
 
开发者ID:HydAu,项目名称:Camel,代码行数:27,代码来源:TemporalRule.java

示例5: customProcessExchange

import org.apache.camel.Processor; //导入方法依赖的package包/类
/**
 * Processes the exchange using a custom processor.
 *
 * @param exchange the exchange
 * @param processor the custom processor
 */
protected boolean customProcessExchange(final Exchange exchange, final Processor processor) {
    GenericFile<T> file = getExchangeFileProperty(exchange);
    log.trace("Custom processing file: {}", file);

    // must extract the absolute name before the begin strategy as the file could potentially be pre moved
    // and then the file name would be changed
    String absoluteFileName = file.getAbsoluteFilePath();

    try {
        // process using the custom processor
        processor.process(exchange);
    } catch (Exception e) {
        if (log.isDebugEnabled()) {
            log.debug(endpoint + " error custom processing: " + file + " due to: " + e.getMessage() + ". This exception will be ignored.", e);
        }
        handleException(e);
    } finally {
        // always remove file from the in progress list as its no longer in progress
        // use the original file name that was used to add it to the repository
        // as the name can be different when using preMove option
        endpoint.getInProgressRepository().remove(absoluteFileName);
    }

    return true;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:32,代码来源:GenericFileConsumer.java

示例6: wrapProcessorInInterceptors

import org.apache.camel.Processor; //导入方法依赖的package包/类
public Processor wrapProcessorInInterceptors(final CamelContext context, final ProcessorDefinition<?> definition,
                                             final Processor target, final Processor nextTarget) throws Exception {

    return new DelegateAsyncProcessor(new Processor() {

        public void process(Exchange exchange) throws Exception {
            // we just count number of interceptions
            count++;
            LOG.info("I am the container wide interceptor. Intercepted total count: " + count);
            target.process(exchange);
        }

        @Override
        public String toString() {
            return "ContainerWideInterceptor[" + target + "]";
        }
    });
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:19,代码来源:AdviceWithStartTargetIssueTest.java

示例7: wrapProcessorInInterceptors

import org.apache.camel.Processor; //导入方法依赖的package包/类
public Processor wrapProcessorInInterceptors(final CamelContext context, final ProcessorDefinition<?> definition,
                                             final Processor target, final Processor nextTarget) throws Exception {

    // as this is based on an unit test we are a bit lazy and just create an inlined processor
    // where we implement our interception logic.
    return new Processor() {
        public void process(Exchange exchange) throws Exception {
            // we just count number of interceptions
            count++;
            LOG.info("I am the container wide interceptor. Intercepted total count: " + count);
            // its important that we delegate to the real target so we let target process the exchange
            target.process(exchange);
        }

        @Override
        public String toString() {
            return "ContainerWideInterceptor[" + target + "]";
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:ContainerWideInterceptor.java

示例8: doProcess

import org.apache.camel.Processor; //导入方法依赖的package包/类
/**
 * Processes the exchange by the processors
 *
 * @param processor the processor
 * @param exchange the exchange
 */
protected static void doProcess(Processor processor, Exchange exchange) {
    // must remember some properties which we cannot use during onCompletion processing
    // as otherwise we may cause issues
    // but keep the caused exception stored as a property (Exchange.EXCEPTION_CAUGHT) on the exchange
    Object stop = exchange.removeProperty(Exchange.ROUTE_STOP);
    Object failureHandled = exchange.removeProperty(Exchange.FAILURE_HANDLED);
    Object errorhandlerHandled = exchange.removeProperty(Exchange.ERRORHANDLER_HANDLED);
    Object rollbackOnly = exchange.removeProperty(Exchange.ROLLBACK_ONLY);
    Object rollbackOnlyLast = exchange.removeProperty(Exchange.ROLLBACK_ONLY_LAST);

    Exception cause = exchange.getException();
    exchange.setException(null);

    try {
        processor.process(exchange);
    } catch (Exception e) {
        exchange.setException(e);
    } finally {
        // restore the options
        if (stop != null) {
            exchange.setProperty(Exchange.ROUTE_STOP, stop);
        }
        if (failureHandled != null) {
            exchange.setProperty(Exchange.FAILURE_HANDLED, failureHandled);
        }
        if (errorhandlerHandled != null) {
            exchange.setProperty(Exchange.ERRORHANDLER_HANDLED, errorhandlerHandled);
        }
        if (rollbackOnly != null) {
            exchange.setProperty(Exchange.ROLLBACK_ONLY, rollbackOnly);
        }
        if (rollbackOnlyLast != null) {
            exchange.setProperty(Exchange.ROLLBACK_ONLY_LAST, rollbackOnlyLast);
        }
        if (cause != null) {
            exchange.setException(cause);
        }
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:46,代码来源:OnCompletionProcessor.java

示例9: wrap

import org.apache.camel.Processor; //导入方法依赖的package包/类
public Processor wrap(RouteContext routeContext, final Processor processor) {
    return new Processor() {
        public void process(Exchange exchange) throws Exception {
            invoked++;
            // let the original processor continue routing
            exchange.getIn().setHeader(name, "was wrapped");
            processor.process(exchange);
            exchange.getIn().setHeader(name, "policy finished execution");
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:12,代码来源:PolicyPerRouteTest.java

示例10: pipelineBindingProcessor

import org.apache.camel.Processor; //导入方法依赖的package包/类
/**
 * Applies the {@link Binding} processor to the given exchange before passing it on to the delegateProcessor (either a producer or consumer)
 */
public void pipelineBindingProcessor(Processor bindingProcessor, Exchange exchange, Processor delegateProcessor) throws Exception {
    bindingProcessor.process(exchange);

    Exchange delegateExchange = PipelineHelper.createNextExchange(exchange);
    delegateProcessor.process(delegateExchange);
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:BindingEndpoint.java

示例11: wrap

import org.apache.camel.Processor; //导入方法依赖的package包/类
@Override
public Processor wrap(RouteContext routeContext, final Processor processor) {
    return new Processor() {
        @Override
        public void process(Exchange exchange) throws Exception {
            counter.incrementAndGet();
            processor.process(exchange);
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:ManagedCustomPolicyTest.java

示例12: wrapProcessorInInterceptors

import org.apache.camel.Processor; //导入方法依赖的package包/类
public Processor wrapProcessorInInterceptors(CamelContext context, ProcessorDefinition<?> definition, final Processor target, Processor nextTarget) throws Exception {
    Processor answer = new Processor() {
        public void process(Exchange exchange) throws Exception {
            String order = exchange.getIn().getHeader("order", "", String.class);
            order = order + getOrder();
            exchange.getIn().setHeader("order", order);

            target.process(exchange);
        }
    };
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:13,代码来源:InterceptorStrategyOrderedTest.java

示例13: wrapProcessorInInterceptors

import org.apache.camel.Processor; //导入方法依赖的package包/类
public Processor wrapProcessorInInterceptors(final CamelContext context, final ProcessorDefinition<?> definition,
                                             final Processor target, final Processor nextTarget) throws Exception {

    return new Processor() {
        public void process(Exchange exchange) throws Exception {
            // we just want to count number of interceptions
            counter.incrementAndGet();

            // and continue processing the exchange
            target.process(exchange);
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:14,代码来源:AsyncEndpointCustomInterceptorTest.java

示例14: wrap

import org.apache.camel.Processor; //导入方法依赖的package包/类
public Processor wrap(final RouteContext routeContext, final Processor processor) {
    return new Processor() {
        public void process(Exchange exchange) throws Exception {
            invoked++;
            exchange.getIn().setHeader(name, "was wrapped");
            processor.process(exchange);
        }
    };
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:DefinitionPolicyPerProcessorTest.java

示例15: testDataFormatReturnsSameExchange

import org.apache.camel.Processor; //导入方法依赖的package包/类
public void testDataFormatReturnsSameExchange() throws Exception {
    Exchange exchange = createExchangeWithBody(new DefaultCamelContext(), "body");
    Processor processor = new UnmarshalProcessor(new MyDataFormat(exchange));

    processor.process(exchange);

    assertEquals("UnmarshalProcessor did not copy OUT from IN message", "body", exchange.getOut().getBody());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:9,代码来源:UnmarshalProcessorTest.java


注:本文中的org.apache.camel.Processor.process方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。