Java Concurrency programming - use producer-consumer-problem to improve performance.
Generically speaking, when setup a module in distributed system, we need to connect to the other modules through MQ middleware. For showing how the producer-consumer module works, this sample will use file system to replace the MQ middleware.
I integrate this sample with Spring framework, so you can just change the logic for consumer, producer and pipeline. Then use it in your company project easily.
There are still same reminder:
- Don't forget to backup your MESSAGE in producer(Producer.java line56).
- Don't forget to delete your temporary file when you have done your task in consumer(Consumer.java line34).
- Tune your thread size in applicationContext.xml.
Feel free to send email to me chenrulong0513.master@gmail.com if you have any questions. And welcome to my blog GeekerSquare.