spring-integration: Error handling on inbound adapters -


basics:

  • using spring 4.1.1 integration, boot , 1.0.0 of dsl.
  • multiple inbound sftp adapters on different schedules fetching files different vendors.
  • each integration flow attaches headers message after files downloaded identify vendor source.
  • use messagepublishingerrorhandler handle exceptions.
  • standard message flow notify external monitoring solution when message processed or when message fails complete. uses message headers identify flow failed.

both success , error flows work great, after have message. however, when encounter error occurs before message produced (i.e. not connect sftp server), don't have chance attach headers.

i've been looking @ samples , documentation, , cannot find way attach same headers error message produced messagepublishingerrorhandler without overriding error handler on poller, or creating custom error flow every inbound integration. options have here?

this example of 1 of configs:

        integrationflows         .from(             sftp.inboundadapter(sessionfactory)                     .autocreatelocaldirectory(true)                     .localdirectory(configproperties.getlocaldirectory())                     .preservetimestamp(true)                     .remotedirectory(configproperties.getremotedirectory()),             c -> c.poller(pollers                     .fixedrate(properties.getsftpinterval(), properties.getsftpintervalunit())                     .errorhandler(errorhandler)) // custom error handler?         )         .enrichheaders(                     mapbuilder                             .with("vendorname", "vendor1")                             .get()         )         .channel("filechannelhandler")         .get(); 

yeah - problem that, polled channel adapters, if exception thrown in messagesource.receive(), there's not yet message enhance custom headers.

the framework doesn't allow modifying headers of errormessage (which has raw exception payload exceptions this).

one work-around (aside custom eh) put header enricher on each error-flow identify source adapter.

in future, framework add header errormessage, containing id of channel adapter source can identified in common error flow.

feel free open 'improvement' jira issue , we'll take look.


Comments

Popular posts from this blog

Email notification in google apps script -

c++ - Difference between pre and post decrement in recursive function argument -

javascript - IE11 incompatibility with jQuery's 'readonly'? -