java - Spring integration - decorate message on fail -


i trying implement process consisting of several webservice-calls, initiated jms-message read spring-integration. since there no transactions across these ws-calls, keep track of how far process has gone, steps carried out skipped when retrying message processing.

example steps:

  1. retrieve (get a.id)
  2. create new b (using a.id, getting b.id)
  3. create new c b (using b.id, getting c.id)

now, if first attempt fails in step 3, have created b, , know it's id. if want retry message, skip second step, , not leave me incomplete b.

so, question: possible decorate jms-message read spring-integration additional header properties upon message processing failures? if so, how this?

the way works @ moment:

  1. message read
  2. some exception thrown
  3. message processing halts, , activemq places message on dlq

how work:

  1. message read
  2. some exception thrown
  3. the exception handled, result of handling being header property added original message
  4. activemq places message on dlq

one thing might achieve following:

  1. read message
  2. start processing, wrapped in try-catch
  3. on exception, information exception, create new message based on original one, add info header , send directly dlq
  4. swallow exception original message dissappears

this feels kinda hackish though, there more elegant solution.

it's hard generalize without more information flow(s) consider adding custom request handler advice decorate and/or re-route failed messages. see adding behavior endpoints.

as other answer says, can't modify message can build new 1 it.

edit:

so, question: possible decorate jms-message read spring-integration additional header properties upon message processing failures? if so, how this?

ahhh... think know asking; no, can't "decorate" existing message; can republish additional headers instead of throwing exception.

you can republish in advice, or in error flow.

it might seem "hack" you, jms api provides no mechanism want.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -