|
52 | 52 | import org.springframework.integration.store.SimpleMessageGroup;
|
53 | 53 | import org.springframework.integration.store.SimpleMessageStore;
|
54 | 54 | import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
|
| 55 | +import org.springframework.integration.support.MessageBuilder; |
55 | 56 | import org.springframework.integration.support.locks.DefaultLockRegistry;
|
56 | 57 | import org.springframework.integration.support.locks.LockRegistry;
|
57 | 58 | import org.springframework.integration.util.UUIDConverter;
|
@@ -141,6 +142,8 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageP
|
141 | 142 |
|
142 | 143 | private boolean expireGroupsUponTimeout = true;
|
143 | 144 |
|
| 145 | + private boolean popSequenceDetails = true; |
| 146 | + |
144 | 147 | private volatile boolean running;
|
145 | 148 |
|
146 | 149 | public AbstractCorrelatingMessageHandler(MessageGroupProcessor processor, MessageGroupStore store,
|
@@ -218,6 +221,69 @@ public void setOutputProcessor(MessageGroupProcessor outputProcessor) {
|
218 | 221 | this.outputProcessor = outputProcessor;
|
219 | 222 | }
|
220 | 223 |
|
| 224 | + public void setDiscardChannel(MessageChannel discardChannel) { |
| 225 | + Assert.notNull(discardChannel, "'discardChannel' cannot be null"); |
| 226 | + this.discardChannel = discardChannel; |
| 227 | + } |
| 228 | + |
| 229 | + public void setDiscardChannelName(String discardChannelName) { |
| 230 | + Assert.hasText(discardChannelName, "'discardChannelName' must not be empty"); |
| 231 | + this.discardChannelName = discardChannelName; |
| 232 | + } |
| 233 | + |
| 234 | + |
| 235 | + public void setSendPartialResultOnExpiry(boolean sendPartialResultOnExpiry) { |
| 236 | + this.sendPartialResultOnExpiry = sendPartialResultOnExpiry; |
| 237 | + } |
| 238 | + |
| 239 | + /** |
| 240 | + * By default, when a MessageGroupStoreReaper is configured to expire partial |
| 241 | + * groups, empty groups are also removed. Empty groups exist after a group |
| 242 | + * is released normally. This is to enable the detection and discarding of |
| 243 | + * late-arriving messages. If you wish to expire empty groups on a longer |
| 244 | + * schedule than expiring partial groups, set this property. Empty groups will |
| 245 | + * then not be removed from the MessageStore until they have not been modified |
| 246 | + * for at least this number of milliseconds. |
| 247 | + * @param minimumTimeoutForEmptyGroups The minimum timeout. |
| 248 | + */ |
| 249 | + public void setMinimumTimeoutForEmptyGroups(long minimumTimeoutForEmptyGroups) { |
| 250 | + this.minimumTimeoutForEmptyGroups = minimumTimeoutForEmptyGroups; |
| 251 | + } |
| 252 | + |
| 253 | + /** |
| 254 | + * Set {@code releasePartialSequences} on an underlying default |
| 255 | + * {@link SequenceSizeReleaseStrategy}. Ignored for other release strategies. |
| 256 | + * @param releasePartialSequences true to allow release. |
| 257 | + */ |
| 258 | + public void setReleasePartialSequences(boolean releasePartialSequences) { |
| 259 | + if (!this.releaseStrategySet && releasePartialSequences) { |
| 260 | + setReleaseStrategy(new SequenceSizeReleaseStrategy()); |
| 261 | + } |
| 262 | + this.releasePartialSequences = releasePartialSequences; |
| 263 | + } |
| 264 | + |
| 265 | + /** |
| 266 | + * Expire (completely remove) a group if it is completed due to timeout. |
| 267 | + * Default true |
| 268 | + * @param expireGroupsUponTimeout the expireGroupsUponTimeout to set |
| 269 | + * @since 4.1 |
| 270 | + */ |
| 271 | + public void setExpireGroupsUponTimeout(boolean expireGroupsUponTimeout) { |
| 272 | + this.expireGroupsUponTimeout = expireGroupsUponTimeout; |
| 273 | + } |
| 274 | + |
| 275 | + /** |
| 276 | + * Perform a {@link MessageBuilder#popSequenceDetails()} for output message or not. |
| 277 | + * Default to true. |
| 278 | + * This option play an opposite role to the |
| 279 | + * {@link org.springframework.integration.splitter.AbstractMessageSplitter#setApplySequence(boolean)}. |
| 280 | + * @param popSequenceDetails the boolean flag to use. |
| 281 | + * @since 5.1 |
| 282 | + */ |
| 283 | + public void setPopSequenceDetails(boolean popSequenceDetails) { |
| 284 | + this.popSequenceDetails = popSequenceDetails; |
| 285 | + } |
| 286 | + |
221 | 287 | @Override
|
222 | 288 | public void setTaskScheduler(TaskScheduler taskScheduler) {
|
223 | 289 | super.setTaskScheduler(taskScheduler);
|
@@ -286,57 +352,6 @@ private MessageGroupProcessor createGroupTimeoutProcessor() {
|
286 | 352 | return processor;
|
287 | 353 | }
|
288 | 354 |
|
289 |
| - public void setDiscardChannel(MessageChannel discardChannel) { |
290 |
| - Assert.notNull(discardChannel, "'discardChannel' cannot be null"); |
291 |
| - this.discardChannel = discardChannel; |
292 |
| - } |
293 |
| - |
294 |
| - public void setDiscardChannelName(String discardChannelName) { |
295 |
| - Assert.hasText(discardChannelName, "'discardChannelName' must not be empty"); |
296 |
| - this.discardChannelName = discardChannelName; |
297 |
| - } |
298 |
| - |
299 |
| - |
300 |
| - public void setSendPartialResultOnExpiry(boolean sendPartialResultOnExpiry) { |
301 |
| - this.sendPartialResultOnExpiry = sendPartialResultOnExpiry; |
302 |
| - } |
303 |
| - |
304 |
| - /** |
305 |
| - * By default, when a MessageGroupStoreReaper is configured to expire partial |
306 |
| - * groups, empty groups are also removed. Empty groups exist after a group |
307 |
| - * is released normally. This is to enable the detection and discarding of |
308 |
| - * late-arriving messages. If you wish to expire empty groups on a longer |
309 |
| - * schedule than expiring partial groups, set this property. Empty groups will |
310 |
| - * then not be removed from the MessageStore until they have not been modified |
311 |
| - * for at least this number of milliseconds. |
312 |
| - * @param minimumTimeoutForEmptyGroups The minimum timeout. |
313 |
| - */ |
314 |
| - public void setMinimumTimeoutForEmptyGroups(long minimumTimeoutForEmptyGroups) { |
315 |
| - this.minimumTimeoutForEmptyGroups = minimumTimeoutForEmptyGroups; |
316 |
| - } |
317 |
| - |
318 |
| - /** |
319 |
| - * Set {@code releasePartialSequences} on an underlying default |
320 |
| - * {@link SequenceSizeReleaseStrategy}. Ignored for other release strategies. |
321 |
| - * @param releasePartialSequences true to allow release. |
322 |
| - */ |
323 |
| - public void setReleasePartialSequences(boolean releasePartialSequences) { |
324 |
| - if (!this.releaseStrategySet && releasePartialSequences) { |
325 |
| - setReleaseStrategy(new SequenceSizeReleaseStrategy()); |
326 |
| - } |
327 |
| - this.releasePartialSequences = releasePartialSequences; |
328 |
| - } |
329 |
| - |
330 |
| - /** |
331 |
| - * Expire (completely remove) a group if it is completed due to timeout. |
332 |
| - * Default true |
333 |
| - * @param expireGroupsUponTimeout the expireGroupsUponTimeout to set |
334 |
| - * @since 4.1 |
335 |
| - */ |
336 |
| - public void setExpireGroupsUponTimeout(boolean expireGroupsUponTimeout) { |
337 |
| - this.expireGroupsUponTimeout = expireGroupsUponTimeout; |
338 |
| - } |
339 |
| - |
340 | 355 | @Override
|
341 | 356 | public String getComponentType() {
|
342 | 357 | return "aggregator";
|
@@ -759,7 +774,7 @@ protected Collection<Message<?>> completeGroup(Message<?> message, Object correl
|
759 | 774 | partialSequence = (Collection<Message<?>>) result;
|
760 | 775 | }
|
761 | 776 |
|
762 |
| - if (partialSequence == null && !(result instanceof Message<?>)) { |
| 777 | + if (this.popSequenceDetails && partialSequence == null && !(result instanceof Message<?>)) { |
763 | 778 | AbstractIntegrationMessageBuilder<?> messageBuilder;
|
764 | 779 | if (result instanceof AbstractIntegrationMessageBuilder<?>) {
|
765 | 780 | messageBuilder = (AbstractIntegrationMessageBuilder<?>) result;
|
|
0 commit comments