Notification.scala
contains all the necessary implementations and a couple of missing ones. Using Scala's Future
s implement the problem parts below:
-
Part 1
- Send notification for
debit
orcredit
transactions on a customer’s bank account. - Implement either
credit
ordebit
operation. - You must send both the messages SMS and Email upon a successful transaction.
- Send notification for
-
Part 2
- Retry any service method -
sendSms
orsendEmail
until a specified number of times. - Hint: For this write a generic retry method which consumes a CBN Future and returns a Future that succeeds or fails.
- Enhance the above to now retry after every specified duration.
- You can use the
enableSMSAfter
orenableEmailAfter
methods onNotificationService
to test.
- Retry any service method -
-
Part 3
- Using the earlier retry (from Part 2) caused multiple SMS’ and Email’s being sent, despite the success of intermediate future.
- Change the behaviour of retry such that:
- if any of the intermediate future succeeds, it stops retrying and exits.
- if none of the futures succeeds, it retries until the specified number of times every specified duration
- Finally, use it the
AccountService
’sdebit
orcredit
implementation to see it in action.