RESOLVED - issue INT-1097
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
package org.springframework.integration.store;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
|
||||
@@ -27,6 +28,7 @@ import org.springframework.integration.core.Message;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Iwein Fuld
|
||||
* @author Dave Syer
|
||||
* @since 2.0
|
||||
*/
|
||||
public interface MessageStore {
|
||||
@@ -35,11 +37,11 @@ public interface MessageStore {
|
||||
* Return the Message with the given id, or <i>null</i> if no
|
||||
* Message with that id exists in the MessageStore.
|
||||
*/
|
||||
Message<?> get(Object id);
|
||||
Message<?> get(UUID id);
|
||||
|
||||
/**
|
||||
* Put the provided Message into the MessageStore. Its id will
|
||||
* be used as an index so that the {@link #get(Object)} and
|
||||
* be used as an index so that the {@link #get(UUID)} and
|
||||
* {@link #delete(Object)} behave properly. If available, its
|
||||
* correlationId header will also be stored so that the
|
||||
* {@link #list(Object)} method behaves properly.
|
||||
@@ -51,7 +53,7 @@ public interface MessageStore {
|
||||
* if present, and return it. If no Message with that id is
|
||||
* present in the store, this will return <i>null</i>.
|
||||
*/
|
||||
Message<?> delete(Object id);
|
||||
Message<?> delete(UUID id);
|
||||
|
||||
/**
|
||||
* Return all Messages currently in the MessageStore.
|
||||
|
||||
@@ -16,17 +16,18 @@
|
||||
|
||||
package org.springframework.integration.store;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.util.UpperBound;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessagingException;
|
||||
import org.springframework.integration.util.UpperBound;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Map-based implementation of {@link MessageStore} that enforces a maximum capacity.
|
||||
*
|
||||
@@ -36,7 +37,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
*/
|
||||
public class SimpleMessageStore implements MessageStore {
|
||||
|
||||
private final Map<Object, Message<?>> map;
|
||||
private final Map<UUID, Message<?>> map;
|
||||
private final UpperBound upperBound;
|
||||
|
||||
/**
|
||||
@@ -44,7 +45,7 @@ public class SimpleMessageStore implements MessageStore {
|
||||
* size if the given capacity is less than 1.
|
||||
*/
|
||||
public SimpleMessageStore(int capacity) {
|
||||
this.map = new ConcurrentHashMap<Object, Message<?>>();
|
||||
this.map = new ConcurrentHashMap<UUID, Message<?>>();
|
||||
this.upperBound = new UpperBound(capacity);
|
||||
}
|
||||
|
||||
@@ -65,7 +66,7 @@ public class SimpleMessageStore implements MessageStore {
|
||||
return (Message<T>) this.map.put(message.getHeaders().getId(), message);
|
||||
}
|
||||
|
||||
public Message<?> get(Object key) {
|
||||
public Message<?> get(UUID key) {
|
||||
return (key != null) ? this.map.get(key) : null;
|
||||
}
|
||||
|
||||
@@ -73,7 +74,7 @@ public class SimpleMessageStore implements MessageStore {
|
||||
return new ArrayList<Message<?>>(this.map.values());
|
||||
}
|
||||
|
||||
public Message<?> delete(Object key) {
|
||||
public Message<?> delete(UUID key) {
|
||||
if (key != null) {
|
||||
upperBound.release();
|
||||
return this.map.remove(key);
|
||||
|
||||
Reference in New Issue
Block a user