Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

213
Visualizações
best practice to do rollback within multi-phase update?

we have a data object whose attributes are distributed among 3 parties,

  1. an internal service using http
  2. cloud
  3. DB

When it comes to updating the data of that object, we don't want to leave the object partially updated. So if all parties are involved for updating, will do

1 -> 2 -> 3 

sequentially. But if the update is successful at step 1 and fails at step 2, then we need to rollback step 1; if step 1 & 2 are successful, and step 3 fails, then step 1 & 2 both should be reverted. This is a spring boot 1.4, Java 8 application. Is there any elegant way for me to achieve it programmatically, rather than try/catch in step 2 & 3?

Hope I explain it well. Any helps/clues are deeply appreciated

about 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

There are integration patterns you could take a look at, and libraries that implement these patterns for you such as Apache Camel, or propriety products such as Mule (I think that is expensive you would probably never choose that), or a business process management flow, but these are all design decisions you will need to make yourself. It may be perfectly ok to decide not to use any of these more heavy weight approaches. There is allot out there on integration you can check out that field as much as you need to find a suitable solution, but I wouldn't invest too much time in it, just figure out what will be good enough.

Note: you might find material on distributed transactions, and you'll find people who believe in them, just like how some people believe in the Easter bunny as a child. I'm not going to tell you they aren't real, (having done so in the past I have received down votes ): ), but I will just say I have yet to witness them, and don't expect to.

about 4 years ago · Santiago Trujillo Relatório

0

If I understood well, the 1st and 2nd call goes outside of your scope and you can't just roll back easily as you can in a DB transaction? You can apply a compensation pattern in order to compensate what was already updated.

  • You need to store your object state before the update process.
  • If something goes wrong in step 2 or 3, a compensation handler will be triggered in order to revert the changes (it will make an update with the previous state).
about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda