Search in sources :

Example 71 with ProducerTemplate

use of org.apache.camel.ProducerTemplate in project camel by apache.

the class RmiTest method testRmi.

@Test
public void testRmi() throws Exception {
    // Create a new camel context to send the request so we can test the service which is deployed into a container
    CamelContext myContext = new DefaultCamelContext();
    ProducerTemplate myTemplate = myContext.createProducerTemplate();
    myTemplate.start();
    try {
        System.out.println("Calling on port " + port);
        String out = myTemplate.requestBody("rmi://localhost:" + port + "/helloServiceBean", "Camel", String.class);
        assertEquals("Hello Camel", out);
    } finally {
        myTemplate.stop();
        myContext.stop();
    }
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) Test(org.junit.Test)

Example 72 with ProducerTemplate

use of org.apache.camel.ProducerTemplate in project camel by apache.

the class SplunkPublishEventClient method main.

public static void main(String[] args) throws Exception {
    LOG.info("About to run splunk-camel integration...");
    CamelContext camelContext = new DefaultCamelContext();
    camelContext.addRoutes(new SplunkPublishEventRouteBuilder());
    ProducerTemplate eventProducer = camelContext.createProducerTemplate();
    camelContext.start();
    eventProducer.request("direct:start", new SplunkEventProcessor());
    LOG.info("Successfully published event to Splunk.");
    camelContext.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 73 with ProducerTemplate

use of org.apache.camel.ProducerTemplate in project camel by apache.

the class CamelContextStandaloneTest method testStandalone.

public void testStandalone() throws Exception {
    CamelContext context = new DefaultCamelContext();
    context.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("direct:start").to("mock:result");
        }
    });
    context.start();
    MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
    mock.expectedMessageCount(1);
    ProducerTemplate template = context.createProducerTemplate();
    template.sendBody("direct:start", "Hello World");
    mock.assertIsSatisfied();
    template.stop();
    context.stop();
}
Also used : CamelContext(org.apache.camel.CamelContext) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 74 with ProducerTemplate

use of org.apache.camel.ProducerTemplate in project camel by apache.

the class PojoDualCamelContextConsumerTest method testCamel2RecipientList.

public void testCamel2RecipientList() throws Exception {
    String body = "<bye>world!</bye>";
    MockEndpoint result = camel2.getEndpoint("mock:result", MockEndpoint.class);
    result.expectedBodiesReceived(body);
    MockEndpoint foo = camel2.getEndpoint("mock:foo", MockEndpoint.class);
    foo.expectedBodiesReceived(body);
    ProducerTemplate template = camel2.createProducerTemplate();
    template.start();
    template.sendBody("direct:foo", body);
    template.stop();
    result.assertIsSatisfied();
    foo.assertIsSatisfied();
}
Also used : ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 75 with ProducerTemplate

use of org.apache.camel.ProducerTemplate in project camel by apache.

the class PojoDualCamelContextConsumerTest method testCamel2.

public void testCamel2() throws Exception {
    String body = "<bye>world!</bye>";
    MockEndpoint result = camel2.getEndpoint("mock:result", MockEndpoint.class);
    result.expectedBodiesReceived(body);
    ProducerTemplate template = camel2.createProducerTemplate();
    template.start();
    template.sendBody("direct:start", body);
    template.stop();
    result.assertIsSatisfied();
}
Also used : ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Aggregations

ProducerTemplate (org.apache.camel.ProducerTemplate)130 Test (org.junit.Test)58 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)53 CamelContext (org.apache.camel.CamelContext)48 Exchange (org.apache.camel.Exchange)36 DefaultCamelContext (org.apache.camel.impl.DefaultCamelContext)27 Deployment (org.activiti.engine.test.Deployment)16 RouteBuilder (org.apache.camel.builder.RouteBuilder)16 Processor (org.apache.camel.Processor)8 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)8 HashMap (java.util.HashMap)7 Task (org.activiti.engine.task.Task)7 Endpoint (org.apache.camel.Endpoint)7 File (java.io.File)6 ArrayList (java.util.ArrayList)5 Message (org.apache.camel.Message)4 List (java.util.List)3 ExecutorService (java.util.concurrent.ExecutorService)3 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)3 ConsumerTemplate (org.apache.camel.ConsumerTemplate)3