Franck Anso
Franck Anso

Reputation: 1458

How manage heavy task under Java/Spring?

I have a dashboard where users can do modification to their customers datas. Some modifications needs heavy processing on all those customers. I don't want to block my user waiting that the task finished so how can I manage this in background?

I saw Spring Batch but I'm not sure it's the good answer. Is there anything else?

Thanks in advance for your help.

Upvotes: 0

Views: 553

Answers (4)

Emerson Farrugia
Emerson Farrugia

Reputation: 11363

You already have an accepted answer, but I wanted to throw in another option FYI.

  • If you want to run within the same JVM, @Async and a task executor will work.
  • If you have a big job that needs progress tracking, resumes, etc. and doesn't user need interaction, Spring Batch works.
  • If you have big jobs that you want to trigger remotely, or as part of a message driven architecture, Spring Batch Integration is a new effort to better combine Spring Integration and Spring Batch.

Upvotes: 0

gipsh
gipsh

Reputation: 608

You should have a separte process or application to process this kind of heavy task. Your main application have to communicate with this heavy-task-processor via any method like JMS, JGroups, ConcurrentLinkedQueue, or whatever you want. You can process (deque) each task one at time or using a thread pool. When the task is finish you have to implement a way to inform the main application the task has finished (JMS, subscription, etc..)

Upvotes: 0

Jorge_B
Jorge_B

Reputation: 9872

It is not a Spring specific feature, but if you work under a commercial java application server (say websphere, weblogic), you will have some implementation of workmanagers.

http://docs.oracle.com/javaee/1.4/api/javax/resource/spi/work/WorkManager.html

These are container-managed threadpools used to send work into the background. You will find tools in your admin console to configure and fine tune them.

Upvotes: 0

Adam Gent
Adam Gent

Reputation: 49095

See (google) @Async and or Spring AMQP / JMS

Upvotes: 2

Related Questions