Renamed 'broadcaster' property to 'publishSubscribe'.
This commit is contained in:
@@ -36,11 +36,11 @@ public interface MessageChannel {
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Return whether this channel has been designated as a broadcaster. If so,
|
||||
* any dispatcher retrieving messages from this channel should send each
|
||||
* message to each of its receivers.
|
||||
* Return whether this channel has been designated as a publish-subscribe channel.
|
||||
* If so, any dispatcher retrieving messages from this channel should send each
|
||||
* message to each of the dispatcher's handlers.
|
||||
*/
|
||||
boolean isBroadcaster();
|
||||
boolean isPublishSubscribe();
|
||||
|
||||
/**
|
||||
* Send a message, blocking indefinitely if necessary.
|
||||
|
||||
@@ -36,7 +36,7 @@ public class SimpleChannel implements MessageChannel, BeanNameAware {
|
||||
|
||||
private String name;
|
||||
|
||||
private boolean broadcaster = false;
|
||||
private boolean publishSubscribe = false;
|
||||
|
||||
private BlockingQueue<Message<?>> queue;
|
||||
|
||||
@@ -70,12 +70,12 @@ public class SimpleChannel implements MessageChannel, BeanNameAware {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public boolean isBroadcaster() {
|
||||
return this.broadcaster;
|
||||
public boolean isPublishSubscribe() {
|
||||
return this.publishSubscribe;
|
||||
}
|
||||
|
||||
public void setBroadcaster(boolean broadcaster) {
|
||||
this.broadcaster = broadcaster;
|
||||
public void setPublishSubscribe(boolean publishSubscribe) {
|
||||
this.publishSubscribe = publishSubscribe;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -39,6 +39,8 @@ public class ChannelParser implements BeanDefinitionParser {
|
||||
|
||||
private static final String PUBLISH_SUBSCRIBE_ATTRIBUTE = "publish-subscribe";
|
||||
|
||||
private static final String PUBLISH_SUBSCRIBE_PROPERTY = "publishSubscribe";
|
||||
|
||||
|
||||
public BeanDefinition parse(Element element, ParserContext parserContext) {
|
||||
RootBeanDefinition channelDef = new RootBeanDefinition(SimpleChannel.class);
|
||||
@@ -49,7 +51,7 @@ public class ChannelParser implements BeanDefinitionParser {
|
||||
}
|
||||
String isPublishSubscribe = element.getAttribute(PUBLISH_SUBSCRIBE_ATTRIBUTE);
|
||||
if ("true".equals(isPublishSubscribe)) {
|
||||
channelDef.getPropertyValues().addPropertyValue("broadcaster", Boolean.TRUE);
|
||||
channelDef.getPropertyValues().addPropertyValue(PUBLISH_SUBSCRIBE_PROPERTY, Boolean.TRUE);
|
||||
}
|
||||
String beanName = element.getAttribute(ID_ATTRIBUTE);
|
||||
if (!StringUtils.hasText(beanName)) {
|
||||
|
||||
@@ -121,10 +121,11 @@ public class DefaultMessageDispatcher implements MessageDispatcher, MessagingTas
|
||||
if (schedule == null) {
|
||||
schedule = this.defaultSchedule;
|
||||
}
|
||||
else if (this.channel.isBroadcaster()) {
|
||||
else if (this.channel.isPublishSubscribe()) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("This dispatcher's channel is a broadcaster, and therefore all handlers are " +
|
||||
"scheduled with its 'defaultSchedule'. The provided schedule will be ignored.");
|
||||
logger.info("This dispatcher broadcasts messages for a publish-subscribe channel. " +
|
||||
"Therefore all handlers are scheduled with its 'defaultSchedule', " +
|
||||
"and the provided schedule will be ignored.");
|
||||
}
|
||||
schedule = this.defaultSchedule;
|
||||
}
|
||||
@@ -167,7 +168,7 @@ public class DefaultMessageDispatcher implements MessageDispatcher, MessagingTas
|
||||
task.setSchedule(schedule);
|
||||
task.setRejectionLimit(this.rejectionLimit);
|
||||
task.setRetryInterval(this.retryInterval);
|
||||
task.setBroadcast(channel.isBroadcaster());
|
||||
task.setPublishSubscribe(channel.isPublishSubscribe());
|
||||
task.setShouldFailOnRejectionLimit(this.shouldFailOnRejectionLimit);
|
||||
for (MessageHandler handler : handlers) {
|
||||
if (handler instanceof Lifecycle) {
|
||||
|
||||
@@ -46,7 +46,7 @@ public class DispatcherTask implements MessagingTask {
|
||||
|
||||
private Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private boolean broadcast = false;
|
||||
private boolean publishSubscribe = false;
|
||||
|
||||
private Schedule schedule;
|
||||
|
||||
@@ -64,20 +64,20 @@ public class DispatcherTask implements MessagingTask {
|
||||
public DispatcherTask(MessageChannel channel) {
|
||||
Assert.notNull(channel, "'channel' must not be null");
|
||||
this.retriever = new ChannelPollingMessageRetriever(channel);
|
||||
this.broadcast = channel.isBroadcaster();
|
||||
this.publishSubscribe = channel.isPublishSubscribe();
|
||||
}
|
||||
|
||||
public DispatcherTask(MessageRetriever retriever) {
|
||||
Assert.notNull(retriever, "'retriever' must not be null");
|
||||
if (retriever instanceof ChannelPollingMessageRetriever) {
|
||||
this.broadcast = ((ChannelPollingMessageRetriever) retriever).getChannel().isBroadcaster();
|
||||
this.publishSubscribe = ((ChannelPollingMessageRetriever) retriever).getChannel().isPublishSubscribe();
|
||||
}
|
||||
this.retriever = retriever;
|
||||
}
|
||||
|
||||
|
||||
public void setBroadcast(boolean broadcast) {
|
||||
this.broadcast = broadcast;
|
||||
public void setPublishSubscribe(boolean publishSubscribe) {
|
||||
this.publishSubscribe = publishSubscribe;
|
||||
}
|
||||
|
||||
public void setSchedule(Schedule schedule) {
|
||||
@@ -161,7 +161,7 @@ public class DispatcherTask implements MessagingTask {
|
||||
MessageHandler handler = iter.next();
|
||||
try {
|
||||
handler.handle(message);
|
||||
if (!this.broadcast) {
|
||||
if (!this.publishSubscribe) {
|
||||
return true;
|
||||
}
|
||||
iter.remove();
|
||||
|
||||
Reference in New Issue
Block a user