Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

214
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda