Using version 2.14.0 - First time i've used Camel, so excuse if this is obvious 
- but I'm having some difficulties getting the first step of the ReportIncident 
tutorial working. Seems there have been some recent changes to the LogEndpoint 
(see CAMEL-7599) - might have affected this example :-

http://camel.apache.org/tutorial-example-reportincident-part2.html

I had to modify sendToCamelLog as per below to get it working - call 
endpoint.setProvidedLogger(..) as well as endpoint.start() ..  

Does this point to a bug or does the example require updating ?

Thx Jon
================
   private void sendToCamelLog(String name) {
        try {
            // get the log component
            Component component = camel.getComponent("log");

            // create an endpoint and configure it.
            // Notice the URI parameters this is a common pratice in Camel to 
configure
            // endpoints based on URI.
            // com.mycompany.part2 = the log category used. Will log at INFO 
level as default
            LogEndpoint endpoint = (LogEndpoint) 
component.createEndpoint("log:org.apache.camel.example?level=DEBUG");
//            endpoint.setCamelContext(camel);
            
endpoint.setProvidedLogger(LoggerFactory.getLogger(ReportIncidentEndpointImpl.class));
            endpoint.start();
            // create an Exchange that we want to send to the endpoint
            Exchange exchange = endpoint.createExchange();
            // set the in message payload (=body) with the name parameter
            exchange.getIn().setBody(name);

            // now we want to send the exchange to this endpoint and we then 
need a producer
            // for this, so we create and start the producer.
            Producer producer = endpoint.createProducer();
            producer.start();
            // process the exchange will send the exchange to the log 
component, that will process
            // the exchange and yes log the payload
            producer.process(exchange);

            // Exception was being generated during processing, but not thrown.
            Exception exc = exchange.getException();
            if (exc != null) throw exc;

            // stop the producer, we want to be nice and cleanup
            producer.stop();


        } catch (Exception e) {
            // we ignore any exceptions and just rethrow as runtime          
            throw new RuntimeException(e);

        }
    }




Jonathan Jenkins
+44 7789 847427
j...@java2go.com <mailto:jon.jenk...@tradingscreen.com>

Reply via email to