What are the Slack Archives?
It’s a history of our time together in the Slack Community! There’s a ton of knowledge in here, so feel free to search through the archives for a possible answer to your question.
Because this space is not active, you won’t be able to create a new post or comment here. If you have a question or want to start a discussion about something, head over to our categories and pick one to post in! You can always refer back to a post from Slack Archives if needed; just copy the link to use it as a reference..
Hi, I have another question on Spryker’s state machine. I just found this in the documentation: Tri
Hi, I have another question on Spryker’s state machine. I just found this in the documentation:
Triggering an event follows the transition that has the current state as a source state and the triggered event type attached to it. The event triggers the transaction and the related command is executed. The condition(s) is/are checked afterwards. If no condition is evaluated to true, the item stays on the source state (and the timeout is reseted because it moved away for a moment).
So if I have several transitions with different conditions from state A to B then all commands will be executed although only one (or even none) condition is true?
Comments
-
Hi Matthias! Can you please explain, what do you mean by “different conditions”, “several transitions” and “all commands” between A and B? Does it mean, that you have multiple states between A and B? If you have already a state machine visualization to show here - that would be helpful!
0 -
My point is that the documentation states that the condition is checked after the command is executed. I would expect that a condition is checked first.
Imagine a state with several transitions from this state to other states. Each transition can have an event which can have a command and a condition. To decide which transition is executed you have to check the conditions. If the command is executed BEFORE the condition then all commands would be executed.0 -
@UPDV9V3ST I see your point! I also had a situations in the past where executing condition before the command would be beneficial, however I also had situations where you first want to execute a command, and then check it’s result execution with the condition and proceed further.
If you need to execute a command after the condition check, then you have to introduce a state right after condition, and then from that state do a trasition to the next one which will include the event.
0 -
That’s an example of what I mean:
0 -
you do a command (export), then you check if it was successful in a condition, and if yes - you notify buyer with another command
0 -
if it wasn’t successful - you fix the issue and then retry manually
0 -
Ok, thanks for the clarification. Actually I have a pretty similar use case. What I don't like about that solution is that I need an additional method/interface in my middleware to check whether the last command was successful. It would be much better to use the outcome of the export itself to transition to different states.
0 -
In my use case I would use a HTTP response code to decide if I can proceed, retry or go to an error state.
0 -
@UPDV9V3ST yes, that’s a pretty common use case.
additional method/interface in my middleware
So just do it in Zed!
how I’ve done that In my project:
1. Command executes the HTTP call and persists the results into the separate table. Can be “pyz_order_export_log” or similar.
2. Condition checks, is there an entry for order_id (or order_item_id) with the status “success”? Yes - go there; No - go elsewhere.As a bonus, the “log” table was turned out to be extremely useful during further checks like “what did we send and why did the request fail?”
0 -
Hi Andriy, can you give me a hint how you persist the result into an separate table? Do I have to create a new Transfer object?
0
Categories
- All Categories
- 42 Getting Started & Guidelines
- 7 Getting Started in the Community
- 8 Additional Resources
- 7 Community Ideas and Feedback
- 76 Spryker News
- 929 Developer Corner
- 787 Spryker Development
- 89 Spryker Dev Environment
- 362 Spryker Releases
- 3 Oryx frontend framework
- 35 Propel ORM
- 68 Community Projects
- 3 Community Ideation Board
- 30 Hackathon
- 3 PHP Bridge
- 6 Gacela Project
- 26 Job Opportunities
- 3.2K 📜 Slack Archives
- 116 Academy
- 5 Business Users
- 370 Docker
- 551 Slack General
- 2K Help
- 75 Knowledge Sharing
- 6 Random Stuff
- 4 Code Testing
- 32 Product & Business Questions
- 70 Spryker Safari Questions
- 50 Random