Package org.apache.camel

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


    @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 camelContext = new DefaultCamelContext();
        ProducerTemplate myTemplate = camelContext.createProducerTemplate();
        myTemplate.start();
        try {
            String out = myTemplate.requestBody("rmi://localhost:37541/helloServiceBean", "Camel", String.class);
            assertEquals("Hello Camel", out);
        } finally {
            if (myTemplate != null) {
View Full Code Here


        mock.setMinimumResultWaitTime(3000);

        // use our own template that has a higher thread pool than default camel that uses 5
        ProducerTemplate pt = new DefaultProducerTemplate(context, Executors.newFixedThreadPool(10));
        // must start the template
        pt.start();

        List<Future> replies = new ArrayList<Future>(20);
        for (int i = 0; i < 20; i++) {
            Future<Object> out = pt.asyncRequestBody("seda:bar", "Message " + i);
            replies.add(out);
View Full Code Here

        // must use the camel context from osgi
        CamelContext ctx = getOsgiService(CamelContext.class, "(camel.context.symbolicname=" + name + ")"
                + "&&(camel.context.name=camel1)", 10000);

        ProducerTemplate myTemplate = ctx.createProducerTemplate();
        myTemplate.start();

        // do our testing
        MockEndpoint mock = ctx.getEndpoint("mock:result", MockEndpoint.class);
        mock.expectedMessageCount(1);
View Full Code Here

        assertEquals(new Integer(123), out);
    }

    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);
View Full Code Here

        producer.stop();
    }

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

        getMockEndpoint("mock:result").expectedMessageCount(3);

        producer.sendBody("Hello");
        producer.sendBodyAndHeader("Hello", "foo", 123);
View Full Code Here

    }

    public void testCacheProducers() throws Exception {
        ProducerTemplate template = new DefaultProducerTemplate(context);
        template.setMaximumCacheSize(500);
        template.start();

        assertEquals("Size should be 0", 0, template.getCurrentCacheSize());

        // test that we cache at most 500 producers to avoid it eating to much memory
        for (int i = 0; i < 503; i++) {
View Full Code Here

    @Test
    public void testRestartSpringIssue() throws Exception {
        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
View Full Code Here

        assertEquals(new Integer(123), out);
    }

    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);
View Full Code Here

        producer.stop();
    }

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

        getMockEndpoint("mock:result").expectedMessageCount(3);

        producer.sendBody("Hello");
        producer.sendBodyAndHeader("Hello", "foo", 123);
View Full Code Here

    }

    public void testCacheProducers() throws Exception {
        ProducerTemplate template = new DefaultProducerTemplate(context);
        template.setMaximumCacheSize(500);
        template.start();

        assertEquals("Size should be 0", 0, template.getCurrentCacheSize());

        // test that we cache at most 500 producers to avoid it eating to much memory
        for (int i = 0; i < 503; i++) {
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.