use of org.apache.camel.component.seda.SedaEndpoint in project camel by apache.
the class EndpointPropertyTest method testEndpointProperty.
@Test
public void testEndpointProperty() throws Exception {
getMockEndpoint("mock:result").expectedMessageCount(2);
template.sendBody("ref:foo", "Hello World");
template.sendBody("ref:bar", "Bye World");
assertMockEndpointsSatisfied();
BlueprintCamelContext blue = context().adapt(BlueprintCamelContext.class);
SedaEndpoint foo = (SedaEndpoint) blue.getBlueprintContainer().getComponentInstance("foo");
assertNotNull(foo);
assertEquals(100, foo.getSize());
assertEquals(5000, foo.getPollTimeout());
assertEquals(true, foo.isBlockWhenFull());
assertEquals("seda://foo?blockWhenFull=true&pollTimeout=5000&size=100", foo.getEndpointUri());
SedaEndpoint bar = (SedaEndpoint) blue.getBlueprintContainer().getComponentInstance("bar");
assertNotNull(bar);
assertEquals(200, bar.getSize());
assertEquals("seda://bar?size=200", bar.getEndpointUri());
}
use of org.apache.camel.component.seda.SedaEndpoint in project camel by apache.
the class IsMockEndpointsAndSkipJUnit4Test method testMockEndpointAndSkip.
@Test
public void testMockEndpointAndSkip() throws Exception {
// notice we have automatic mocked the direct:foo endpoints and the name of the endpoints is "mock:uri"
getMockEndpoint("mock:result").expectedBodiesReceived("Hello World");
getMockEndpoint("mock:direct:foo").expectedMessageCount(1);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
// the message was not send to the direct:foo route and thus not sent to the seda endpoint
SedaEndpoint seda = context.getEndpoint("seda:foo", SedaEndpoint.class);
assertEquals(0, seda.getCurrentQueueSize());
}
use of org.apache.camel.component.seda.SedaEndpoint in project camel by apache.
the class SedaDisruptorCompareTest method installSizeMonitoring.
private ExecutorService installSizeMonitoring(final Endpoint endpoint) {
final ScheduledExecutorService service = context.getExecutorServiceManager().newScheduledThreadPool(this, "SizeMonitoringThread", 1);
endpointSizeQueue.clear();
final Runnable monitoring = new Runnable() {
@Override
public void run() {
if (endpoint instanceof SedaEndpoint) {
final SedaEndpoint sedaEndpoint = (SedaEndpoint) endpoint;
endpointSizeQueue.offer(sedaEndpoint.getCurrentQueueSize());
} else if (endpoint instanceof DisruptorEndpoint) {
final DisruptorEndpoint disruptorEndpoint = (DisruptorEndpoint) endpoint;
long remainingCapacity = 0;
try {
remainingCapacity = disruptorEndpoint.getRemainingCapacity();
} catch (DisruptorNotStartedException e) {
//ignore
}
endpointSizeQueue.offer((int) (disruptorEndpoint.getBufferSize() - remainingCapacity));
}
}
};
service.scheduleAtFixedRate(monitoring, 0, 100, TimeUnit.MILLISECONDS);
return service;
}
use of org.apache.camel.component.seda.SedaEndpoint in project camel by apache.
the class ComponentConfigurationTest method testConfigureAnExistingSedaEndpoint.
/**
* Shows how we can use the configuration to get and set parameters directly on the endpoint
* for a {@link UriEndpointComponent}
*/
@Test
public void testConfigureAnExistingSedaEndpoint() throws Exception {
SedaEndpoint endpoint = context.getEndpoint("seda:cheese?concurrentConsumers=5", SedaEndpoint.class);
SedaComponent component = endpoint.getComponent();
ComponentConfiguration configuration = component.createComponentConfiguration();
assertEquals("concurrentConsumers", 5, endpoint.getConcurrentConsumers());
assertEquals("concurrentConsumers", 5, configuration.getEndpointParameter(endpoint, "concurrentConsumers"));
// lets try set and get some valid parameters
configuration.setEndpointParameter(endpoint, "concurrentConsumers", 10);
Object concurrentConsumers = configuration.getEndpointParameter(endpoint, "concurrentConsumers");
assertEquals("endpoint.concurrentConsumers", 10, concurrentConsumers);
configuration.setEndpointParameter(endpoint, "size", 1000);
Object size = configuration.getEndpointParameter(endpoint, "size");
assertEquals("endpoint.size", 1000, size);
// lets try set an invalid parameter
try {
configuration.setEndpointParameter(endpoint, "doesNotExist", 1000);
fail("Should have got InvalidPropertyException thrown!");
} catch (InvalidPropertyException e) {
LOG.info("Got expected exception: " + e);
}
}
use of org.apache.camel.component.seda.SedaEndpoint in project camel by apache.
the class DummyRestConsumerFactory method createApiConsumer.
@Override
public Consumer createApiConsumer(CamelContext camelContext, Processor processor, String contextPath, RestConfiguration configuration, Map<String, Object> parameters) throws Exception {
// just use a seda endpoint for testing purpose
String id = ActiveMQUuidGenerator.generateSanitizedId(contextPath);
// remove leading dash as we add that ourselves
if (id.startsWith("-")) {
id = id.substring(1);
}
SedaEndpoint seda = camelContext.getEndpoint("seda:api:" + "-" + id, SedaEndpoint.class);
return seda.createConsumer(processor);
}
Aggregations