Reputation: 3832
I am designing a stateless service which essentially processes a stream of information and then based on conditions sends emails. I want to host this in service fabric, with more than one active in case of failure, however how do I limit the email to be sent from only the "primary".
Is active/active only valid for stateful services which are partitioned? If the services have to be active/passive then how does the service know when it is now the active one?
Upvotes: 1
Views: 225
Reputation: 981
Another option is to have a pool of stateless workers that process your data stream, and then whenever it wants to send an email, it'll notify another service (through ServiceRemoting/Rest/ServiceBus/other communication channel) and this service will handle the actual sending of emails.
If this email sending service is stateful, it can then handle duplicates if that's one concern you have.
Upvotes: 0
Reputation: 855
I will go with Stateful service for couple reasons:
Upvotes: 0
Reputation: 11470
There's no built-in mechanism for leader election (that you can use) inside SF. You could use a blob lease. The leader will be the one who acquires the lease, and needs to refresh it while it's 'alive'. If it crashes, it will lose the lease and another instance can get it. This does introduce an external dependency, lowering the overall availability % of your system.
You could also create a Stateful service that does something similar.
Upvotes: 2