You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Hilde <hi...@yahoo.de> on 2012/08/14 16:35:40 UTC

Exception in Exchange is null

Hello Readers!

Inside the route combined with the DefaultErrorHandler we are using
exception policies. 
When an exception is thrown that part is even called but the exception
object is null:

.onException(Exception.class).handled(true)
	.process(new Processor() {
	  @Override
	  public void process(Exchange exchange) throws Exception {
		exchange.getIn().setBody(exchange.getException()); // why exception is
null ???
	  }
	})
	.to("activemq:queue:" + JmsDestinations.QUEUE_LOG_SERVICE)
.end()

On the other side the jms consumer is used to take the exchange and finally
logs the stack trace via 
camel log component:

from("activemq:queue:" +
JmsDestinations.QUEUE_LOG_SERVICE).routeId("logServiceRoute")
       
.to("log:errorLog?level=ERROR&showAll=true&multiline=true&showStackTrace=true");

What is the right way to log the stack trace into the log file by the camel
log component? But
take into account that JMS is in use.

We are using version 2.10.0 .

Cheers
Hilde



--
View this message in context: http://camel.465427.n5.nabble.com/Exception-in-Exchange-is-null-tp5717324.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Exception in Exchange is null

Posted by Hilde <hi...@yahoo.de>.
Thanks, as I can read the camel log component exists in the first place to
log out the exchange object and not to log stack traces.



--
View this message in context: http://camel.465427.n5.nabble.com/Exception-in-Exchange-is-null-tp5717324p5717337.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Exception in Exchange is null

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

The log component has many options
http://camel.apache.org/log

See the showCaughtException option.


On Tue, Aug 14, 2012 at 5:28 PM, Hilde <hi...@yahoo.de> wrote:
> Thanks for you patient.
>
> Could you please give me some advice how we can log the stack trace
> subsequently? We
> are using the camel log component after the exchange was gone through JMS:
>
> log:errorLog?level=ERROR&showAll=true&multiline=true&showStackTrace=true
>
> However the output inside the file looks as follows:
>
> 2012-08-14 17:06:54,319 | ERROR | PIC_LOG_SERIVCE] | errorLog
> | Exchange[
> , Id:ID-E6520-030W7-55199-1344955353825-7-14
> , ExchangePattern:InOnly
> ,
> Properties:{CamelBinding=org.apache.camel.component.jms.JmsBinding@7ebf324,
> CamelToEndpoint=log://errorLog?level=ERROR&multiline=true&showAll=true&showStackTrace=true,
> CamelCreatedTimestamp=Tue Aug 14 17:06:54 CEST 2012,
> CamelExternalRedelivered=false}
> , Headers:{JMSDestination=queue://TOPIC_LOG_SERIVCE,
> VELO_LOAD_LOGDIR=c:\dn1\load\logs, VELO_SQLLDR=sqlldr,
> JMSTimestamp=1344956814308, VELO_LOAD_INSTALLDIR=c:\dn1\load,
> VELO_WORKDIR_REFDATA=c:\dn1\workingDir\08-2012\ref, JMSRedelivered=false,
> JMSCorrelationID=null, JMSPriority=4, JMSReplyTo=null,
> JMSMessageID=ID:E6520-030W7-55200-1344955354981-5:19:1:1:1,
> VELO_CONN_TRANSFORMDB_TLD=TLD/TLD@//esxelx0215:1521/TOC,
> CamelFileNameProduced=c:\dn1\load\sql\tld_delete_reference_data.sql,
> CamelRedeliveryCounter=0, VELO_FILE_SEP=\, JMSType=null,
> VELO_SQLPLUS=sqlplus, CamelRedelivered=false, CamelJmsDeliveryMode=2,
> IS_WINDOWS=true, breadcrumbId=ID:E6520-030W7-55200-1344955354981-5:2:1:1:3,
> JMSDeliveryMode=2, JMSExpiration=0, JMSXGroupID=null}
> , BodyType:IllegalStateException
> , Body:java.lang.IllegalStateException: Moving files failed!
> , Out: null
> ]
>
>
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Exception-in-Exchange-is-null-tp5717324p5717333.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Exception in Exchange is null

Posted by Hilde <hi...@yahoo.de>.
Thanks for you patient.

Could you please give me some advice how we can log the stack trace
subsequently? We
are using the camel log component after the exchange was gone through JMS:

log:errorLog?level=ERROR&showAll=true&multiline=true&showStackTrace=true

However the output inside the file looks as follows:

2012-08-14 17:06:54,319 | ERROR | PIC_LOG_SERIVCE] | errorLog                        
| Exchange[
, Id:ID-E6520-030W7-55199-1344955353825-7-14
, ExchangePattern:InOnly
,
Properties:{CamelBinding=org.apache.camel.component.jms.JmsBinding@7ebf324,
CamelToEndpoint=log://errorLog?level=ERROR&multiline=true&showAll=true&showStackTrace=true,
CamelCreatedTimestamp=Tue Aug 14 17:06:54 CEST 2012,
CamelExternalRedelivered=false}
, Headers:{JMSDestination=queue://TOPIC_LOG_SERIVCE,
VELO_LOAD_LOGDIR=c:\dn1\load\logs, VELO_SQLLDR=sqlldr,
JMSTimestamp=1344956814308, VELO_LOAD_INSTALLDIR=c:\dn1\load,
VELO_WORKDIR_REFDATA=c:\dn1\workingDir\08-2012\ref, JMSRedelivered=false,
JMSCorrelationID=null, JMSPriority=4, JMSReplyTo=null,
JMSMessageID=ID:E6520-030W7-55200-1344955354981-5:19:1:1:1,
VELO_CONN_TRANSFORMDB_TLD=TLD/TLD@//esxelx0215:1521/TOC,
CamelFileNameProduced=c:\dn1\load\sql\tld_delete_reference_data.sql,
CamelRedeliveryCounter=0, VELO_FILE_SEP=\, JMSType=null,
VELO_SQLPLUS=sqlplus, CamelRedelivered=false, CamelJmsDeliveryMode=2,
IS_WINDOWS=true, breadcrumbId=ID:E6520-030W7-55200-1344955354981-5:2:1:1:3,
JMSDeliveryMode=2, JMSExpiration=0, JMSXGroupID=null}
, BodyType:IllegalStateException
, Body:java.lang.IllegalStateException: Moving files failed!
, Out: null
]





--
View this message in context: http://camel.465427.n5.nabble.com/Exception-in-Exchange-is-null-tp5717324p5717333.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Exception in Exchange is null

Posted by Claus Ibsen <cl...@gmail.com>.
On Tue, Aug 14, 2012 at 4:58 PM, Hilde <hi...@yahoo.de> wrote:
> Thanks you Claus, but I have just checked that the exception object
> is still null even though handled(false) [default].
>

Yeah its null in both situations, as the error handler is kicking in.
handled = false, just mean that when the error handler is done, the
caused exception is restored and propagated back to the caller.

So you need to get the exception from the property.


>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Exception-in-Exchange-is-null-tp5717324p5717329.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Exception in Exchange is null

Posted by Hilde <hi...@yahoo.de>.
Thanks you Claus, but I have just checked that the exception object 
is still null even though handled(false) [default].



--
View this message in context: http://camel.465427.n5.nabble.com/Exception-in-Exchange-is-null-tp5717324p5717329.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Exception in Exchange is null

Posted by Claus Ibsen <cl...@gmail.com>.
The exception is null because you use handled(true).

If you want to get the caused exception, then its stored as a property
on the exchange.

Exception cause = exchange.getProperty(Exchange.CAUGHT_EXCEPTION,
Exception.class);



On Tue, Aug 14, 2012 at 4:35 PM, Hilde <hi...@yahoo.de> wrote:
> Hello Readers!
>
> Inside the route combined with the DefaultErrorHandler we are using
> exception policies.
> When an exception is thrown that part is even called but the exception
> object is null:
>
> .onException(Exception.class).handled(true)
>         .process(new Processor() {
>           @Override
>           public void process(Exchange exchange) throws Exception {
>                 exchange.getIn().setBody(exchange.getException()); // why exception is
> null ???
>           }
>         })
>         .to("activemq:queue:" + JmsDestinations.QUEUE_LOG_SERVICE)
> .end()
>
> On the other side the jms consumer is used to take the exchange and finally
> logs the stack trace via
> camel log component:
>
> from("activemq:queue:" +
> JmsDestinations.QUEUE_LOG_SERVICE).routeId("logServiceRoute")
>
> .to("log:errorLog?level=ERROR&showAll=true&multiline=true&showStackTrace=true");
>
> What is the right way to log the stack trace into the log file by the camel
> log component? But
> take into account that JMS is in use.
>
> We are using version 2.10.0 .
>
> Cheers
> Hilde
>
>
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Exception-in-Exchange-is-null-tp5717324.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen