org.apache.camel.Consumer Java Examples

The following examples show how to use org.apache.camel.Consumer. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GoalEndpoint.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    // load goals from resource
    InputStream is = getResourceAsInputStream();
    String text = IOHelper.loadText(is);

    // split each line
    Stream<String> stream = Arrays.stream(text.split("\n"));

    // sort goals scored on minutes
    stream = stream.sorted((a, b) -> goalTime(a).compareTo(goalTime(b)));

    // store goals in a list
    List<String> goals = stream.collect(Collectors.toList());

    // create consumer with the goals
    return new GoalConsumer(this, processor, goals);
}
 
Example #2
Source File: CamelRestTest.java    From camel-spring-boot with Apache License 2.0 6 votes vote down vote up
@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 = DefaultUuidGenerator.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);
}
 
Example #3
Source File: CamelProcessorTest.java    From incubator-batchee with Apache License 2.0 6 votes vote down vote up
@Test
public void process() throws Exception {
    final List<Exchange> exchanges = new ArrayList<Exchange>(2);
    final Consumer consumer = CamelBridge.CONTEXT.getEndpoint("direct:processor").createConsumer(new Processor() {
        @Override
        public void process(final Exchange exchange) throws Exception {
            exchanges.add(exchange);
        }
    });
    consumer.start();

    final JobOperator jobOperator = BatchRuntime.getJobOperator();
    Batches.waitForEnd(jobOperator, jobOperator.start("camel-processor", new Properties()));
    assertEquals(StoreItems.ITEMS.size(), 2);
    assertEquals(exchanges.size(), 2);

    for (int i = 1; i <= 2; i++) {
        assertEquals("" + i, StoreItems.ITEMS.get(i - 1));
        assertEquals("" + i, exchanges.get(i - 1).getIn().getBody());
    }

    consumer.stop();
}
 
Example #4
Source File: TestComponent.java    From incubator-batchee with Apache License 2.0 5 votes vote down vote up
@Override
protected Endpoint createEndpoint(final String uri, final String remaining, final Map<String, Object> parameters) throws Exception {
    final String value = String.class.cast(parameters.remove("value"));
    return new DefaultEndpoint() {
        @Override
        protected String createEndpointUri() {
            return uri;
        }

        @Override
        public Producer createProducer() throws Exception {
            return new DefaultProducer(this) {
                @Override
                public void process(final Exchange exchange) throws Exception {
                    exchange.getIn().setBody(exchange.getIn().getBody(String.class) + value);
                }
            };
        }

        @Override
        public Consumer createConsumer(final Processor processor) throws Exception {
            throw new UnsupportedOperationException();
        }

        @Override
        public boolean isSingleton() {
            return true;
        }
    };
}
 
Example #5
Source File: HiWorldEndpoint.java    From camelinaction2 with Apache License 2.0 5 votes vote down vote up
public Consumer createConsumer(Processor processor) throws Exception {
    // make sure inBody is not set for consumers
    if (inBody != null) {
        throw new IllegalArgumentException("Option inBody is not supported for consumer endpoint");
    }
    final HiWorldConsumer consumer = new HiWorldConsumer(this, processor);
    // also set consumer.* properties
    configureConsumer(consumer);
    return consumer;
}
 
Example #6
Source File: ComponentProxyEndpoint.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Override
@SuppressWarnings("PMD.SignatureDeclareThrowsException")
public Consumer createConsumer(final Processor processor) throws Exception {
    final Processor beforeConsumer = getBeforeConsumer();
    final Processor afterConsumer = getAfterConsumer();

    // use a pipeline to process before, processor, after in that order
    // create consumer with the pipeline
    final Processor pipeline = Pipeline.newInstance(getCamelContext(), beforeConsumer, processor, afterConsumer);
    final Consumer consumer = endpoint.createConsumer(pipeline);
    configureConsumer(consumer);

    return consumer;
}
 
Example #7
Source File: HipchatEndpointSupport.java    From wildfly-camel with Apache License 2.0 5 votes vote down vote up
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new HipchatConsumer(this, processor) {
        @Override
        protected CloseableHttpResponse executeGet(HttpGet httpGet) throws IOException {
            return closeableHttpResponse;
        }
    };
}
 
Example #8
Source File: KnativeHttpTransport.java    From camel-k-runtime with Apache License 2.0 5 votes vote down vote up
@Override
public Consumer createConsumer(Endpoint endpoint, KnativeTransportConfiguration config, KnativeEnvironment.KnativeServiceDefinition service, Processor processor) {
    Processor next = KnativeHttpSupport.remapCloudEventHeaders(processor, config.getCloudEvent());

    if (config.isRemoveCloudEventHeadersInReply()) {
        next = KnativeHttpSupport.withoutCloudEventHeaders(next, config.getCloudEvent());
    }

    return new KnativeHttpConsumer(this, endpoint, service, this.router, next);
}
 
Example #9
Source File: DummyEndpoint.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    DummyConsumer consumer = new DummyConsumer(this, processor);
    configureConsumer(consumer);
    consumer.setFailOnRestart(failOnRestart);
    return consumer;
}
 
Example #10
Source File: CamelRestTest.java    From camel-spring-boot with Apache License 2.0 5 votes vote down vote up
@Override
public Consumer createConsumer(
    CamelContext camelContext,
    Processor processor,
    String verb,
    String basePath,
    String uriTemplate,
    String consumes,
    String produces,
    RestConfiguration configuration,
    Map<String, Object> parameters) throws Exception {

    // just use a seda endpoint for testing purpose
    String id;
    if (uriTemplate != null) {
        id = DefaultUuidGenerator.generateSanitizedId(basePath + uriTemplate);
    } else {
        id = DefaultUuidGenerator.generateSanitizedId(basePath);
    }
    // remove leading dash as we add that ourselves
    if (id.startsWith("-")) {
        id = id.substring(1);
    }

    if (configuration.getConsumerProperties() != null) {
        String ref = (String) configuration.getConsumerProperties().get("dummy");
        if (ref != null) {
            dummy = CamelContextHelper.mandatoryLookup(camelContext, ref.substring(1));
        }
    }

    SedaEndpoint seda = camelContext.getEndpoint("seda:" + verb + "-" + id, SedaEndpoint.class);
    return seda.createConsumer(processor);
}
 
Example #11
Source File: JBatchEndpoint.java    From incubator-batchee with Apache License 2.0 4 votes vote down vote up
@Override
public Consumer createConsumer(final Processor processor) throws Exception {
    throw new UnsupportedOperationException();
}
 
Example #12
Source File: UndertowKeycloakEndpoint.java    From keycloak with Apache License 2.0 4 votes vote down vote up
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new UndertowKeycloakConsumer(this, processor, getDeploymentContext(), getSkipPatternAsPattern(), computeAllowedRoles(), this.confidentialPort);
}
 
Example #13
Source File: WildFlyCxfComponent.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new WildflyCxfConsumer(this, processor);
}
 
Example #14
Source File: WildFlyCxfComponent.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new WildflyCxfConsumer(this, processor);
}
 
Example #15
Source File: WildFlyUndertowComponent.java    From wildfly-camel with Apache License 2.0 4 votes vote down vote up
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new WildFlyUndertowUndertowConsumer(this, processor);
}
 
Example #16
Source File: PropagateEndpoint.java    From syncope with Apache License 2.0 4 votes vote down vote up
@Override
public Consumer createConsumer(final Processor processor) throws Exception {
    throw new UnsupportedOperationException("Consumer not supported");
}
 
Example #17
Source File: ERPEndpoint.java    From camelinaction with Apache License 2.0 4 votes vote down vote up
public Consumer createConsumer(Processor processor) throws Exception {
    throw new UnsupportedOperationException("Consumer not supported");
}
 
Example #18
Source File: MyEndpoint.java    From camelinaction with Apache License 2.0 4 votes vote down vote up
public Consumer createConsumer(Processor processor) throws Exception {
    return new MyConsumer(this, processor);
}
 
Example #19
Source File: ErpEndpoint.java    From camelinaction with Apache License 2.0 4 votes vote down vote up
public Consumer createConsumer(Processor processor) throws Exception {
    throw new UnsupportedOperationException("ErpComponent does not support consumer");
}
 
Example #20
Source File: CbSailEndpoint.java    From rya with Apache License 2.0 4 votes vote down vote up
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    throw new RuntimeCamelException((new StringBuilder()).append("Cannot consume from a CbSailEndpoint: ").append(getEndpointUri()).toString());
}
 
Example #21
Source File: MyEndpoint.java    From camelinaction2 with Apache License 2.0 4 votes vote down vote up
public Consumer createConsumer(Processor processor) throws Exception {
    return new MyConsumer(this, processor);
}
 
Example #22
Source File: FlowableEndpoint.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new FlowableConsumer(this, processor);
}
 
Example #23
Source File: ERPEndpoint.java    From camelinaction2 with Apache License 2.0 4 votes vote down vote up
public Consumer createConsumer(Processor processor) throws Exception {
    throw new UnsupportedOperationException("Consumer not supported");
}
 
Example #24
Source File: ErpEndpoint.java    From camelinaction2 with Apache License 2.0 4 votes vote down vote up
public Consumer createConsumer(Processor processor) throws Exception {
    throw new UnsupportedOperationException("ErpComponent does not support consumer");
}
 
Example #25
Source File: WebhookComponentProducer.java    From camel-quarkus with Apache License 2.0 4 votes vote down vote up
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return this.consumer != null ? this.consumer.apply(processor) : null;
}
 
Example #26
Source File: MdwEndpoint.java    From mdw with Apache License 2.0 4 votes vote down vote up
public Consumer createConsumer(Processor processor) throws Exception {
    return new MdwConsumer(this, processor);
}
 
Example #27
Source File: ArdulinkEndpoint.java    From Ardulink-2 with Apache License 2.0 4 votes vote down vote up
@Override
public Consumer createConsumer(Processor processor) throws Exception {
	return new ArdulinkConsumer(this, processor, link);
}
 
Example #28
Source File: DataVecEndpoint.java    From DataVec with Apache License 2.0 4 votes vote down vote up
public Consumer createConsumer(Processor processor) throws Exception {
    return new DataVecConsumer(this, processor);
}
 
Example #29
Source File: JsonEndpoint.java    From funktion-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new JsonConsumer(this, processor);
}
 
Example #30
Source File: K8NatsEndpoint.java    From funktion-connectors with Apache License 2.0 4 votes vote down vote up
@Override
public Consumer createConsumer(Processor processor) throws Exception {
    return new NatsConsumer(this, processor);
}