synchronized method or use spring @transactional?

后端 未结 6 609
你的背包
你的背包 2021-01-15 08:00

I have a method that will be used to send out email. i want to lock this method so only one thread can accses it per time and the rest pool up concurrently. should i synchro

6条回答
  •  萌比男神i
    2021-01-15 08:14

    Another possibility would be to use JMS queues and put the email sending code in a Message Driven Bean (or through Spring JMS). You can then use your app server to control how many concurrent instances of your MDB will be used and throttle the outgoing emails that way.

提交回复
热议问题