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:
- retrieve (get a.id)
- create new b (using a.id, getting b.id)
- 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:
- message read
- some exception thrown
- message processing halts, , activemq places message on dlq
how work:
- message read
- some exception thrown
- the exception handled, result of handling being header property added original message
- activemq places message on dlq
one thing might achieve following:
- read message
- start processing, wrapped in try-catch
- on exception, information exception, create new message based on original one, add info header , send directly dlq
- 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
Post a Comment