4 ms·
"""This seems horrible design to me. """ Have you actually read the code? I just did and there is barely any thread-related code in the example. It's mostly co
by st3fan 19y ago
"""This seems horrible design to me. """
Have you actually read the code? I just did and there is barely any thread-related code in the example. It's mostly code to push and pop stuff from a queue.
Personally I would turn this into a little Java/AWS framework whose API is based on a high level queue object to abstract away the communication with SQS. Probably simply modelled after a java.util.concurrent.BlockingQueue and configurable through Spring so that it becomes a nice reusable component.
Then it gets totally simple and interacting with those (remote) queues will not be any different than with one kept in memory for example. Since it is all thread safe it will be a no-brainer to create a simple workflow where you take stuff from one queue and put it in another.
I seriously don't understand why people are so afraid of threads. All you need is a good and well tested abstraction for common patterns.
http://www.javaconcurrencyinpractice.com http://www.javaconcurrencyinpractice.com is probably a good start for Java people with the threads-are-evil mindset.
S.
- Tamerlin 19y agoI agree. Then again, most of the people that I've met who share the threads are evil mindset write bad code and can't manage requirements, like a certain project manager I had who was full of "trivial" last-minute requirements... I suspect that there's a relationship there. :)
- st3fan 18y agoMost people I meet that have the threads-are-evil attitude are Python or Ruby coders who have never experienced a rich runtime where stable concurrency is actually possible :-)
- ardit33 19y agodoing concurrency right, is not easy. It takes an exeperienced developer to get it right (i.e good abstraction techniques, recovering from failure and interrupts, etc), so a lot of people are uncomfortable handling multi-threading, mainly b/c it adds yet another layer of what can go wrong.