polishing

This commit is contained in:
Mark Fisher
2011-05-03 17:51:20 -04:00
parent 2deb97608a
commit 832ff4358a
3 changed files with 16 additions and 11 deletions

View File

@@ -71,12 +71,15 @@
</para>
<para><emphasis>Claim Once</emphasis></para>
<para>
There are scenarios when a particular message must be claimed only once. Take the airplane luggage check-in/out process.
Checking-in your luggage on the departure and and then claiming it on the arrival is a classic example of such scenario.
Once the luggage was claimed it can no longer be claimed again without further check-in. To accommodate such cases we
introduced <code>remove-message</code> boolean attribute on <code>claim-check-out</code> transformer. This attribute is
set to <code>false</code> by default, however if set to <code>true</code>, the claimed Message will also be removed
from the MessageStore and can no longer be claimed again.
There are scenarios when a particular message must be claimed only once. As an analogy, consider the airplane luggage check-in/out process.
Checking-in your luggage on the departure and and then claiming it on the arrival is a classic example of such a scenario.
Once the luggage was claimed it can not be claimed again without first checking it back in. To accommodate such cases we
introduced a <code>remove-message</code> boolean attribute on the <code>claim-check-out</code> transformer. This attribute is
set to <code>false</code> by default. However if set to <code>true</code>, the claimed Message will also be removed
from the MessageStore so that it can no longer be claimed again. This is also something to consider in terms of storage space,
especially in the case of the in-memory Map-based <classname>SimpleMessageStore</classname> where failing to remove the Messages
could ultimately lead to an <classname>OutOfMemoryException</classname>. If you don't expect multiple claims to be made, it's
recommended that you set the <code>remove-message</code> attribute's value to <code>false</code>.
<programlisting language="xml"><![CDATA[<claim-check-out id="checkout"
input-channel="checkoutChannel"
message-store="testMessageStore"

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2010 the original author or authors.
* Copyright 2002-2011 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,7 +35,7 @@ import org.springframework.util.Assert;
public class ClaimCheckOutTransformer extends AbstractTransformer {
private final MessageStore messageStore;
private volatile boolean removeMessage = false;
@@ -59,9 +59,11 @@ public class ClaimCheckOutTransformer extends AbstractTransformer {
Message<?> retrievedMessage = this.messageStore.getMessage(id);
Assert.notNull(retrievedMessage, "unable to locate Message for ID: " + id
+ " within MessageStore [" + this.messageStore + "]");
if (this.removeMessage){
if (this.removeMessage) {
this.messageStore.removeMessage(id);
logger.debug("Message with claim-check '" + id + "' was removed from MessageStore");
if (logger.isDebugEnabled()) {
logger.debug("Removed Message with claim-check '" + id + "' from the MessageStore.");
}
}
MessageBuilder<?> responseBuilder = MessageBuilder.fromMessage(retrievedMessage);
// headers on the 'current' message take precedence

View File

@@ -1914,7 +1914,7 @@ endpoint itself is a Polling Consumer for a channel with a queue.
<xsd:annotation>
<xsd:documentation>
If set to 'true' the Message will be removed from the MessageStore by
this transformer. Useful when Message can be 'claimed' only once. DFAULT is 'false'
this transformer. Useful when Message can be 'claimed' only once. DEFAULT is 'false'.
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>