Java 类org.apache.camel.LoggingLevel 实例源码

项目:Camel    文件:RouteScopedOnExceptionWithInterceptSendToEndpointIssueTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            errorHandler(deadLetterChannel("mock:global")
                .maximumRedeliveries(2)
                .redeliveryDelay(5000));

            from("direct:start")
                // no redelivery delay for faster unit tests
                .onException(ConnectException.class).maximumRedeliveries(5).redeliveryDelay(0)
                    .logRetryAttempted(true).retryAttemptedLogLevel(LoggingLevel.WARN)
                    // send to mock when we are exhausted
                    .to("mock:exhausted")
                .end()
                .to("seda:foo");
        }
    };
}
项目:flowable-engine    文件:OutboundErrorRoute.java   
@Override
public void configure() throws Exception {
    // no problems
    from("flowable:ErrorHandling:NormalExecution").routeId("outbound").log(LoggingLevel.INFO, "Normal execution").to("seda:inbound");

    // always fails with default error handling: propagates exception back
    // to the caller
    from("flowable:ErrorHandling:ProvokeError").routeId("error").log(LoggingLevel.INFO, "Provoked error").bean("brokenService") // <--
                                                                                                                                // throws
                                                                                                                                // Exception
            .to("seda:inbound");

    // always fails with specific error handler: exception is not propagated
    // back
    from("flowable:ErrorHandling:HandleError").routeId("errorWithDlq").errorHandler(deadLetterChannel("seda:dlq")).log(LoggingLevel.INFO, "Provoked error").bean("brokenService") // <--
                                                                                                                                                                                  // throws
                                                                                                                                                                                  // Exception
            .to("seda:inbound");
}
项目:Camel    文件:BindySimpleKeyValuePairWithoutSectionMarshallDslTest.java   
public void configure() {

            Tracer tracer = new Tracer();
            tracer.setLogLevel(LoggingLevel.ERROR);
            tracer.setLogName("org.apache.camel.bindy");
            tracer.setLogStackTrace(true);
            tracer.setTraceExceptions(true);

            getContext().addInterceptStrategy(tracer);

            // default should errors go to mock:error
            errorHandler(deadLetterChannel(URI_MOCK_ERROR));

            onException(IllegalArgumentException.class).maximumRedeliveries(0).handled(true);

            from(URI_DIRECT_START).marshal(orderBindyDataFormat).to(URI_MOCK_RESULT);
        }
项目:Camel    文件:RedeliveryErrorHandlerNoRedeliveryOnShutdownTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            // START SNIPPET: e1

            // this error handler will try up till 20 redelivery attempts with 1 second between.
            // however if we are stopping then do not allow any redeliver attempts.
            errorHandler(defaultErrorHandler()
                    .allowRedeliveryWhileStopping(false)
                    .maximumRedeliveries(20).redeliveryDelay(1000).retryAttemptedLogLevel(LoggingLevel.INFO));

            from("seda:foo").routeId("foo")
                .to("mock:foo")
                .throwException(new IllegalArgumentException("Forced"));
            // END SNIPPET: e1
        }
    };
}
项目:Camel    文件:NettyRedeliveryTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            onException(Exception.class)
                    .maximumRedeliveries(REDELIVERY_COUNT)
                    .retryAttemptedLogLevel(LoggingLevel.INFO)
                    .retriesExhaustedLogLevel(LoggingLevel.ERROR)
                    // lets have a little delay so we do async redelivery
                    .redeliveryDelay(10)
                    .to("mock:exception")
                    .handled(true);

            from("direct:start")
                    .routeId("start")
                    .to("netty4:tcp://localhost:" + port)
                    .to("log:downstream")
                    .to("mock:downstream");
        }
    };
}
项目:Camel    文件:SjmsBatchConsumerTest.java   
@Test
public void testConsumptionCompletionSize() throws Exception {
    final int completionSize = 5;
    final int completionTimeout = -1; // size-based only

    final String queueName = getQueueName();
    context.addRoutes(new TransactedSendHarness(queueName));
    context.addRoutes(new RouteBuilder() {
        public void configure() throws Exception {
            fromF("sjms-batch:%s?completionTimeout=%s&completionSize=%s&aggregationStrategy=#testStrategy",
                    queueName, completionTimeout, completionSize).routeId("batchConsumer").startupOrder(10)
                    .log(LoggingLevel.DEBUG, "${body.size}")
                    .to("mock:batches");
        }
    });
    context.start();

    int messageCount = 100;
    MockEndpoint mockBatches = getMockEndpoint("mock:batches");
    mockBatches.expectedMessageCount(messageCount / completionSize);

    template.sendBody("direct:in", generateStrings(messageCount));
    mockBatches.assertIsSatisfied();
}
项目:Camel    文件:LoggingErrorHandlerBuilderTest.java   
public void testLoggingErrorHandler5() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            errorHandler(loggingErrorHandler().level(LoggingLevel.ERROR).logName("foo"));

            from("direct:start").to("mock:foo").throwException(new IllegalArgumentException("Damn"));
        }
    });
    context.start();

    try {
        template.sendBody("direct:start", "Hello World");
        fail("Should have thrown an exception");
    } catch (Exception e) {
        // expected
    }
}
项目:Camel    文件:BindyPojoSimpleCsvMarshallTest.java   
public void configure() {
    BindyCsvDataFormat camelDataFormat = 
        new BindyCsvDataFormat(org.apache.camel.dataformat.bindy.model.simple.oneclass.Order.class);
    camelDataFormat.setLocale("en");

    Tracer tracer = new Tracer();
    tracer.setLogLevel(LoggingLevel.ERROR);
    tracer.setLogName("org.apache.camel.bindy");

    getContext().addInterceptStrategy(tracer);

    // default should errors go to mock:error
    errorHandler(deadLetterChannel(URI_MOCK_ERROR).redeliveryDelay(0));

    onException(Exception.class).maximumRedeliveries(0).handled(true);

    from(URI_DIRECT_START).marshal(camelDataFormat).to(URI_MOCK_RESULT);
}
项目:Camel    文件:FaultRetryRouteTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() {
            getContext().addInterceptStrategy(new HandleFault());

            errorHandler(
                deadLetterChannel("mock:error")
                    .maximumRedeliveries(4)
                    .loggingLevel(LoggingLevel.DEBUG));

            from("direct:start")
                .to("mock:a")
                .process(successOnRetryProcessor)
                .to("mock:b");
        }
    };
}
项目:Camel    文件:MultipleErrorHandlerOnExceptionIssueTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            onException(IllegalArgumentException.class)
                .handled(true)
                .to("mock:handled");

            from("seda:a")
                .errorHandler(deadLetterChannel("mock:dead.a")
                        .maximumRedeliveries(3).redeliveryDelay(0)
                        .retryAttemptedLogLevel(LoggingLevel.WARN).asyncDelayedRedelivery())
                .to("mock:a")
                .throwException(new IllegalArgumentException("Forced A"));

            from("seda:b")
                    .errorHandler(deadLetterChannel("mock:dead.b")
                        .maximumRedeliveries(2).redeliveryDelay(0)
                        .retryAttemptedLogLevel(LoggingLevel.WARN))
                .to("mock:b")
                .throwException(new IOException("Some IO error"));
        }
    };
}
项目:Camel    文件:LoggingErrorHandlerBuilderTest.java   
public void testLoggingErrorHandler2() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            errorHandler(loggingErrorHandler().level(LoggingLevel.WARN).log(LoggerFactory.getLogger("foo")));

            from("direct:start").to("mock:foo").throwException(new IllegalArgumentException("Damn"));
        }
    });
    context.start();

    try {
        template.sendBody("direct:start", "Hello World");
        fail("Should have thrown an exception");
    } catch (Exception e) {
        // expected
    }
}
项目:Camel    文件:ManagedRouteContextTracerTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            Tracer tracer = new Tracer();
            tracer.setDestinationUri("mock:traced");
            tracer.setLogLevel(LoggingLevel.OFF);
            context.addInterceptStrategy(tracer);

            from("direct:start").to("log:foo").to("mock:result");

            from("direct:foo").noTracing().to("mock:foo");
        }
    };
}
项目:fis-amq-producer    文件:JmsMessageProducerRoute.java   
@SuppressWarnings("el-syntax")
@Override
public void configure() throws Exception {
    from("netty4-http:http://0.0.0.0:9090/produceJmsMessage")
        .routeId("jms-message-producer-route")
        .streamCaching()
        .setProperty("start", simple("${date:now:YYYYMMDD HH:mm:ss.SSS}"))
        .filter(header("destination").isNull())
            .transform().method("informationBean","transactedUsage()")
            .stop()
        .end()
        .process("jmsSendPropertiesProcessor") // Prepare JMS Send Properties
        .log(LoggingLevel.INFO, 
                "Publishing ${exchangeProperty.messageCount} messages...")
        .setExchangePattern(ExchangePattern.InOnly)
        .loopDoWhile(simple("${exchangeProperty.messageCount} > 0"))
            .process("jmsTransactionBatchProcessor") // Prepare Transaction Batch to send
            .log(LoggingLevel.INFO, 
                    "Batch size: ${exchangeProperty.transactionBatchSize} - [${exchangeProperty.sjmsUri}]")
            .recipientList(exchangeProperty("sjmsUri")).end()
        .end()
        .setProperty("end", simple("${date:now:YYYYMMDD HH:mm:ss.SSS}"))
        .setProperty("duration").method("informationBean",
                     "getDuration(${exchangeProperty.start},${exchangeProperty.end})")
        .log(LoggingLevel.INFO, 
                "Publishing ${exchangeProperty.messageToSend} messages DONE in ${exchangeProperty.duration}")
        .setExchangePattern(ExchangePattern.InOut)
        .process("prepareHttpResponseProcessor");
}
项目:syndesis    文件:LogHandler.java   
@Override
public Optional<ProcessorDefinition> handle(Log step, ProcessorDefinition route, SyndesisRouteBuilder routeBuilder) {
    LoggingLevel loggingLevel = LoggingLevel.INFO;
    if (step.getLoggingLevel() != null) {
        loggingLevel = LoggingLevel.valueOf(step.getLoggingLevel());
    }

    return Optional.of(route.log(loggingLevel, step.getLogger(), step.getMarker(), step.getMessage()));
}
项目:sponge    文件:CamelMultipleConsumerTest.java   
@Bean
@Override
public RouteBuilder route() {
    return new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            // @formatter:off
            from("direct:test").routeId("spongeProducer")
                    .to("sponge:spongeEngine")
                    .log("Sent event: ${body}");

            from("direct:log").routeId("directLog")
                    .log("${body}");

            from("direct:error").routeId("directError")
                    .log(LoggingLevel.ERROR, "Received message on direct:error endpoint.");

            from("direct:end").routeId("directEnd")
                    .log("Received message on direct:end endpoint: ${body}");

            from("sponge:spongeEngine").routeId("spongeConsumer")
                    .log("Received message on direct:consumerEnd endpoint: ${body}");
            // @formatter:on
        }
    };
}
项目:embedded-jms-junit    文件:EmbeddedJmsRuleCamelTest.java   
@Override
protected RoutesBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from(JMS_DESTINATION_URI)
                    .id("testRoute")
                    .convertBodyTo(String.class)
                    .log(LoggingLevel.INFO, "Received message ${id} with body \"${body}\"")
                    .to(MOCK_ENDPOINT_URI);

        }
    };
}
项目:camel-springboot    文件:GetCityZips.java   
@Override
public void configure() throws Exception {
    //OnExcpetion handlers apply only on the routes defined in this RouteBuilder
    onException(Exception.class)
        .handled(true)
        .log(LoggingLevel.ERROR, "Error getting city info. ${exception.message}")
        .bean(GetCityZips.class, "addErrorToCity");

    //A City object is expected as exchangeProperty.city having the name set already.
    //This object will be enriched by the route. This is easier than writing an AggregatorStrategy
    from("direct:getCityZips").routeId("getCityZips")

        //prepare and call stored procedure
        .removeHeaders("*", RestEndpoints.HEADER_BUSINESSID)
        .setHeader("cityName", simple("${exchangeProperty.city?.name}"))
        .setBody((constant(schema == null ? SP_GETZIPS : schema+"."+SP_GETZIPS)))
        .to("sql-stored:GetZips?useMessageBodyForTemplate=true&dataSource=#cityInfoDS")

        //Process stored proc response
        .choice()
            .when(simple("${body[STATUS]} == '0'"))
                .setBody(simple("${body[#result-set-1]}")) //A stored procedure may also return multiple resultsets
                .bean(GetCityZips.class, "processResultset")
            .otherwise()
                .log(LoggingLevel.WARN, "Failed to get zips for ${header.cityName}")
                .bean(GetCityZips.class, "throwStatusError")
        .end()
        ;

}
项目:syndesis-integration-runtime    文件:LogHandler.java   
@Override
public ProcessorDefinition handle(Log item, ProcessorDefinition route, SyndesisRouteBuilder routeBuilder) {
  Log step = item;
  LoggingLevel loggingLevel = LoggingLevel.INFO;
  if (step.getLoggingLevel() != null) {
    loggingLevel = LoggingLevel.valueOf(step.getLoggingLevel());
  }
  return route.log(loggingLevel, step.getLogger(), step.getMarker(), step.getMessage());
}
项目:camel-cookbook    文件:SyncAggregatorRouteBuilder.java   
@Override
public void configure() throws Exception {

    // @formatter:off

    from("direct:start")
        .log(LoggingLevel.INFO, "Received ${headers.system}${headers.deviceId}")
        .aggregate(header("deviceId"), new SignalAggregationStrategy(3))
        .log(LoggingLevel.INFO, "Signaled body: ${body}")
        .to("direct:result");

    // @formatter:on
}
项目:flowable-engine    文件:CamelVariableBodyTest.java   
@Override
public void setUp() throws Exception {
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("flowable:HelloCamel:serviceTask1").log(LoggingLevel.INFO, "Received message on service task").to("mock:serviceBehavior");
        }
    });
    service1 = (MockEndpoint) camelContext.getEndpoint("mock:serviceBehavior");
    service1.reset();
}
项目:flowable-engine    文件:OutboundErrorRoute.java   
@Override
public void configure() throws Exception {
    // no problems
    from("flowable:ErrorHandling:NormalExecution").routeId("outbound").log(LoggingLevel.INFO, "Normal execution").to("seda:inbound");

    // always fails with default error handling: propagates exception back to the caller
    from("flowable:ErrorHandling:ProvokeError").routeId("error").log(LoggingLevel.INFO, "Provoked error").bean("brokenService") // <-- throws Exception
            .to("seda:inbound");

    // always fails with specific error handler: exception is not propagated back
    from("flowable:ErrorHandling:HandleError").routeId("errorWithDlq").errorHandler(deadLetterChannel("seda:dlq")).log(LoggingLevel.INFO, "Provoked error").bean("brokenService") // <-- throws
                                                                                                                                                                                  // Exception
            .to("seda:inbound");
}
项目:flowable-engine    文件:InboundErrorRoute.java   
@Override
public void configure() throws Exception {
    from("seda:inbound").routeId("inbound")
            // give Flowable some time to reach synchronization point
            .bean(TimeConsumingService.class).log(LoggingLevel.INFO, "Returning result ...").to("flowable:ErrorHandling:ReceiveResult");

    from("seda:dlq").routeId("dlq").log(LoggingLevel.INFO, "Error handled by camel ...");
}
项目:flowable-engine    文件:CamelVariableBodyTest.java   
public void setUp() throws Exception {
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("flowable:HelloCamel:serviceTask1").log(LoggingLevel.INFO, "Received message on service task").to("mock:serviceBehavior");
        }
    });
    service1 = (MockEndpoint) camelContext.getEndpoint("mock:serviceBehavior");
    service1.reset();
}
项目:flowable-engine    文件:CamelVariableBodyMapTest.java   
public void setUp() throws Exception {
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("flowable:HelloCamel:serviceTask1").log(LoggingLevel.INFO, "Received message on service task").to("mock:serviceBehavior");
        }
    });

    service1 = (MockEndpoint) camelContext.getEndpoint("mock:serviceBehavior");
    service1.reset();
}
项目:flowable-engine    文件:CdiCamelVariableBodyMapTest.java   
@Before
public void setUp() throws Exception {
    super.setUp();
    camelContext.addRoutes(new RouteBuilder() {

        @Override
        public void configure() throws Exception {
            from("flowable:HelloCamel:serviceTask1").log(LoggingLevel.INFO, "Received message on service task").to("mock:serviceBehavior");
        }
    });

    service1 = (MockEndpoint) camelContext.getEndpoint("mock:serviceBehavior");
    service1.reset();
}
项目:Camel    文件:JmsErrorHandlerLogStackTraceTest.java   
protected CamelContext createCamelContext() throws Exception {
    CamelContext camelContext = super.createCamelContext();

    ConnectionFactory connectionFactory = CamelJmsTestHelper.createConnectionFactory();
    JmsComponent jms = JmsComponent.jmsComponentAutoAcknowledge(connectionFactory);
    jms.setErrorHandlerLogStackTrace(false);
    jms.setErrorHandlerLoggingLevel(LoggingLevel.ERROR);
    camelContext.addComponent("jms", jms);

    return camelContext;
}
项目:Camel    文件:Application.java   
@Override
public void configure() {
    onException()
        .handled(true)
        .maximumRedeliveries(2)
        .logStackTrace(false)
        .logExhausted(false)
        .log(LoggingLevel.ERROR, "Failed processing ${body}")
        .to("metrics:meter:redelivery?mark=2")
        // The 'error' meter
        .to("metrics:meter:error");

    from("timer:stream?period=1000")
        .routeId("unreliable-service")
        .setBody(header(Exchange.TIMER_COUNTER).prepend("event #"))
        .log("Processing ${body}...")
        // The 'generated' meter
        .to("metrics:meter:generated")
        // The 'attempt' meter via @Metered interceptor
        .bean(UnreliableService.class)
        .filter(header(Exchange.REDELIVERED))
            .log(LoggingLevel.WARN, "Processed ${body} after ${header.CamelRedeliveryCounter} retries")
            .setHeader(MetricsConstants.HEADER_METER_MARK, header(Exchange.REDELIVERY_COUNTER))
            // The 'redelivery' meter
            .to("metrics:meter:redelivery")
        .end()
        .log("Successfully processed ${body}")
        // The 'success' meter
        .to("metrics:meter:success");
}
项目:Camel    文件:ProcessorDefinition.java   
/**
 * Creates a log message to be logged at the given level.
 *
 * @param loggingLevel the logging level to use
 * @param message the log message, (you can use {@link org.apache.camel.language.simple.SimpleLanguage} syntax)
 * @return the builder
 */
@SuppressWarnings("unchecked")
public Type log(LoggingLevel loggingLevel, String message) {
    LogDefinition answer = new LogDefinition(message);
    answer.setLoggingLevel(loggingLevel);
    addOutput(answer);
    return (Type) this;
}
项目:Camel    文件:MllpTcpServerConsumerBindTimeoutTest.java   
@Override
protected RouteBuilder createRouteBuilder() {

    mllpClient.setMllpHost("localhost");
    mllpClient.setMllpPort(AvailablePortFinder.getNextAvailable());

    return new RouteBuilder() {
        int connectTimeout = 500;
        int responseTimeout = 5000;

        @Override
        public void configure() throws Exception {
            String routeId = "mllp-test-receiver-route";

            onCompletion()
                    .toF("log:%s?level=INFO&showAll=true", routeId)
                    .log(LoggingLevel.INFO, routeId, "Test route complete");

            fromF("mllp://%s:%d?autoAck=true&connectTimeout=%d&receiveTimeout=%d",
                    mllpClient.getMllpHost(), mllpClient.getMllpPort(), connectTimeout, responseTimeout)
                    .routeId(routeId)
                    .log(LoggingLevel.INFO, routeId, "Test route received message")
                    .to(result);

        }
    };
}
项目:Camel    文件:MllpProducerConsumerLoopbackTest.java   
@Override
protected RouteBuilder[] createRouteBuilders() throws Exception {
    RouteBuilder[] builders = new RouteBuilder[2];
    final int groupInterval = 1000;
    final boolean groupActiveOnly = false;

    builders[0] = new RouteBuilder() {
        String routeId = "mllp-receiver";

        public void configure() {
            fromF("mllp://%s:%d?autoAck=true", mllpHost, mllpPort)
                    .convertBodyTo(String.class)
                    .to(acknowledged)
                    .process(new PassthroughProcessor("after send to result"))
                    .log(LoggingLevel.DEBUG, routeId, "Receiving: ${body}")
                    .toF("log://%s?level=INFO&groupInterval=%d&groupActiveOnly=%b", routeId, groupInterval, groupActiveOnly);
        }
    };

    builders[1] = new RouteBuilder() {
        String routeId = "mllp-sender";

        public void configure() {
            from(source.getDefaultEndpoint()).routeId(routeId)
                    .log(LoggingLevel.DEBUG, routeId, "Sending: ${body}")
                    .toF("mllp://%s:%d", mllpHost, mllpPort)
                    .setBody(header(MllpConstants.MLLP_ACKNOWLEDGEMENT))
                    .toF("log://%s?level=INFO&groupInterval=%d&groupActiveOnly=%b", routeId, groupInterval, groupActiveOnly);
        }
    };

    return builders;
}
项目:Camel    文件:BacklogDebugger.java   
@Override
public void beforeProcess(Exchange exchange, Processor processor, ProcessorDefinition<?> definition) {
    // store a copy of the message so we can see that from the debugger
    Date timestamp = new Date();
    String toNode = definition.getId();
    String routeId = ProcessorDefinitionHelper.getRouteId(definition);
    String exchangeId = exchange.getExchangeId();
    String messageAsXml = MessageHelper.dumpAsXml(exchange.getIn(), true, 2, isBodyIncludeStreams(), isBodyIncludeFiles(), getBodyMaxChars());
    long uid = debugCounter.incrementAndGet();

    BacklogTracerEventMessage msg = new DefaultBacklogTracerEventMessage(uid, timestamp, routeId, toNode, exchangeId, messageAsXml);
    suspendedBreakpointMessages.put(toNode, msg);

    // suspend at this breakpoint
    SuspendedExchange se = new SuspendedExchange(exchange, new CountDownLatch(1));
    suspendedBreakpoints.put(toNode, se);

    // now wait until we should continue
    logger.log("StepBreakpoint at node " + toNode + " is waiting to continue for exchangeId: " + exchange.getExchangeId());
    try {
        boolean hit = se.getLatch().await(fallbackTimeout, TimeUnit.SECONDS);
        if (!hit) {
            logger.log("StepBreakpoint at node " + toNode + " timed out and is continued exchangeId: " + exchange.getExchangeId(), LoggingLevel.WARN);
        } else {
            logger.log("StepBreakpoint at node " + toNode + " is continued exchangeId: " + exchange.getExchangeId());
        }
    } catch (InterruptedException e) {
        // ignore
    }
}
项目:Camel    文件:TypeConverterRegistryTest.java   
public void testAddDuplicateTypeConverterIgnore() {
    DefaultCamelContext context = new DefaultCamelContext();
    context.getTypeConverterRegistry().setTypeConverterExists(TypeConverterExists.Ignore);
    context.getTypeConverterRegistry().setTypeConverterExistsLoggingLevel(LoggingLevel.INFO);

    context.getTypeConverterRegistry().addTypeConverter(MyOrder.class, String.class, new MyOrderTypeConverter());
    context.getTypeConverterRegistry().addTypeConverter(MyOrder.class, String.class, new MyOrderTypeConverter());
}
项目:Camel    文件:ManagedErrorHandler.java   
public void setRetriesExhaustedLogLevel(String level) {
    if (!isSupportRedelivery()) {
        throw new IllegalArgumentException("This error handler does not support redelivery");
    }

    RedeliveryErrorHandler redelivery = (RedeliveryErrorHandler) errorHandler;
    redelivery.getRedeliveryPolicy().setRetriesExhaustedLogLevel(LoggingLevel.valueOf(level));
}
项目:Camel    文件:ManagedErrorHandler.java   
public void setRetryAttemptedLogLevel(String level) {
    if (!isSupportRedelivery()) {
        throw new IllegalArgumentException("This error handler does not support redelivery");
    }

    RedeliveryErrorHandler redelivery = (RedeliveryErrorHandler) errorHandler;
    redelivery.getRedeliveryPolicy().setRetryAttemptedLogLevel(LoggingLevel.valueOf(level));
}
项目:Camel    文件:MllpTcpClientProducerTest.java   
@Override
protected RouteBuilder createRouteBuilder() {

    return new RouteBuilder() {
        int connectTimeout = 1000;
        int responseTimeout = 1000;

        @Override
        public void configure() throws Exception {
            errorHandler(
                    defaultErrorHandler().allowRedeliveryWhileStopping(false));

            onException(MllpCorruptFrameException.class)
                    .handled(true)
                    .logHandled(false)
                    .to(frame);

            onException(MllpTimeoutException.class)
                    .handled(true)
                    .logHandled(false)
                    .to(timeout);

            onCompletion()
                    .onFailureOnly().log(LoggingLevel.ERROR, "Processing Failed");

            from(source.getDefaultEndpoint())
                    .routeId("mllp-sender-test-route")
                    .log(LoggingLevel.INFO, "Sending Message: $simple{header[CamelHL7MessageControl]}")
                    .toF("mllp://%s:%d?connectTimeout=%d&receiveTimeout=%d",
                            mllpServer.getListenHost(), mllpServer.getListenPort(), connectTimeout, responseTimeout)
                    .to(acknowledged);

            from("direct://handle-timeout")
                    .log(LoggingLevel.ERROR, "Response Timeout")
                    .rollback();

        }
    };

}
项目:Camel    文件:TracerConfigurationTest.java   
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        public void configure() throws Exception {
            Tracer tracer = new Tracer();
            tracer.setLogLevel(LoggingLevel.ERROR);
            tracer.setLogName("com.mycompany");

            getContext().addInterceptStrategy(tracer);

            from("direct:start").to("mock:result");
        }
    };
}
项目:Camel    文件:LogProcessorWithProvidedLoggerTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            from("direct:foo").routeId("foo").log(LoggingLevel.INFO, "Got ${body}").to("mock:foo");
            from("direct:bar").routeId("bar").log(LoggingLevel.INFO, LoggerFactory.getLogger("org.apache.camel.customlogger"), "Also got ${body}").to("mock:bar");
        }
    };
}
项目:Camel    文件:HttpServerChannelHandler.java   
/**
 * Authenticates the http basic auth subject.
 *
 * @param authenticator      the authenticator
 * @param principal          the principal
 * @return <tt>true</tt> if username and password is valid, <tt>false</tt> if not
 */
protected Subject authenticate(SecurityAuthenticator authenticator, LoggingLevel deniedLoggingLevel, HttpPrincipal principal) {
    try {
        return authenticator.login(principal);
    } catch (LoginException e) {
        CamelLogger logger = new CamelLogger(LOG, deniedLoggingLevel);
        logger.log("Cannot login " + principal.getName() + " due " + e.getMessage(), e);
    }
    return null;
}
项目:Camel    文件:MllpTcpClientProducerAcknowledgementTest.java   
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
    return new RouteBuilder() {
        String routeId = "mllp-sender";

        public void configure() {
            onException(MllpApplicationRejectAcknowledgementException.class)
                    .handled(true)
                    .to(reject)
                    .log(LoggingLevel.ERROR, routeId, "AR Acknowledgement");

            onException(MllpApplicationErrorAcknowledgementException.class)
                    .handled(true)
                    .to(error)
                    .log(LoggingLevel.ERROR, routeId, "AE Acknowledgement");

            onCompletion()
                    .onCompleteOnly()
                    .to(complete)
                    .log(LoggingLevel.DEBUG, routeId, "AA Acknowledgement");

            from(source.getDefaultEndpoint()).routeId(routeId)
                    .log(LoggingLevel.INFO, routeId, "Sending Message")
                    .toF("mllp://%s:%d", mllpServer.getListenHost(), mllpServer.getListenPort())
                    .log(LoggingLevel.INFO, routeId, "Received Acknowledgement")
                    .to(accept);
        }
    };
}
项目:Camel    文件:RedeliveryErrorHandlerLogHandledTest.java   
public void testRedeliveryErrorHandlerOnExceptionAllOptions() throws Exception {
    context.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            onException(IllegalArgumentException.class)
                .maximumRedeliveries(3)
                .logHandled(true)
                .logRetryAttempted(true)
                .logRetryStackTrace(true)
                .logExhausted(true)
                .logStackTrace(true)
                .handled(true)
                .retryAttemptedLogLevel(LoggingLevel.WARN)
                .retriesExhaustedLogLevel(LoggingLevel.ERROR)
                .to("mock:handled");

            from("direct:foo")
                .throwException(new IllegalArgumentException("Damn"));
        }
    });
    context.start();

    getMockEndpoint("mock:handled").expectedBodiesReceived("Hello World");

    template.sendBody("direct:foo", "Hello World");

    assertMockEndpointsSatisfied();
}