Package org.apache.camel

Examples of org.apache.camel.ProducerTemplate.requestBody()


        context.startRoute("foo");

        ProducerTemplate producer = context.createProducerTemplate();
        producer.start();

        Object out = producer.requestBody("activemq:queue:foo", "Foo");
        assertEquals("Bye Foo", out);

        // on purpose forget to stop the producer and it should still work

        context.stopRoute("foo");
View Full Code Here


        // on purpose forget to stop the producer and it should still work

        context.stopRoute("foo");
        context.startRoute("foo");

        out = producer.requestBody("activemq:queue:foo", "Bar");
        assertEquals("Bye Bar", out);
    }

}
View Full Code Here

    public void testRequestUsingDefaultEndpoint() throws Exception {
        ProducerTemplate producer = new DefaultProducerTemplate(context, context.getEndpoint("direct:out"));
        producer.start();

        Object out = producer.requestBody("Hello");
        assertEquals("Bye Bye World", out);

        out = producer.requestBodyAndHeader("Hello", "foo", 123);
        assertEquals("Bye Bye World", out);
View Full Code Here

        getInstalledBundle("CamelBlueprintTestBundle20").start();
        BlueprintContainer ctn = getOsgiService(BlueprintContainer.class, "(osgi.blueprint.container.symbolicname=CamelBlueprintTestBundle20)", 10000);
        CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle20)", 10000);

        ProducerTemplate template = ctx.createProducerTemplate();
        Object out = template.requestBody("direct:a", "world");
        assertEquals("<hello>world</hello>", out);
        template.stop();
    }

    @Configuration
View Full Code Here

    public void testRequestUsingDefaultEndpoint() throws Exception {
        ProducerTemplate producer = new DefaultProducerTemplate(context, context.getEndpoint("direct:out"));
        producer.start();

        Object out = producer.requestBody("Hello");
        assertEquals("Bye Bye World", out);

        out = producer.requestBodyAndHeader("Hello", "foo", 123);
        assertEquals("Bye Bye World", out);
View Full Code Here

    }

    @ManagedOperation(description = "Request body (in out)")
    public Object requestBody(String endpointUri, String body) throws Exception {
        ProducerTemplate template = context.createProducerTemplate();
        Object answer = template.requestBody(endpointUri, body);
        template.stop();
        return answer;
    }

}
View Full Code Here

    public Object requestBody(String endpointUri, Object body) throws Exception {
        ProducerTemplate template = context.createProducerTemplate();
        Object answer = null;
        try {
            answer = template.requestBody(endpointUri, body);
        } finally {
            template.stop();
        }
        return answer;
    }
View Full Code Here

    public void testRouteWithVelocity() throws Exception {
        getInstalledBundle("CamelBlueprintTestBundle20").start();
        CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=CamelBlueprintTestBundle20)", 10000);

        ProducerTemplate template = ctx.createProducerTemplate();
        Object out = template.requestBody("direct:a", "world");
        assertEquals("<hello>world</hello>", out);
        template.stop();
    }

    @Test
View Full Code Here

    public void testCallFromCamel() {
        // get camel context
        CamelContext context = (CamelContext) applicationContext.getBean("conduit_context");
        ProducerTemplate producer = context.createProducerTemplate();
        // The echo parameter will be ignore, since the service has the fix response
        String response = producer.requestBody("direct://jbiStart", "Hello World!", String.class);
        assertEquals("Get a wrong response ", "echo Hello World!", response);
    }
   
    @After
    public void tearDown() {
View Full Code Here

    @Test
    public void testCallFromCamel() {
        // get camel context
        CamelContext context = (CamelContext) applicationContext.getBean("conduit_context");
        ProducerTemplate producer = context.createProducerTemplate();
        String response = producer.requestBody("direct://jbiStart", "Hello", String.class);
        assertEquals("Get a wrong response ", "echo Hello World!", response);
    }
   
    @After
    public void tearDown() {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.