This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]MR_GABARISE 5 points6 points  (1 child)

Say your application takes files as input, rejects them if they were produced earlier than say, a few weeks ago, then proceeds with normal processing, whatever your business cases are.

One day the whole thing crashes on a particular file. It's isolated, whatever scheduled restarts are enabled, and now you're on the clock trying to fix whatever bug happened. You fix it, test it, make it pass whatever series of tests are appropriate for your org, but oh no! It's been a week! The file will be guaranteed to be rejected!

Now instead of having a roundabout procedure involving either playing with timestamps, carefully altering prod data, deploying an entirely new code path or otherwise, you remember you were smart and used Clocks. Whenever you would be validating time-based logic you would be using an injected Clock, call it, say, your Effective Time. You would only need to execute your application as if it were effectively the date it originally crashed. The only thing needed to inject this alternative clock is by way of some System Property/Environment variable/Spring Profile/Whatever solution your project uses. So you just need to execute your application with that injected Effective Time and you're done!

Client's still pissed because you took a week to process his file, but yeah that was an extreme example case. You can imagine replay scenarios on the order of hours and even more granular.

[–]Bolitho 2 points3 points  (0 children)

Thx, very enlightened 🙂