INT-3132 Add minSubscribers to Pub/SubChannel

Send is deemed to be successful if sent to at least this
number of subscribers (default 0).

Note: when using a task executor, if there is at least one
subscriber, a send is always good, regardless of success
or failure of invoking the handler.

Polishing - Docs - PR Comments
This commit is contained in:
Gary Russell
2013-09-04 13:34:31 -04:00
parent e24d683478
commit 4abeebdb3a
9 changed files with 152 additions and 11 deletions

View File

@@ -81,6 +81,20 @@
must be a <interfacename>MessageHandler</interfacename> itself, and the subscriber's
<methodname>handleMessage(Message)</methodname> method will be invoked in turn.
</para>
<para>
Prior to version 3.0, invoking the send method on a <classname>PublishSubscribeChannel</classname> that
had no subscribers returned <code>false</code>. When used in conjunction with a
<classname>MessagingTemplate</classname>, a <classname>MessageDeliveryException</classname>
was thrown. Starting with version 3.0, the behavior has changed such that a send is
always considered successful if at least the minimum subscribers are present (and successfully
handle the message). This behavior can be modified by setting the <code>minSubscribers</code>
property, which defaults to <code>0</code>.
</para>
<note>
If a <classname>TaskExecutor</classname> is used, only the presence of the correct number
of subscribers is used for this determination, because the actual handling of the message
is performed asynchronously.
</note>
</section>
<section id="channel-implementations-queuechannel">
<title>QueueChannel</title>

View File

@@ -363,5 +363,18 @@
For more information see <xref linkend="http"/>.
</para>
</section>
<section id="3.0-pub-sub">
<title>PublishSubscribeChannel Behavior</title>
<para>
Previously, sending to a &lt;publish-subscribe-channel/&gt; that had
no subscribers would return a <code>false</code> result. If used in conjunction with
a <classname>MessagingTemplate</classname>, this would result in an exception being thrown.
Now, the <classname>PublishSubscribeChannel</classname> has a property
<code>minSubscribers</code> (default 0). If the message is sent to at least the minimum
number of subscribers, the send is deemed to be successful (even if zero). If an application
is expecting to get an exception under these conditions, set the minimum subscribers to at
least 1.
</para>
</section>
</section>
</chapter>