use of org.apache.camel.component.direct.DirectEndpoint in project camel by apache.
the class SamplingThrottlerTest method sendExchangesThroughDroppingThrottler.
private void sendExchangesThroughDroppingThrottler(List<Exchange> sentExchanges, int messages) throws Exception {
ProducerTemplate myTemplate = context.createProducerTemplate();
DirectEndpoint targetEndpoint = resolveMandatoryEndpoint("direct:sample", DirectEndpoint.class);
for (int i = 0; i < messages; i++) {
Exchange e = targetEndpoint.createExchange();
e.getIn().setBody("<message>" + i + "</message>");
// only send if we are still started
if (context.getStatus().isStarted()) {
myTemplate.send(targetEndpoint, e);
sentExchanges.add(e);
Thread.sleep(100);
}
}
myTemplate.stop();
}
Aggregations