org.apache.camel.LoggingLevel Java Examples
The following examples show how to use
org.apache.camel.LoggingLevel.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: UseCaseRoute.java From camelinaction2 with Apache License 2.0 | 6 votes |
@Override public void configure() throws Exception { getContext().setTracing(true); // general error handler errorHandler(defaultErrorHandler() .maximumRedeliveries(5) .redeliveryDelay(2000) .retryAttemptedLogLevel(LoggingLevel.WARN)); // in case of a http exception then retry at most 3 times // and if exhausted then upload using ftp instead onException(IOException.class, HttpOperationFailedException.class) .maximumRedeliveries(3) .handled(true) .to(ftp); // poll files send them to the HTTP server from(file).to(http); }
Example #2
Source File: JmxNamingContextCamelApplication.java From camel-cookbook-examples with Apache License 2.0 | 6 votes |
public void setup() throws Exception { context = new DefaultCamelContext(); context.setNameStrategy(new ExplicitCamelContextNameStrategy("myCamelContextName")); // Add a simple test route context.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start") .routeId("first-route") .log(LoggingLevel.INFO, "First Route", "${body}") .to("mock:result"); from("direct:startOther") .routeId("other-route") .log(LoggingLevel.INFO, "Other Route", "${body}") .to("mock:resultOther"); } }); }
Example #3
Source File: LogProfileIntegrationTest.java From wildfly-camel with Apache License 2.0 | 6 votes |
@Test public void testWildFlyLogProfile() throws Exception { CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start") .log(LoggingLevel.DEBUG, LoggerFactory.getLogger(LogProfileIntegrationTest.class.getName()), "Hello ${body}"); } }); camelctx.start(); try { ProducerTemplate producer = camelctx.createProducerTemplate(); producer.requestBody("direct:start", "Kermit"); assertLogFileContainsContent(".*LogProfileIntegrationTest.*Hello Kermit$"); } finally { camelctx.close(); } }
Example #4
Source File: CamelSourceTaskTest.java From camel-kafka-connector with Apache License 2.0 | 6 votes |
@Test public void testSourcePolling() { final long size = 2; Map<String, String> props = new HashMap<>(); props.put(CamelSourceConnectorConfig.TOPIC_CONF, TOPIC_NAME); props.put(CamelSourceConnectorConfig.CAMEL_SOURCE_URL_CONF, DIRECT_URI); CamelSourceTask sourceTask = new CamelSourceTask(); sourceTask.start(props); sendBatchOfRecords(sourceTask, size); List<SourceRecord> poll = sourceTask.poll(); assertEquals(size, poll.size()); assertEquals(TOPIC_NAME, poll.get(0).topic()); assertEquals(LoggingLevel.OFF.toString(), sourceTask.getCamelSourceConnectorConfig(props) .getString(CamelSourceConnectorConfig.CAMEL_SOURCE_CONTENT_LOG_LEVEL_CONF)); sourceTask.stop(); }
Example #5
Source File: DefaultErrorHandlerTest.java From camelinaction with Apache License 2.0 | 6 votes |
@Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { // context.setTracing(true); errorHandler(defaultErrorHandler() .maximumRedeliveries(2) .redeliveryDelay(1000) .retryAttemptedLogLevel(LoggingLevel.WARN)); from("seda:queue.inbox") .beanRef("orderService", "validate") .beanRef("orderService", "enrich") .log("Received order ${body}") .to("mock:queue.order"); } }; }
Example #6
Source File: LogEipRoute.java From camel-cookbook-examples with Apache License 2.0 | 6 votes |
@Override public void configure() throws Exception { from("direct:start") .routeId("LogEipRoute") .log("Something interesting happened - ${body}") .to("mock:result"); from("direct:startLevel") .routeId("LogEipInfoLevelRoute") .log(LoggingLevel.INFO, "Something informational happened - ${body}") .to("mock:result"); from("direct:startName") .routeId("LogEipCustomLogNameRoute") .log(LoggingLevel.INFO, "MyName", "Something myName happened - ${body}") .to("mock:result"); }
Example #7
Source File: LoggingRoute.java From camel-cookbook-examples with Apache License 2.0 | 6 votes |
@Override public void configure() throws Exception { errorHandler(loggingErrorHandler() .logName("MyLoggingErrorHandler") .level(LoggingLevel.ERROR) ); from("direct:start").bean(FlakyProcessor.class).to("mock:result"); from("direct:routeSpecific") .errorHandler(loggingErrorHandler() .logName("MyRouteSpecificLogging") .level(LoggingLevel.ERROR)) .bean(FlakyProcessor.class) .to("mock:result"); }
Example #8
Source File: AccountChangedCamelRoute.java From eda-tutorial with Apache License 2.0 | 6 votes |
@Override public void configure() throws Exception { from(String.format("amqps:account-topic")) .routeId("account-changed-route") .transacted() .log(LoggingLevel.INFO, "Received Account message ${id}") .process(e -> { String stringValue = e.getIn().getBody(String.class); JSONObject jsonObject = new JSONObject(stringValue); e.getIn().setBody(AccountChangedEvent.of(jsonObject)); }) .process(e -> { AccountChangedEvent event = e.getIn().getBody(AccountChangedEvent.class); AccountNumber accountNumber = event.getAccountNumber(); Account account = accountRepository.findByAccountNumber(accountNumber) .orElseGet(() -> accountRepository.save(Account.of(accountNumber))); account.accept(event); }); }
Example #9
Source File: OutboundErrorRoute.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public void configure() throws Exception { // no problems from("activiti: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("activiti:ErrorHandling:ProvokeError").routeId("error").log(LoggingLevel.INFO, "Provoked error").beanRef("brokenService") // <-- // throws // Exception .to("seda:inbound"); // always fails with specific error handler: exception is not propagated // back from("activiti:ErrorHandling:HandleError").routeId("errorWithDlq").errorHandler(deadLetterChannel("seda:dlq")).log(LoggingLevel.INFO, "Provoked error").beanRef("brokenService") // <-- // throws // Exception .to("seda:inbound"); }
Example #10
Source File: OutboundErrorRoute.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@Override public void configure() throws Exception { // no problems from("activiti: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("activiti:ErrorHandling:ProvokeError").routeId("error").log(LoggingLevel.INFO, "Provoked error").beanRef("brokenService") // <-- // throws // Exception .to("seda:inbound"); // always fails with specific error handler: exception is not propagated // back from("activiti:ErrorHandling:HandleError").routeId("errorWithDlq").errorHandler(deadLetterChannel("seda:dlq")).log(LoggingLevel.INFO, "Provoked error").beanRef("brokenService") // <-- // throws // Exception .to("seda:inbound"); }
Example #11
Source File: DecanterTraceEventHandlerTest.java From karaf-decanter with Apache License 2.0 | 6 votes |
private DefaultCamelContext createCamelContext(TraceEventHandler handler) throws Exception { RouteBuilder builder = new RouteBuilder() { @Override public void configure() throws Exception { from("direct:start").routeId("test-route").to("log:foo"); } }; DefaultCamelContext camelContext = new DefaultCamelContext(); camelContext.setName("test-context"); camelContext.addRoutes(builder); Tracer tracer = new Tracer(); tracer.setEnabled(true); tracer.setTraceOutExchanges(true); tracer.setLogLevel(LoggingLevel.OFF); tracer.addTraceHandler(handler); camelContext.setTracing(true); camelContext.setDefaultTracer(tracer); camelContext.start(); return camelContext; }
Example #12
Source File: OutboundErrorRoute.java From flowable-engine with Apache License 2.0 | 6 votes |
@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"); }
Example #13
Source File: HelloRoute.java From camelinaction2 with Apache License 2.0 | 6 votes |
@Override public void configure() throws Exception { // use retry pattern to retry calling the hello service // perform up till 5 retries with 3 second delay, // and log at INFO level when an attempt is performed errorHandler(defaultErrorHandler() .retryAttemptedLogLevel(LoggingLevel.INFO) .maximumRedeliveries(5) .redeliveryDelay(3000)); // use synchronous so we only have one concurrent thread from the timer from("timer:foo?period=2000&synchronous=true") // call the service using {{service:name}} .to("netty4-http://{{service:helloswarm-kubernetes}}?disconnect=true&keepAlive=false") .log("${body}"); }
Example #14
Source File: DefaultErrorHandlerAsyncTest.java From camelinaction with Apache License 2.0 | 6 votes |
@Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { // context.setTracing(true); errorHandler(defaultErrorHandler() // enable async redelivery mode (pay attention to thread names in console output) .asyncDelayedRedelivery() .maximumRedeliveries(2) .redeliveryDelay(1000) .retryAttemptedLogLevel(LoggingLevel.WARN)); from("seda:queue.inbox") .beanRef("orderService", "validate") .beanRef("orderService", "enrich") .log("Received order ${body}") .to("mock:queue.order"); } }; }
Example #15
Source File: DefaultErrorHandlerTest.java From camelinaction2 with Apache License 2.0 | 6 votes |
@Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { // context.setTracing(true); errorHandler(defaultErrorHandler() .maximumRedeliveries(2) .redeliveryDelay(1000) .retryAttemptedLogLevel(LoggingLevel.WARN)); from("seda:queue.inbox") .bean("orderService", "validate") .bean("orderService", "enrich") .log("Received order ${body}") .to("mock:queue.order"); } }; }
Example #16
Source File: InboundErrorRoute.java From flowable-engine with Apache License 2.0 | 5 votes |
@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 ..."); }
Example #17
Source File: EventRouter.java From fcrepo-camel-toolbox with Apache License 2.0 | 5 votes |
/** * Configure the message route workflow. */ public void configure() throws Exception { /** * A generic error handler (specific to this RouteBuilder) */ onException(Exception.class) .maximumRedeliveries("{{error.maxRedeliveries}}") .log("Event Routing Error: ${routeId}"); /** * Process a message. */ from("{{input.stream}}") .routeId("AuditFcrepoRouter") .process(new EventProcessor()) .filter(not(in(tokenizePropertyPlaceholder(getContext(), "{{filter.containers}}", ",").stream() .map(uri -> or( header(FCREPO_URI).startsWith(constant(uri + "/")), header(FCREPO_URI).isEqualTo(constant(uri)))) .collect(toList())))) .to("direct:event"); from("direct:event") .routeId("AuditEventRouter") .setHeader(AuditHeaders.EVENT_BASE_URI, simple("{{event.baseUri}}")) .process(new AuditSparqlProcessor()) .log(LoggingLevel.INFO, "org.fcrepo.camel.audit", "Audit Event: ${headers.CamelFcrepoUri} :: ${headers[CamelAuditEventUri]}") .to("{{triplestore.baseUrl}}?useSystemProperties=true"); }
Example #18
Source File: OutboundErrorRoute.java From flowable-engine with Apache License 2.0 | 5 votes |
@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"); }
Example #19
Source File: CamelVariableBodyTest.java From flowable-engine with Apache License 2.0 | 5 votes |
@BeforeEach 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(); }
Example #20
Source File: FailoverInheritErrorHandlerLoadBalancerTest.java From camelinaction with Apache License 2.0 | 5 votes |
@Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @Override public void configure() throws Exception { // configure error handler to try at most 3 times with 2 sec delay errorHandler(defaultErrorHandler() .maximumRedeliveries(3).redeliveryDelay(2000) // reduce some logging noise .retryAttemptedLogLevel(LoggingLevel.WARN) .retriesExhaustedLogLevel(LoggingLevel.WARN) .logStackTrace(false)); from("direct:start").routeId("start") // use load balancer with failover strategy // 1 = which will try 1 failover attempt before exhausting // true = do use Camel error handling // false = do not use round robin mode .loadBalance().failover(1, true, false) // will send to A first, and if fails then send to B afterwards .to("direct:a").to("direct:b") .end(); // service A from("direct:a") .log("A received: ${body}") .to("mock:a"); // service B from("direct:b") .log("B received: ${body}") .to("mock:b"); } }; }
Example #21
Source File: LogStepHandlerTest.java From syndesis with Apache License 2.0 | 5 votes |
@Test public void shouldAddLogProcessorWithCustomMessageAndStepId() { final Step step = new Step.Builder().id("step-id") .putConfiguredProperty("customText", "Log me baby one more time").build(); assertThat(handler.handle(step, route, NOT_USED, "1", "2")).contains(route); verify(route).log(LoggingLevel.INFO, (String) null, "step-id", "Log me baby one more time"); }
Example #22
Source File: LogStepHandlerTest.java From syndesis with Apache License 2.0 | 5 votes |
@Test public void shouldAddLogProcessorWithCustomMessage() { final Step step = new Step.Builder().putConfiguredProperty("customText", "Log me baby one more time").build(); assertThat(handler.handle(step, route, NOT_USED, "1", "2")).contains(route); verify(route).log(LoggingLevel.INFO, "Log me baby one more time"); }
Example #23
Source File: ActivityLoggingTest.java From syndesis with Apache License 2.0 | 5 votes |
@Override protected RoutesBuilder createTestRoutes() { return new RouteBuilder() { @Override public void configure() { from("direct:start") .id("start") .routePolicy(new IntegrationActivityTrackingPolicy(activityTracker)) .setHeader(IntegrationLoggingConstants.STEP_ID, KeyGenerator::createKey) .pipeline() .id("step:log") .setHeader(IntegrationLoggingConstants.STEP_ID, KeyGenerator::createKey) .log(LoggingLevel.INFO, "log", "log", "hi") .process(OutMessageCaptureProcessor.INSTANCE) .end() .pipeline() .id("step:rnderr") .setHeader(IntegrationLoggingConstants.STEP_ID, KeyGenerator::createKey) .process().body(String.class, body -> { if ("Hello Error".equals(body)) { throw new RuntimeException("Bean Error"); } }) .process(OutMessageCaptureProcessor.INSTANCE) .end() .pipeline() .id("step:end") .setHeader(IntegrationLoggingConstants.STEP_ID, KeyGenerator::createKey) .to("mock:end") .process(OutMessageCaptureProcessor.INSTANCE) .end(); } }; }
Example #24
Source File: MllpTcpServerConsumerTest.java From wildfly-camel with Apache License 2.0 | 5 votes |
@Test public void testReceiveSingleMessage() throws Exception { mllpClient.setMllpHost("localhost"); mllpClient.setMllpPort(AvailablePortFinder.getNextAvailable()); CamelContext camelctx = new DefaultCamelContext(); camelctx.addRoutes(new RouteBuilder() { int connectTimeout = 500; int responseTimeout = 5000; @Override public void configure() throws Exception { String routeId = "mllp-test-receiver-route"; fromF("mllp://%s:%d?autoAck=true&connectTimeout=%d&receiveTimeout=%d&reuseAddress=true", mllpClient.getMllpHost(), mllpClient.getMllpPort(), connectTimeout, responseTimeout) .routeId(routeId) .log(LoggingLevel.INFO, routeId, "Test route received message") .to("mock:result"); } }); MockEndpoint mock = camelctx.getEndpoint("mock:result", MockEndpoint.class); mock.expectedMessageCount(1); camelctx.start(); try { mllpClient.connect(); mllpClient.sendMessageAndWaitForAcknowledgement(Hl7MessageGenerator.generateMessage(), 10000); MockEndpoint.assertIsSatisfied(10, TimeUnit.SECONDS, mock); } finally { mllpClient.disconnect(); camelctx.close(); } }
Example #25
Source File: LogStepHandler.java From syndesis with Apache License 2.0 | 5 votes |
@Override public Optional<ProcessorDefinition<?>> handle(Step step, ProcessorDefinition<?> route, IntegrationRouteBuilder builder, String flowIndex, String stepIndex) { final String message = createMessage(step); if (message.isEmpty()) { return Optional.empty(); } if (step.getId().isPresent()) { String stepId = step.getId().get(); return Optional.of(route.log(LoggingLevel.INFO, (String) null, stepId, message)); } return Optional.of(route.log(LoggingLevel.INFO, message)); }
Example #26
Source File: SendRequestResponseRoute.java From container with Apache License 2.0 | 5 votes |
@Override public void configure() throws Exception { // MQTT endpoint where this route publishes messages final String producerEndpoint = "mqtt:send?host=${header." + MBHeader.MQTTBROKERHOSTNAME_STRING.toString() + "}&userName=" + this.username + "&password=" + this.password + "&publishTopicName=${header." + MBHeader.MQTTTOPIC_STRING.toString() + "}&qualityOfService=ExactlyOnce"; // print broker host name and topic for incoming messages final String loggerMessage = "Sending Exchange to MQTT topic. Host: ${header." + MBHeader.MQTTBROKERHOSTNAME_STRING.toString() + "} Topic: ${header." + MBHeader.MQTTTOPIC_STRING.toString() + "}"; // print broker host name and topic for incoming messages final String exception = "Unable to marshal given object. Exchange will not be send!"; // JAXB definitions to marshal the outgoing message body final ClassLoader classLoader = ObjectFactory.class.getClassLoader(); final JAXBContext jc = JAXBContext.newInstance("org.opentosca.bus.management.service.impl.collaboration.model", classLoader); final JaxbDataFormat jaxb = new JaxbDataFormat(jc); // extracts exchange headers and adds them to the marshaled object final Processor outgoingProcessor = new OutgoingProcessor(); // @formatter:off this.from("direct:SendMQTT") .log(LoggingLevel.DEBUG, LoggerFactory.getLogger(SendRequestResponseRoute.class), loggerMessage) .process(outgoingProcessor) .doTry() .marshal(jaxb) .recipientList(this.simple(producerEndpoint)) .endDoTry() .doCatch(Exception.class) .log(LoggingLevel.ERROR, LoggerFactory.getLogger(SendRequestResponseRoute.class), exception) .end(); }
Example #27
Source File: InboundErrorRoute.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void configure() throws Exception { from("seda:inbound").routeId("inbound") // give Activiti some time to reach synchronization point .bean(TimeConsumingService.class).log(LoggingLevel.INFO, "Returning result ...").to("activiti:ErrorHandling:ReceiveResult"); from("seda:dlq").routeId("dlq").log(LoggingLevel.INFO, "Error handled by camel ..."); }
Example #28
Source File: CamelVariableBodyTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void setUp() throws Exception { camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("activiti:HelloCamel:serviceTask1").log(LoggingLevel.INFO, "Received message on service task").to("mock:serviceBehavior"); } }); service1 = (MockEndpoint) camelContext.getEndpoint("mock:serviceBehavior"); service1.reset(); }
Example #29
Source File: CamelVariableBodyMapTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public void setUp() throws Exception { camelContext.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("activiti:HelloCamel:serviceTask1").log(LoggingLevel.INFO, "Received message on service task").to("mock:serviceBehavior"); } }); service1 = (MockEndpoint) camelContext.getEndpoint("mock:serviceBehavior"); service1.reset(); }
Example #30
Source File: InboundErrorRoute.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Override public void configure() throws Exception { from("seda:inbound").routeId("inbound") // give Activiti some time to reach synchronization point .bean(TimeConsumingService.class).log(LoggingLevel.INFO, "Returning result ...").to("activiti:ErrorHandling:ReceiveResult"); from("seda:dlq").routeId("dlq").log(LoggingLevel.INFO, "Error handled by camel ..."); }