Reputation: 815
I am developing a solution that queries a SOAP web service for certain transactions. Once retrieved, these transactions are meant to be saved in a database after which a callback url is invoked to send some data to another server. How would you best architect a solution to this problem. My point of confusion is whether gen_server or gen_fsm should be used and if so which component of the solution goes where i.e. if gen_server what task goes to the server which task goes to the client.
Upvotes: 1
Views: 267
Reputation: 16577
Think about what tasks can happen in parallel in your system. Can the SOAP queries be done in parallel, and does it make sense? Can the transactions be written to the database while SOAP is being queried again? Is the data to another server supposed to be sent after the transactions are written to the database, or can it be done at the same time?
Once you know these answers, you can build your pipeline. One example would be:
This is just one example, and depending on your requirements, you might have to structure things another way.
In general, these processes can all be gen_servers
as none of them have any clear states. In fact, the two worker processes doesn't have to be gen_servers
at all, since they just do one task and then die. Using a gen_server
in that case would be overkill.
Upvotes: 3