0

I am implementing integration with a third party system, that I don't have a control over it, and use rabbitmq as message queue to publish a message after doing some updates on the third party system, my implementation as the following scenario

await createItemOnProvider()
await queue.publishMessage()

If I implement a database update and want to publish a message after it succeeds, I use the outbox pattern to handle that case, but in the current case, I need to make it atomic but there is no transaction wrapper that handles doing both or not, I am not sure what pattern should be used in that case, for example if publishing a message failed, what to do?

5
  • Could you clarify the data flow, please? As far as I understand, some app A (you have no control over) does some update Ua and publishes a message after it is completed. You app B reads the message, does some update Ub on its side and publishes another message to the queue. And you want Ua and Ub to be atomic (either both happen or none at all). Did I get it right? Commented Dec 13, 2022 at 11:00
  • thanks for your reply, I want to make the updates that happen on the another system and the message I am publishing are atomic, there is two possible cases here: the first case : System (A) does the updates successfully, then the message will be published successfully second case: system (A) fails to do updates then no message will be published third case: system (A) does changes successfully, but a problem happen while publishing the message, so how I gurantee that the message will be published successfully? Commented Dec 13, 2022 at 11:12
  • But why it is your concern if you say you don't control A? You should not care what happens on their side (in fact, you don't even know that, A is just a "blackbox with public API" for you), you should build your own system taking in mind possible inconsistencies. Commented Dec 13, 2022 at 11:21
  • I don't care about (A) system, I care about in case I called (A) system and did the updates, then I failed to publish the message to my system Commented Dec 13, 2022 at 11:34
  • If it is only the message publishing on your end that has failed - just repeat it (maybe with some backoff if it failed due to network-related issues), repeat until succeeded. In any case, your system is only eventually consistent with A, so nothing extraordinary happened, didn't it? Commented Dec 13, 2022 at 11:42

1 Answer 1

1

Don't reinvent the wheel. Use an orchestrator like temporal.io to implement your logic. You can write code exactly as per your requirements:

await createItemOnProvider()
await publishMessage()

and Temporal is going to ensure that both lines complete execution in the presence of any failures including process crashes and network outages.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.