Hi,

I managed to change the logging level to ERROR by configuring a custom 
exception handler:
from(jpa(MyEntity.class.getName())
    .consumeDelete(false)
    .query(QUERY)
    .delay(300000)
    .advanced().exceptionHandler(new LoggingExceptionHandler(getContext(), 
JpaConsumer.class, LoggingLevel.ERROR)))

I looked at how JPAConsumer creates an ExceptionHandler by default and specifed 
the logging level as ERROR.

This will affect the logging level of all Exceptions handled by the 
ExceptionHandler but I hope this will be a good enough solution in my specific 
case.

Regards,
Calle
________________________________
From: Claus Ibsen <claus.ib...@gmail.com>
Sent: Sunday, February 20, 2022 1:00:24 PM
To: users@camel.apache.org <users@camel.apache.org>
Subject: Re: JPA consumer logging

Hi

Thanks for the logging output. No you cannot change the logging level
- it's hard coded in the jpa consumer.

On Thu, Feb 17, 2022 at 9:41 AM Calle Andersson
<calleanders...@hotmail.com> wrote:
>
> Unfortunately I currently have limited access to the logs (I'm out of office) 
> but I think we only get the following in the log:
>
> WARN  [org.apache.camel.component.jpa.JpaConsumer] (Camel 
> (camelContext_myContext) thread #26 - jpa://dummy.MyEntity) Consumer 
> Consumer[jpa://dummy.MyEntity?consumeDelete=false&delay=300000&query=select+x+from+dummy.MyEntity+x+where+x.myProperty+%3D+%27N%27]
>  failed polling endpoint: 
> jpa://?dummy.MyEntity?consumeDelete=false&delay=300000&query=select+x+from+dummy.MyEntity+x+where+x.myProperty+%3D+%27N%27.
>  Will try again at next poll. Caused by: 
> [javax.persistence.PersistenceException - 
> javax.persistence.PersistenceException: 
> org.hibernate.PropertyAccessException: Null value was assigned to a property 
> [class dummy.MyEntity.myOtherProperty] of primitive type setter of 
> dummy.MyEntity.myOtherProperty]: javax.persistence.PersistenceException: 
> javax.persistence.PersistenceException: 
> org.hibernate.PropertyAccessException: Null value was assigned to a property 
> [class .dummy.MyEntity.myOtherValue] of primitive type setter of 
> dummy.MyEntity.myOtherValue
> ...
> Caused by: javax.persistence.PersistenceException: 
> org.hibernate.PropertyAccessException: Null value was assigned to a property 
> [class dummy.MyEntity.myOtherValue] of primitive type setter of 
> dummy.MyEntity.myOtherValue
> ...
> Caused by: org.hibernate.PropertyAccessException: Null value was assigned to 
> a property [class dummy.MyEntity.myOtherValue] of primitive type setter of 
> dummy.MyEntity.myOtherValue
> ...
> Caused by: java.lang.IllegalArgumentException: Can not set int field 
> dummy.MyEntity.myOtherValue to null value
>
> Regards,
> Calle
>
> ________________________________
> Från: Claus Ibsen <claus.ib...@gmail.com>
> Skickat: onsdag 16 februari 2022 14:58
> Till: users@camel.apache.org
> Ämne: Re: JPA consumer logging
>
> Hi
>
> Is it this WARN log you see?
>
> LOG.warn(
>         "Error processing last message due: {}. Will commit all
> previous successful processed message, and ignore this last failure.",
>         cause.getMessage(), cause);
>
>
> On Tue, Feb 15, 2022 at 3:28 PM Calle Andersson
> <calleanders...@hotmail.com> wrote:
> >
> > Hi,
> >
> > I recently discovered that the JPA consumer only logs WARN when failing to 
> > populate an entity class (in my specific case, an exception occurred since 
> > an unexpected null couldn’t be mapped to an int).
> >
> > If I understand it correctly, the JPA consumer uses a 
> > LoggingExceptionHandler. Is there a simple way of configuring it to log 
> > exceptions as ERROR instead of WARN as default?
> >
> > I use Camel 3.4 and my route is configured in a Java class which extends 
> > EndpointRouteBuilder:
> > from(jpa(MyEntity.class.getName())
> >     .consumeDelete(false)
> >     .query(QUERY)
> >     .delay(300000))
> >     .transacted()
> >     // …
> >
> > Some JPA component configuration is also made in jboss-camel-context.xml:
> > <bean id="jpa" class="org.apache.camel.component.jpa.JpaComponent">
> >     <property name="entityManagerFactory" ref="entityManagerFactory" />
> >     <property name="transactionManager" ref="txManager" />
> > </bean>
> >
> > Regards,
> > Calle
>
>
>
> --
> Claus Ibsen
> -----------------
> http://davsclaus.com @davsclaus
> Camel in Action 2: https://www.manning.com/ibsen2
>


--
Claus Ibsen
-----------------
http://davsclaus.com @davsclaus
Camel in Action 2: https://www.manning.com/ibsen2

Reply via email to