Package org.apache.camel

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


    @ManagedOperation(description = "Request body (in out)")
    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


        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();
    }

    @Test
View Full Code Here

    public void testRestartSpringIssue() throws Exception {
        context.start();

        ProducerTemplate producer = context.createProducerTemplate();

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

        // on purpose forget to stop the producer and it should still work
        // producer.stop();
        context.stop();
View Full Code Here

        context.start();

        producer = context.createProducerTemplate();

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

        producer.stop();
        context.stop();
    }
View Full Code Here

    public void testJettyMulticastJmsFile() throws Exception {
        TestSupport.deleteDirectory("target/jetty");

        ProducerTemplate template = camelContext.createProducerTemplate();

        String out = template.requestBody("jetty:http://localhost:9000/test", "Hello World", String.class);
        assertEquals("Bye World", out);

        template.stop();

        ConsumerTemplate consumer = camelContext.createConsumerTemplate();
View Full Code Here

    public void testJettyMulticastJmsFile() throws Exception {
        TestSupport.deleteDirectory("target/jetty");

        ProducerTemplate template = camelContext.createProducerTemplate();

        String out = template.requestBody(URL, "Hello World", String.class);
        assertEquals("Bye World", out);

        template.stop();

        ConsumerTemplate consumer = camelContext.createConsumerTemplate();
View Full Code Here

    public void testCamelGreeter() throws Exception {
        TestSupport.deleteDirectory("target/greeter/response");
        assertNotNull(camelContext);
       
        ProducerTemplate template = camelContext.createProducerTemplate();
        Object result = template.requestBody("direct:start", REQUEST);
        template.stop();

        assertEquals("The result is wrong.", "Hello Willem", result);
       
        File file = new File("target/greeter/response/response.txt");
View Full Code Here

    @Test
    public void testSendThenFailoverThenSend() throws Exception {

        ProducerTemplate requester = senderContext.createProducerTemplate();
        LOG.info("*** Sending Request 1");
        String response = (String) requester.requestBody(fromEndpoint, "This is a request");
        assertNotNull(response != null);
        LOG.info("Got response: " + response);

        /**
         * You actually don't need to restart the broker, just wait long enough and the next
View Full Code Here

        LOG.info("Restarting Broker A now.");
        shutdownBrokerA();
        createBrokerA();

        LOG.info("*** Sending Request 2");
        response = (String) requester.requestBody(fromEndpoint, "This is a request");
        assertNotNull(response != null);
        LOG.info("Got response: " + response);
    }

    private CamelContext createSenderContext() throws Exception {
View Full Code Here

        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

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.