domain.setProperty(CamelContextConfigurator.SHUTDOWN_TIMEOUT, "5");
initDomain(domain);
QName name = new QName("testThrottleTimePeriod");
final ExchangeSink sink = new ExchangeSink();
final Service service = new MockService(name, new InOnlyService(), sink);
final ServiceReference reference = new ServiceReferenceImpl(name, new InOnlyService(), null, null);
// Set throttling to 1 per minute (60000 ms)
Throttling throttle = new Throttling().setMaxRequests(1).setTimePeriod(60 * 1000);
ServiceMetadataBuilder.update(reference.getServiceMetadata()).throttling(throttle);
final ExchangeDispatcher dispatch = _provider.createDispatcher(reference);
final int NUM_SENDS = 5;
for (int i = 0; i < NUM_SENDS; i++) {
new Thread(new Runnable() {
public void run() {
Exchange exchange = dispatch.createExchange(sink, ExchangePattern.IN_ONLY);
exchange.consumer(reference, reference.getInterface().getOperation(ServiceInterface.DEFAULT_OPERATION));
exchange.provider(service, service.getInterface().getOperation(ServiceInterface.DEFAULT_OPERATION));
Message message = exchange.createMessage();
exchange.send(message);
}
}).start();
}