Package org.apache.camel.spi

Examples of org.apache.camel.spi.IdempotentRepository


        ExpressionDefinition expression = expNode.getExpression();
        IdempotentConsumerDefinition idempotentConsume = (IdempotentConsumerDefinition)expNode;
        buffer.append("(");
        ExpressionRenderer.render(buffer, expression);
        buffer.append(", ");
        IdempotentRepository repository = idempotentConsume.getMessageIdRepository();
        if (repository instanceof FileIdempotentRepository) {
            // TODO need to be improved
            buffer.append("FileIdempotentRepository.fileIdempotentRepository()");
        } else if (repository instanceof MemoryIdempotentRepository) {
            buffer.append("MemoryIdempotentRepository.memoryIdempotentRepository()");
View Full Code Here


    public void testNotSkiDuplicate() throws Exception {
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                IdempotentRepository repo = MemoryIdempotentRepository.memoryIdempotentRepository(200);

                from("direct:start")
                    .idempotentConsumer(header("messageId")).messageIdRepository(repo).skipDuplicate(false)
                    .to("mock:result");
            }
View Full Code Here

    public void testNotSkiDuplicateWithFilter() throws Exception {
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                IdempotentRepository repo = MemoryIdempotentRepository.memoryIdempotentRepository(200);

                // START SNIPPET: e1
                from("direct:start")
                    // instruct idempotent consumer to not skip duplicates as we will filter then our self
                    .idempotentConsumer(header("messageId")).messageIdRepository(repo).skipDuplicate(false)
View Full Code Here

    public void testNotEager() throws Exception {
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                final IdempotentRepository repo = MemoryIdempotentRepository.memoryIdempotentRepository(200);

                from("direct:start").idempotentConsumer(header("messageId"), repo).eager(false).
                        process(new Processor() {
                            public void process(Exchange exchange) throws Exception {
                                String id = exchange.getIn().getHeader("messageId", String.class);
                                // should not contain
                                assertFalse("Should not eager add to repo", repo.contains(id));
                            }
                        }).to("mock:result");
            }
        });
        context.start();
View Full Code Here

    public void testEager() throws Exception {
        context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() throws Exception {
                final IdempotentRepository repo = MemoryIdempotentRepository.memoryIdempotentRepository(200);

                from("direct:start").idempotentConsumer(header("messageId"), repo).eager(true).
                        process(new Processor() {
                            public void process(Exchange exchange) throws Exception {
                                String id = exchange.getIn().getHeader("messageId", String.class);
                                // should contain
                                assertTrue("Should eager add to repo", repo.contains(id));
                            }
                        }).to("mock:result");
            }
        });
        context.start();
View Full Code Here

        ExpressionDefinition expression = expNode.getExpression();
        IdempotentConsumerDefinition idempotentConsume = (IdempotentConsumerDefinition)expNode;
        buffer.append("(");
        ExpressionRenderer.render(buffer, expression);
        buffer.append(", ");
        IdempotentRepository repository = idempotentConsume.getMessageIdRepository();
        if (repository instanceof FileIdempotentRepository) {
            // TODO need to be improved
            buffer.append("FileIdempotentRepository.fileIdempotentRepository()");
        } else if (repository instanceof MemoryIdempotentRepository) {
            buffer.append("MemoryIdempotentRepository.memoryIdempotentRepository()");
View Full Code Here

    }

    @Override
    public Processor createProcessor(RouteContext routeContext) throws Exception {
        Processor childProcessor = routeContext.createProcessor(this);
        IdempotentRepository idempotentRepository = resolveMessageIdRepository(routeContext);
        Expression expression = getExpression().createExpression(routeContext);
        return new IdempotentConsumer(expression, idempotentRepository, eager, childProcessor);
    }
View Full Code Here

        } else if (expNode instanceof IdempotentConsumerDefinition) {
            IdempotentConsumerDefinition idempotentConsume = (IdempotentConsumerDefinition)expNode;
            buffer.append("(");
            ExpressionRenderer.render(buffer, expression);
            buffer.append(", ");
            IdempotentRepository repository = idempotentConsume.getMessageIdRepository();
            if (repository instanceof FileIdempotentRepository) {
                // TODO need to be improved
                buffer.append("FileIdempotentRepository.fileIdempotentRepository()");
            } else if (repository instanceof MemoryIdempotentRepository) {
                buffer.append("MemoryIdempotentRepository.memoryIdempotentRepository()");
View Full Code Here

            assertEquals("boom!", ExceptionUtils.getRootCause(cee).getMessage());
        }

        assertMockEndpointsSatisfied();
        assertEquals(0, auditLogDao.getAuditCount(message)); // the insert was rolled back
        IdempotentRepository idempotentRepository = getMandatoryBean(IdempotentRepository.class, "jdbcIdempotentRepository");

        // even though the transaction rolled back, the repository should still contain an entry for this messageId
        assertTrue(idempotentRepository.contains("foo"));
    }
View Full Code Here

        template.sendBodyAndHeader("direct:transacted", message, "messageId", "foo");

        assertMockEndpointsSatisfied();
        assertEquals(1, auditLogDao.getAuditCount(message)); // the insert was successful
        IdempotentRepository idempotentRepository = getMandatoryBean(IdempotentRepository.class, "jdbcIdempotentRepository");

        // even though the transaction rolled back, the repository should still contain an entry for this messageId
        assertTrue(idempotentRepository.contains("foo"));
    }
View Full Code Here

TOP

Related Classes of org.apache.camel.spi.IdempotentRepository

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.