I'm looking an implementing a web service ( let's call it A) in Java that accepts job requests and then sends these requests to another web service (3rd party service Let's call it B). Nothing complex here. Responses from B to A are synchronous ( returns job id) and then when the job finishes B sends an asynchronous message to A notifying it that the job has finished ( jobs to B can take X time). B can only accept 20 jobs at a time however A should be able to accept as many jobs as possible from multiple clients. So A needs a queing system to only ever send B no more that 20 jobs. When B finishes a job and notifies A, then A can send another job to B. 

I could save jobs coming into A in a database with state NEW and then have a process running every 5 min, collects NEW jobs and if <20 jobs processing by B send job. Jobs processing by B would have status PROCESSING and then when B sends job finish to A it sets status to DONE. And just

Can I do this with JMS or a routing engine like Camel or if anyone can provide another framework to help. I haven't been able to find anything that maintains a queue and only ever sends a max of X jobs. The A queue could have hundreds of jobs waiting to be processed but only ever sends another job to B when it finishes another job.