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