use of org.apache.camel.Endpoint in project camel by apache.
the class AbstractCamelProducerTemplateFactoryBean method getObject.
public ProducerTemplate getObject() throws Exception {
CamelContext context = getCamelContext();
if (defaultEndpoint != null) {
Endpoint endpoint = context.getEndpoint(defaultEndpoint);
if (endpoint == null) {
throw new IllegalArgumentException("No endpoint found for URI: " + defaultEndpoint);
} else {
template = new DefaultProducerTemplate(context, endpoint);
}
} else {
template = new DefaultProducerTemplate(context);
}
// set custom cache size if provided
if (maximumCacheSize != null) {
template.setMaximumCacheSize(maximumCacheSize);
}
// must start it so its ready to use
ServiceHelper.startService(template);
return template;
}
use of org.apache.camel.Endpoint in project camel by apache.
the class CouchDbComponentTest method testEndpointCreated.
@Test
public void testEndpointCreated() throws Exception {
Map<String, Object> params = new HashMap<String, Object>();
String uri = "couchdb:http://localhost:5984/db";
String remaining = "http://localhost:5984/db";
Endpoint endpoint = new CouchDbComponent(context).createEndpoint(uri, remaining, params);
assertNotNull(endpoint);
}
use of org.apache.camel.Endpoint in project camel by apache.
the class CouchDbConsumerIntegrationTest method testMessages.
@Test
public void testMessages() throws InterruptedException {
final int messageCount = 100;
to.expectedMessageCount(messageCount);
// insert json manually into couch, camel will
// then pick that up and send to mock endpoint
Thread t = new Thread(new Runnable() {
@Override
public void run() {
for (int k = 0; k < messageCount; k++) {
JsonElement obj = new Gson().toJsonTree("{ \"randomString\" : \"" + UUID.randomUUID() + "\" }");
client.save(obj);
}
}
});
t.start();
t.join();
to.assertIsSatisfied();
}
use of org.apache.camel.Endpoint in project camel by apache.
the class CxfBeanTest method testConsumerWithProviders.
/**
* Test that we have an endpoint with 2 providers.
*/
@Test
public void testConsumerWithProviders() throws Exception {
boolean testedEndpointWithProviders = false;
for (Endpoint endpoint : camelContext.getEndpoints()) {
if (endpoint instanceof CxfBeanEndpoint) {
CxfBeanEndpoint beanEndpoint = (CxfBeanEndpoint) endpoint;
if (beanEndpoint.getEndpointUri().equals("customerServiceBean")) {
assertNotNull("The bean endpoint should have provider", beanEndpoint.getProviders());
if (beanEndpoint.getProviders().size() == 2) {
testedEndpointWithProviders = true;
break;
} else if (beanEndpoint.getProviders().size() != 0) {
fail("Unexpected number of providers present");
}
}
}
}
assertTrue(testedEndpointWithProviders);
}
use of org.apache.camel.Endpoint in project camel by apache.
the class DisruptorComponent method createEndpoint.
@Override
protected Endpoint createEndpoint(final String uri, final String remaining, final Map<String, Object> parameters) throws Exception {
final int concurrentConsumers = getAndRemoveParameter(parameters, "concurrentConsumers", Integer.class, defaultConcurrentConsumers);
final boolean limitConcurrentConsumers = getAndRemoveParameter(parameters, "limitConcurrentConsumers", Boolean.class, true);
if (limitConcurrentConsumers && concurrentConsumers > MAX_CONCURRENT_CONSUMERS) {
throw new IllegalArgumentException("The limitConcurrentConsumers flag in set to true. ConcurrentConsumers cannot be set at a value greater than " + MAX_CONCURRENT_CONSUMERS + " was " + concurrentConsumers);
}
if (concurrentConsumers < 0) {
throw new IllegalArgumentException("concurrentConsumers found to be " + concurrentConsumers + ", must be greater than 0");
}
int size = 0;
if (parameters.containsKey("size")) {
size = getAndRemoveParameter(parameters, "size", int.class);
if (size <= 0) {
throw new IllegalArgumentException("size found to be " + size + ", must be greater than 0");
}
}
// replacement for the SEDA component.
if (parameters.containsKey("pollTimeout")) {
throw new IllegalArgumentException("The 'pollTimeout' argument is not supported by the Disruptor component");
}
final DisruptorWaitStrategy waitStrategy = getAndRemoveParameter(parameters, "waitStrategy", DisruptorWaitStrategy.class, defaultWaitStrategy);
final DisruptorProducerType producerType = getAndRemoveParameter(parameters, "producerType", DisruptorProducerType.class, defaultProducerType);
final boolean multipleConsumers = getAndRemoveParameter(parameters, "multipleConsumers", boolean.class, defaultMultipleConsumers);
final boolean blockWhenFull = getAndRemoveParameter(parameters, "blockWhenFull", boolean.class, defaultBlockWhenFull);
final DisruptorReference disruptorReference = getOrCreateDisruptor(uri, remaining, size, producerType, waitStrategy);
final DisruptorEndpoint disruptorEndpoint = new DisruptorEndpoint(uri, this, disruptorReference, concurrentConsumers, multipleConsumers, blockWhenFull);
disruptorEndpoint.setWaitStrategy(waitStrategy);
disruptorEndpoint.setProducerType(producerType);
disruptorEndpoint.configureProperties(parameters);
return disruptorEndpoint;
}
Aggregations