Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8689125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:33:43+00:00 2026-06-12T23:33:43+00:00

I’m hoping someone can provoke some ideas or provide references to material for creating

  • 0

I’m hoping someone can provoke some ideas or provide references to material for creating a “transaction coordinator” implementation in PHP 5. The driver is based on a multi-vendor single business process integration. Due to potential failure points I’d like to avoid spaghetti code with tons of if’s, switches, try..catches and have a coordinator that can intercept method calls, track responses to subsequent calls and interrogate a methods attribute to determine what compensation function to use to reverse the transaction. The intent is to create an “ACID” like processing. The closing thing I can reference would be the TransactionScope object in .Net.

A sample scenario:

ServiceA
ServiceB
ServiceC

ServiceA->DoSomething() - passes
ServiceB->DoSomething() - passes
ServiceC->DoSomething() - fails

at this point A & B must employ some type of compensation strategy to call functionality that will return state be it a database, third party integration or otherwise back to its original state.

My initial thoughts are to use some type of AOP to hold a reference to the compensator and the state requirements to complete the reversal activity. Than a coordinator would need to keep track of executions, as well as returned state of executions to allow for the call to the compensator.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:33:45+00:00Added an answer on June 12, 2026 at 11:33 pm

    Dont try ACID, because you cannot do it. Trying to fake it will at some point leak, so better not try in the first place. As you wrote yourself, using Service A to do one step, later seeing that Service C failed, puts you in need of telling Service A to undo the one step taken. If there is no way to undo the single step, the workaround might be to restart all over with Service A, doing a reset and all previously done steps without the last one inside your transaction. This does not sound ACID at all. Pretending it is will fail at some point.

    As you are modeling a process, use a finite state machine for it. It is independent from what your services can or cannot do, but you get the ability to track which steps need to be taken, probably in which order, what to do if a step fails, and it is relatively easy to extend at any point.

    Regarding your comment that you might end up in a mess of if, switch and try/catch: That is entirely up to you, but has nothing to do with implementing a process.

    If you are looking for an implementation of a state machine, there are not that many for PHP. PEAR has one very PHP4-style old one, which might still work and do the job (have a look: http://pear.php.net/package/FSM ), but the better implementation would be https://github.com/Metabor/Statemachine – this guy has written “state machine” all over, and I see some very good features there, for example handing over the code that does the work via callbacks to the transitions, and then change transitions via events. This has the advantage that your state machine is in full control of what can and cannot be done, and if it can be done, it will be done via the callback.

    A neat feature is that you can get hold of the defined states and transitions as an image.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I would like to count the length of a string with PHP. The string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.