diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/MessageChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/MessageChannel.java
index 69bb51bf7f..25482e11f7 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/channel/MessageChannel.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/MessageChannel.java
@@ -19,14 +19,20 @@ package org.springframework.integration.channel;
import org.springframework.integration.message.Message;
/**
- * Base channel interface defining common behavior for message reception and sending.
+ * Base channel interface defining common behavior for message sending and receiving.
*
* @author Mark Fisher
*/
public interface MessageChannel {
+ /**
+ * Set the name of this channel. Must be unique within a context.
+ */
void setName(String name);
+ /**
+ * Return the name of this channel.
+ */
String getName();
/**
@@ -34,41 +40,40 @@ public interface MessageChannel {
*
* @param message the {@link Message} to send
*
- * @return true if the message is sent
- * successfully, false if interrupted
+ * @return true if the message is sent successfully,
+ * false if interrupted
*/
boolean send(Message message);
/**
- * Send a message, blocking until either the message is
- * accepted or the specified timeout period elapses.
+ * Send a message, blocking until either the message is accepted or the
+ * specified timeout period elapses.
*
* @param message the {@link Message} to send
* @param timeout the timeout in milliseconds
*
- * @return true if the message is sent
- * successfully, false if the specified
- * timeout period elapses or the send is interrupted
+ * @return true if the message is sent successfully,
+ * false if the specified timeout period elapses or
+ * the send is interrupted
*/
boolean send(Message message, long timeout);
/**
* Receive a message, blocking indefinitely if necessary.
*
- * @return the next available {@link Message} or
- * null if interrupted
+ * @return the next available {@link Message} or null if
+ * interrupted
*/
Message receive();
/**
- * Receive a message, blocking until either a message is
- * available or the specified timeout period elapses.
+ * Receive a message, blocking until either a message is available or the
+ * specified timeout period elapses.
*
* @param timeout the timeout in milliseconds
*
- * @return the next available {@link Message} or
- * null if the specified timeout period
- * elapses or the message reception is interrupted
+ * @return the next available {@link Message} or null if the
+ * specified timeout period elapses or the message reception is interrupted
*/
Message receive(long timeout);
diff --git a/spring-integration-core/src/main/java/org/springframework/integration/channel/PointToPointChannel.java b/spring-integration-core/src/main/java/org/springframework/integration/channel/PointToPointChannel.java
index 62ab1c1139..e89caf7100 100644
--- a/spring-integration-core/src/main/java/org/springframework/integration/channel/PointToPointChannel.java
+++ b/spring-integration-core/src/main/java/org/springframework/integration/channel/PointToPointChannel.java
@@ -35,17 +35,15 @@ public class PointToPointChannel implements MessageChannel, BeanNameAware {
private static final int DEFAULT_CAPACITY = 25;
-
private String name;
- private BlockingQueue queue;
-
+ private BlockingQueue> queue;
/**
* Create a channel with the specified queue capacity.
*/
public PointToPointChannel(int capacity) {
- queue = new LinkedBlockingQueue(capacity);
+ queue = new LinkedBlockingQueue>(capacity);
}
/**
@@ -56,17 +54,29 @@ public class PointToPointChannel implements MessageChannel, BeanNameAware {
}
+ /**
+ * Set the name of this channel.
+ */
public void setName(String name) {
this.name = name;
}
+ /**
+ * Return the name of this channel.
+ */
public String getName() {
return this.name;
}
+ /**
+ * Set the name of this channel to its bean name. This will be invoked
+ * automatically whenever the channel is configured explicitly with a bean
+ * definition.
+ */
public void setBeanName(String beanName) {
this.setName(beanName);
}
+
/**
* Send a message on this channel. If the queue is full, this method will
* block until either space becomes available or the sending thread is
@@ -173,7 +183,7 @@ public class PointToPointChannel implements MessageChannel, BeanNameAware {
while (timeout <= 0 || System.currentTimeMillis() - start < timeout) {
Object[] elements = this.queue.toArray();
for (int i = (elements.length - 1); i >= 0; i--) {
- Message m = (Message) elements[i];
+ Message> m = (Message>) elements[i];
if (selector.accept(m) && this.queue.remove(m)) {
return m;
}
diff --git a/spring-integration-core/src/test/java/org/springframework/integration/bus/FixedRateConsumerTests.java b/spring-integration-core/src/test/java/org/springframework/integration/bus/FixedRateConsumerTests.java
index 52e5e42613..31bfc9e5f4 100644
--- a/spring-integration-core/src/test/java/org/springframework/integration/bus/FixedRateConsumerTests.java
+++ b/spring-integration-core/src/test/java/org/springframework/integration/bus/FixedRateConsumerTests.java
@@ -99,7 +99,7 @@ public class FixedRateConsumerTests {
}
latch.await(80, TimeUnit.MILLISECONDS);
int count = counter.get();
- assertTrue("received " + count + ", but expected less than 6", count < 6);
+ assertTrue("received " + count + ", but expected less than 7", count < 7);
assertTrue("received " + count + ", but expected more than 3", count > 3);
}