I’m working on an app with a simple purpose and I would like for someone to look over what I have so far and perhaps provide a little guidance. Please note that the pom file references a parent project which is not included, identifying information has been removed or changed, and that the code may not reflect the following narrative.
So, the idea is that you want to alert someone via phone (using twilio) that they need to check their email (because it needs immediate attention and they can’t be expected to check their inbox every 5 minutes). An external app may create or cancel voice notifications. When a voice notification is created, the important pieces of information include a phone number, the number of attempts, and how long to wait between each attempt. Each phone call has a few possible outcomes: No Answer, Busy, Failed (eg. invalid #), Incomplete (eg. the call was answered, but the callee might have hung up before completing the flow), or Complete (ie. the callee listened to the call and followed the prompts to the end). A Phone Call Scheduler will check every minute for notifications that need to go out and queue a phone call.
Where might the actual call to twilio go? From the scheduler? From an event handler in the aggregate/listener? When using their API to create a call, it returns a callSid which I would think should be available to the PhoneCallQueued event. However, this would make it seem as if I should do it from a command handler. Furthermore, if the command handler is the place, it seems like that might make things harder to test.
I need to use timestamps (eg. How do I know that it’s been 10 minutes since my last attempt?), but in coding up some simple tests, trying to use them (eg. when was the notification created?) seemed a little strange. As if I was supposed to put it into the Created command and then pass it along.
I’m sure I will have more questions, but I just want to start with these.
notification-service.zip (16.9 KB)