Package org.apache.camel

Examples of org.apache.camel.ProducerTemplate


    }

    @Test
    public void testPutMultiRows() throws Exception {
        if (systemReady) {
            ProducerTemplate template = context.createProducerTemplate();
            Map<String, Object> headers = new HashMap<String, Object>();
            headers.put(HbaseAttribute.HBASE_ROW_ID.asHeader(), key[0]);
            headers.put(HbaseAttribute.HBASE_FAMILY.asHeader(), DEFAULTFAMILY);
            headers.put(HbaseAttribute.HBASE_QUALIFIER.asHeader(), column[0]);
            headers.put(HbaseAttribute.HBASE_VALUE.asHeader(), body[0]);

            headers.put(HbaseAttribute.HBASE_ROW_ID.asHeader(2), key[1]);
            headers.put(HbaseAttribute.HBASE_FAMILY.asHeader(2), DEFAULTFAMILY);
            headers.put(HbaseAttribute.HBASE_QUALIFIER.asHeader(2), column[0]);
            headers.put(HbaseAttribute.HBASE_VALUE.asHeader(2), body[1]);

            headers.put(HbaseAttribute.HBASE_ROW_ID.asHeader(3), key[2]);
            headers.put(HbaseAttribute.HBASE_FAMILY.asHeader(3), DEFAULTFAMILY);
            headers.put(HbaseAttribute.HBASE_QUALIFIER.asHeader(3), column[0]);
            headers.put(HbaseAttribute.HBASE_VALUE.asHeader(3), body[2]);

            headers.put(HBaseContats.OPERATION, HBaseContats.PUT);

            template.sendBodyAndHeaders("direct:start", null, headers);

            Configuration configuration = hbaseUtil.getHBaseAdmin().getConfiguration();
            HTable bar = new HTable(configuration, DEFAULTTABLE.getBytes());
            Get get = new Get(Bytes.toBytes((Integer) key[0]));
View Full Code Here


            context.start();

            MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
            mock.setExpectedMessageCount(1);

            ProducerTemplate template = context.createProducerTemplate();
            if (e != null) {
                template.send("direct:in", e);
            } else {
                template.sendBodyAndHeaders("direct:in", payload, headers);
            }
            assertMockEndpointsSatisfied();
            return mock.getReceivedExchanges().get(0);
        } finally {
            context.stop();
View Full Code Here

        SpringCamelContext context = (SpringCamelContext) applicationContext.getBean("camel");
        assertValidContext(context);

        // now lets send a message
        ProducerTemplate template = context.createProducerTemplate();
        template.start();
        template.send("direct:start", new Processor() {
            public void process(Exchange exchange) {
                Message in = exchange.getIn();
                in.setHeader("name", "James");
                in.setBody(body);
            }
        });
        template.stop();

        List list = MyProcessor.getExchanges();
        assertEquals("Should have received a single exchange: " + list, 1, list.size());
    }
View Full Code Here

    private CamelContext context;

    public void testTemplateMaximumCache() throws Exception {
        assertNotNull("Should have injected a producer template", template);

        ProducerTemplate lookup = context.getRegistry().lookup("template", ProducerTemplate.class);
        assertNotNull("Should lookup producer template", lookup);

        assertEquals(50, template.getMaximumCacheSize());
        assertEquals("Size should be 0", 0, template.getCurrentCacheSize());
View Full Code Here

    private CamelContext context;

    public void testHasExistingTemplate() {
        assertNotNull("Should have injected a producer template", template);

        ProducerTemplate lookup = context.getRegistry().lookup("myTemplate", ProducerTemplate.class);
        assertNotNull("Should lookup producer template", lookup);

        ProducerTemplate lookup2 = context.getRegistry().lookup("template", ProducerTemplate.class);
        assertNull("Should not be able to lookup producer template", lookup2);
    }
View Full Code Here

        ProducerTemplate lookup2 = context.getRegistry().lookup("template", ProducerTemplate.class);
        assertNull("Should not be able to lookup producer template", lookup2);
    }

    public void testShouldBeSingleton() {
        ProducerTemplate lookup = context.getRegistry().lookup("myTemplate", ProducerTemplate.class);
        assertNotNull("Should lookup producer template", lookup);

        ProducerTemplate lookup2 = context.getRegistry().lookup("myTemplate", ProducerTemplate.class);
        assertNotNull("Should lookup producer template", lookup);

        assertSame("Should be same instances (singleton)", lookup, lookup2);
    }
View Full Code Here

    @Autowired
    private CamelContext context;

    public void testHasTwoTemplates() {
        ProducerTemplate lookup = context.getRegistry().lookup("myTemplate", ProducerTemplate.class);
        assertNotNull("Should lookup producer template", lookup);

        ProducerTemplate lookup2 = context.getRegistry().lookup("myOtherTemplate", ProducerTemplate.class);
        assertNotNull("Should lookup producer template", lookup2);

        assertNotSame("Should not be same", lookup, lookup2);
    }
View Full Code Here

        // and now we can send a message to the route and see that it works
        MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
        mock.expectedMessageCount(1);

        ProducerTemplate template = camel.createProducerTemplate();
        template.start();
        template.sendBody("direct:start", "Hello World");
        template.stop();

        mock.assertIsSatisfied();
    }
View Full Code Here

        // send a message to the route and see that it works
        MockEndpoint mock = camel.getEndpoint("mock:result", MockEndpoint.class);
        mock.expectedMessageCount(1);

        ProducerTemplate template = camel.createProducerTemplate();
        template.start();
        template.sendBody("direct:start", "Hello World");
        template.stop();

        mock.assertIsSatisfied();
    }
View Full Code Here

        int start = myInterceptor.getCount();

        MockEndpoint result = camel1.getEndpoint("mock:result", MockEndpoint.class);
        result.expectedBodiesReceived("Hello World");

        ProducerTemplate template = camel1.createProducerTemplate();
        template.start();
        template.sendBody("direct:one", "Hello World");
        template.stop();

        result.assertIsSatisfied();

        // lets see if the counter is +1 since last (has 1 step in the route)
        int delta = myInterceptor.getCount() - start;
View Full Code Here

TOP

Related Classes of org.apache.camel.ProducerTemplate

Copyright © 2018 www.massapicom. 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.