jdh
jdh

Reputation: 73

Playframework with thread-pool for background job

In my playframework application (I'm very new to play) I want to be able to handle events rising from the domain model that will be published to an AMQP exchange. I think this could be a multi-threaded background event handler that handles the events and handles the connections to the message broker. I have had had a look at the Jobs class but can't see a way to specify any kind of thread pool. Does anyone have any suggestions?

Best,

Jon

Upvotes: 2

Views: 661

Answers (1)

Gelin Luo
Gelin Luo

Reputation: 14373

ThreadPool is managed by Play, not by app. What you need to do is just create a job class, and schedule it to run:

@On("cron.handleAMQP")
public class MyAMQPHandler extends play.jobs.Job{
   public void doJob() {
      // your logic to handle AMQP message comes here
   }
}

Where "cron.handleAMQP" could be one item in your application.conf:

cron.handleAMQP=0 0 12 * * ?

Upvotes: 5

Related Questions