1
14
15 package com.liferay.portal.kernel.messaging;
16
17 import com.liferay.portal.kernel.util.ThreadLocalRegistry;
18
19 import java.util.Set;
20 import java.util.concurrent.ThreadPoolExecutor;
21
22
32 public class SerialDestination extends BaseDestination {
33
34 public SerialDestination() {
35 }
36
37
40 public SerialDestination(String name) {
41 super(name, _WORKERS_CORE_SIZE, _WORKERS_MAX_SIZE);
42 }
43
44 protected void dispatch(
45 final Set<MessageListener> messageListeners, final Message message) {
46
47 ThreadPoolExecutor threadPoolExecutor = getThreadPoolExecutor();
48
49 Runnable runnable = new Runnable() {
50
51 public void run() {
52 try {
53 for (MessageListener messageListener : messageListeners) {
54 messageListener.receive(message);
55 }
56 }
57 finally {
58 ThreadLocalRegistry.resetThreadLocals();
59 }
60 }
61
62 };
63
64 threadPoolExecutor.execute(runnable);
65 }
66
67 private static final int _WORKERS_CORE_SIZE = 1;
68
69 private static final int _WORKERS_MAX_SIZE = 1;
70
71 }