use of org.apache.camel.processor.SendProcessor in project camel by apache.
the class EndpointTransformerDefinition method doCreateTransformer.
@Override
protected Transformer doCreateTransformer(CamelContext context) throws Exception {
Endpoint endpoint = uri != null ? context.getEndpoint(uri) : context.getRegistry().lookupByNameAndType(ref, Endpoint.class);
SendProcessor processor = new SendProcessor(endpoint, ExchangePattern.InOut);
return new ProcessorTransformer(context).setProcessor(processor).setModel(getScheme()).setFrom(getFromType()).setTo(getToType());
}
use of org.apache.camel.processor.SendProcessor in project camel by apache.
the class EndpointValidatorDefinition method doCreateValidator.
@Override
protected Validator doCreateValidator(CamelContext context) throws Exception {
Endpoint endpoint = uri != null ? context.getEndpoint(uri) : context.getRegistry().lookupByNameAndType(ref, Endpoint.class);
SendProcessor processor = new SendProcessor(endpoint, ExchangePattern.InOut);
return new ProcessorValidator(context).setProcessor(processor).setType(getType());
}
use of org.apache.camel.processor.SendProcessor in project camel by apache.
the class AggregateProcessorTimeoutCompletionRestartTest method testAggregateProcessorTimeoutExpressionRestart.
public void testAggregateProcessorTimeoutExpressionRestart() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("A+B");
mock.expectedPropertyReceived(Exchange.AGGREGATED_COMPLETED_BY, "timeout");
Processor done = new SendProcessor(context.getEndpoint("mock:result"));
Expression corr = header("id");
AggregationStrategy as = new BodyInAggregatingStrategy();
AggregateProcessor ap = new AggregateProcessor(context, done, corr, as, executorService, true);
// start with a high timeout so no completes before we stop
ap.setCompletionTimeoutExpression(header("myTimeout"));
ap.start();
Exchange e1 = new DefaultExchange(context);
e1.getIn().setBody("A");
e1.getIn().setHeader("id", 123);
e1.getIn().setHeader("myTimeout", 2000);
Exchange e2 = new DefaultExchange(context);
e2.getIn().setBody("B");
e2.getIn().setHeader("id", 123);
e2.getIn().setHeader("myTimeout", 2000);
ap.process(e1);
ap.process(e2);
// shutdown before the 2 sec timeout occurs
// however we use stop instead of shutdown as shutdown will clear the in memory aggregation repository,
ap.stop();
// should be no completed
assertEquals(0, mock.getReceivedCounter());
// start aggregator again
ap.start();
// the aggregator should restore the timeout condition and trigger timeout
assertMockEndpointsSatisfied();
assertEquals(1, mock.getReceivedCounter());
ap.shutdown();
}
use of org.apache.camel.processor.SendProcessor in project camel by apache.
the class AggregateProcessorTimeoutCompletionRestartTest method testAggregateProcessorTimeoutRestart.
public void testAggregateProcessorTimeoutRestart() throws Exception {
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceived("A+B");
mock.expectedPropertyReceived(Exchange.AGGREGATED_COMPLETED_BY, "timeout");
Processor done = new SendProcessor(context.getEndpoint("mock:result"));
Expression corr = header("id");
AggregationStrategy as = new BodyInAggregatingStrategy();
AggregateProcessor ap = new AggregateProcessor(context, done, corr, as, executorService, true);
// start with a high timeout so no completes before we stop
ap.setCompletionTimeout(2000);
ap.start();
Exchange e1 = new DefaultExchange(context);
e1.getIn().setBody("A");
e1.getIn().setHeader("id", 123);
Exchange e2 = new DefaultExchange(context);
e2.getIn().setBody("B");
e2.getIn().setHeader("id", 123);
ap.process(e1);
ap.process(e2);
// shutdown before the 2 sec timeout occurs
// however we use stop instead of shutdown as shutdown will clear the in memory aggregation repository,
ap.stop();
// should be no completed
assertEquals(0, mock.getReceivedCounter());
// start aggregator again
ap.start();
// the aggregator should restore the timeout condition and trigger timeout
assertMockEndpointsSatisfied();
assertEquals(1, mock.getReceivedCounter());
ap.shutdown();
}
use of org.apache.camel.processor.SendProcessor in project camel by apache.
the class AggregateProcessorTest method testAggregateForceCompletion.
public void testAggregateForceCompletion() throws Exception {
// camel context must be started
context.start();
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedBodiesReceivedInAnyOrder("B+END", "A+END");
mock.expectedPropertyReceived(Exchange.AGGREGATED_COMPLETED_BY, "force");
Processor done = new SendProcessor(context.getEndpoint("mock:result"));
Expression corr = header("id");
AggregationStrategy as = new BodyInAggregatingStrategy();
AggregateProcessor ap = new AggregateProcessor(context, done, corr, as, executorService, true);
ap.setCompletionSize(10);
ap.start();
Exchange e1 = new DefaultExchange(context);
e1.getIn().setBody("A");
e1.getIn().setHeader("id", 123);
Exchange e2 = new DefaultExchange(context);
e2.getIn().setBody("B");
e2.getIn().setHeader("id", 456);
Exchange e3 = new DefaultExchange(context);
e3.getIn().setBody("END");
e3.getIn().setHeader("id", 123);
Exchange e4 = new DefaultExchange(context);
e4.getIn().setBody("END");
e4.getIn().setHeader("id", 456);
ap.process(e1);
ap.process(e2);
ap.process(e3);
ap.process(e4);
assertEquals("should not have completed yet", 0, mock.getExchanges().size());
ap.forceCompletionOfAllGroups();
assertMockEndpointsSatisfied();
ap.stop();
}
Aggregations