use of org.apache.camel.impl.DefaultProducer in project camel by apache.
the class RetryRouteScopedUntilRecipientListIssueTest method createCamelContext.
@Override
protected CamelContext createCamelContext() throws Exception {
CamelContext context = super.createCamelContext();
context.addEndpoint("fail", new DefaultEndpoint() {
public Producer createProducer() throws Exception {
return new DefaultProducer(this) {
public void process(Exchange exchange) throws Exception {
exchange.setException(new IllegalArgumentException("Damn"));
}
};
}
public Consumer createConsumer(Processor processor) throws Exception {
return null;
}
@Override
protected String createEndpointUri() {
return "fail";
}
public boolean isSingleton() {
return true;
}
});
context.addEndpoint("not-fail", new DefaultEndpoint() {
public Producer createProducer() throws Exception {
return new DefaultProducer(this) {
public void process(Exchange exchange) throws Exception {
// noop
}
};
}
public Consumer createConsumer(Processor processor) throws Exception {
return null;
}
@Override
protected String createEndpointUri() {
return "not-fail";
}
public boolean isSingleton() {
return true;
}
});
return context;
}
use of org.apache.camel.impl.DefaultProducer in project camel by apache.
the class DummyRestProducerFactory method createProducer.
@Override
public Producer createProducer(CamelContext camelContext, String host, String verb, String basePath, final String uriTemplate, String queryParameters, String consumes, String produces, Map<String, Object> parameters) throws Exception {
// use a dummy endpoint
Endpoint endpoint = camelContext.getEndpoint("stub:dummy");
return new DefaultProducer(endpoint) {
@Override
public void process(Exchange exchange) throws Exception {
String query = exchange.getIn().getHeader(Exchange.REST_HTTP_QUERY, String.class);
if (query != null) {
String name = ObjectHelper.after(query, "name=");
exchange.getIn().setBody("Bye " + name);
}
String uri = exchange.getIn().getHeader(Exchange.REST_HTTP_URI, String.class);
if (uri != null) {
int pos = uri.lastIndexOf('/');
String name = uri.substring(pos + 1);
exchange.getIn().setBody("Hello " + name);
}
}
};
}
use of org.apache.camel.impl.DefaultProducer in project camel by apache.
the class EventEndpoint method createProducer.
public Producer createProducer() throws Exception {
ObjectHelper.notNull(applicationContext, "applicationContext");
return new DefaultProducer(this) {
public void process(Exchange exchange) throws Exception {
ApplicationEvent event = toApplicationEvent(exchange);
applicationContext.publishEvent(event);
}
};
}
Aggregations