Error Handling

Configuration

Set up Default Error Handler

To change the behavior of the default error handler, put the following properties into application.properties. 

Property

Since

Default Value

Description

Property

Since

Default Value

Description

integration.route-error-handling.enabled

 

true

Sets whether the defaultErrorHandler bean should be created or not.

integration.route-error-handling.maximumRedeliveries

 

10

Sets the maximum number of times a message exchange will be redelivered. Setting a negative value will retry forever.

integration.route-error-handling.redeliveryDelay

 

2000

Sets the initial redelivery delay in milliseconds.

integration.route-error-handling.maximumRedeliveryDelay



300000

Sets the maximum redelivery delay in milliseconds. Use -1 if you wish to have no maximum.

integration.route-error-handling.useExponentialBackOff

 

true

Enables/disables exponential backoff using the integration.route-error-handling.back-off-multiplier to increase the time between retries.

integration.route-error-handling.backOffMultiplier

 

2.0

Sets the multiplier used to increase the delay between redeliveries if exponential backoff is enabled.

integration.route-error-handling.logHandled

 

true

Sets whether errors should be logged even if they are handled.

integration.route-error-handling.retryAttemptedLogLevel



INFO

Sets the logging level to use for log messages when retries are attempted. Possible values are: TRACE, DEBUG, INFO, WARN, ERROR, OFF.

integration.route-error-handling.logRetryAttempted

 

true

Sets whether retry attempts should be logged or not.

integration.route-error-handling.logStackTrace

 

true

Sets whether stack traces should be logged or not.

integration.route-error-handling.retry.exceptions

1.1.17

net.pricefx.integration.api.RecoverableException,

org.apache.http.conn.ConnectTimeoutException,

java.net.ConnectException

A comma-separated list of fully qualified class names of exceptions that should be redelivered. If option integration.route-error-handling.retry.override-defaults is:

  • false (default) – Configured exceptions are appended to the default exceptions list.

  • true – Configured exceptions override default exceptions.

This property is used with the DefaultRetryWhilePredicate component.

integration.route-error-handling.retry.httpStatus

1.1.17

409, 503, 504

A comma-separated list of HTTP response status codes that should be redelivered. If option integration.route-error-handling.retry.override-defaults is:

  • false (default) –Configured HTTP response status codes are appended to the default status codes list.

  • true – Configured HTTP response status codes override the default status codes list.

This property is used with the DefaultRetryWhilePredicate component.

integration.route-error-handling.retry.overrideDefaults

1.1.17

false

Sets whether default values of exceptions and HTTP status codes should be overridden.

This property is used with the DefaultRetryWhilePredicate component.

integration.route-error-handling.enableSendingMail

up to 1.1.17

false

Sets whether an email should be sent in case of an error.

integration.route-error-handling.enable-sending-mail

1.1.18

integration.route-error-handling.email.smtpHost

 

localhost

Sets the SMTP hostname.

integration.route-error-handling.email.smtPort

 

25

Sets the SMTP port.

integration.route-error-handling.email.smtpAuth

 

false

Sets whether authentication for SMTP should be used.

integration.route-error-handling.email.smtpAuthUsername

 

 

Sets the username for SMTP authentication.

integration.route-error-handling.email.smtpAuthPassword

 

 

Sets the password for SMTP authentication.

integration.route-error-handling.email.smtp-ssl

 

false

Sets the info about usage of SSL in communication with SMPT host.

integration.route-error-handling.email.mailFrom



integration@pricefx.eu

Sets the email sender.

Current convention in IM team: integration_<pfx.partition>@pricefx.eu

integration.route-error-handling.email.mailTo



integration@pricefx.eu

Sets the email recipients. Multiple addresses are separated with a semicolon ';'.

Current convention in IM team:

  • For PROD partition: <IE email>;integration@pricefx.eu

  • For QA, DEV partition: <IE email>

integration.route-error-handling.email.mailSubject



Camel processing error!

Sets the subject of the email.

integration.route-error-handling.email.emailContentTemplate

1.1.18

email/default-email-template.vm

(internal template)

Sets a template for the error email body.
e.g. integration.route-error-handling.email.email-content-template=file:///Users/johndoe/workspace/pricefx/pricefx-integration-commons/config/email-template/my-template.vm

integration.route-error-handling.email.aggregation.enabled

1.9.0

false

Sets whether the aggregation of error messages is enabled or not.

integration.route-error-handling.email.aggregation.checkPeriodInSeconds

1.9.0

600

Sets the period (in seconds) in which another check of errors to aggregate will be performed.

integration.route-error-handling.email.aggregation.aggregateErrorSize

1.9.0

0

Defines the size of the error message which will be used as an input key of the aggregation.
If default 0 is set, the first line of the error is used for aggregation. Otherwise the defined size of an error (including detailed error message) is used for the aggregation.

integration.route-error-handling.email.aggregation.similarityErrors

1.9.0

1.0

Specifies similarity of the errors. The range of this value is from 0.0 to 1.0:

  • If the default value 1.0 is set, the aggregation requires a precise match of error messages.

integration.route-error-handling.email.aggregation.mailSubject

1.9.0

${integration.name} Summary integration processing report!

Sets the subject of the summary email.

integration.route-error-handling.email.aggregation.differentErrorTypes

1.9.0

10

Sets the count of different types of errors that will be stored in a memory. If this value is exceeded, the oldest type of an aggregate error is removed from the memory and the summary email is sent for this error.

integration.route-error-handling.email.smtpSslProtocols

4.10.10, 5.4.0

 

Specifies the SSL protocols that will be enabled for SSL connections. The property value is a whitespace separated list of tokens acceptable to the javax.net.ssl.SSLSocket.setEnabledProtocols method.

Configuration of the error handler is logged during IM startup. Example:

14:48:38.399 | INFO | main | | | n.p.i.a.core.CoreAutoConfiguration | Error Handling AutoConfiguration is [ENABLED] with configuration [RouteErrorHandlingProperties(enabled=true, maximumRedeliveryDelay=300000, maximumRedeliveries=10, retryAttemptedLogLevel=INFO, redeliveryDelay=2000, backOffMultiplier=2.0, useExponentialBackOff=true, logRetryAttempted=true, logHandled=true, logStackTrace=true, enableSendingMail=false, retry=RouteErrorHandlingProperties.Retry(overrideDefaults=false, exceptions=[class java.net.ConnectException, class net.pricefx.integration.api.RecoverableException, class org.apache.http.conn.ConnectTimeoutException], httpStatus=[503, 504]))] 14:48:38.404 | INFO | main | | | n.p.i.a.core.CoreAutoConfiguration | Email Error Listener AutoConfiguration is [DISABLED] with configuration [RouteErrorHandlingProperties.EmailProperties(smtpHost=localhost, smtpPort=25, smtpAuth=false, smtpAuthUsername=null, smtpAuthPassword=null, smtpSsl=false, mailFrom=integration@pricefx.eu, mailTo=[martin@pricefx.eu, kocour@pricefx.eu], mailSubject=Camel processing error!, emailContentTemplate=email/default-email-template.vm)]

Apply Default Error Handler to Camel Context

Use the defaultErrorHandler bean reference as the Camel context attribute.

<camelContext xmlns="http://camel.apache.org/schema/spring" useMDCLogging="true" errorHandlerRef="defaultErrorHandler">

How to Set Custom Error Email Template

  1. Create a Velocity template for an error email. E.g.:

    file:///Users/johndoe/workspace/pricefx/pricefx-integration-commons/config/email-template/my-template.vm

    Hello error template of exchange ${exchange.exchangeId} with body ${body} and headers ${headers} caused by ${exchange.properties.CamelExceptionCaught}

     

  2. Configure the error handler to use the custom template:

    application.properties

Error Messages Aggregation

  • There is a possibility to turn on the aggregation of error messages in order to prevent receiving a lot of the same error messages.

  • By default the aggregation is disabled. It is sufficient to set parameter integration.route-error-handling.email.aggregation.enabled=true to turn on the aggregation without setting other parameters if not needed.

  • All parameters of this aggregation including turning on the aggregation are mentioned in the table above with prefix: 

    application.properties

Failed Integration Jobs

All integration jobs (including scheduled integration jobs) are monitored and if they fail, Pricefx is notified by an email. The email can also be sent to the customer if required. The monitoring is per project where each IM has set up its own monitoring.

 

IntegrationManager version 5.8.0