Added AbstractMessageConsumingEndpoint. MessageDispatchers now expect MessageConsumer instances as subscribers, and the MessageEndpoint no longer has a send() method or a getSource() method. All consumer endpoints now use 'inputChannel' as the property (instead of source). The MessageBus is less involved in endpoint activation now, since endpoints that need to poll a channel can create, configure, and schedule their own poller.
This commit is contained in:
@@ -23,7 +23,7 @@ import java.io.OutputStream;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.endpoint.AbstractMessageConsumingEndpoint;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessagingException;
|
||||
|
||||
@@ -32,7 +32,7 @@ import org.springframework.integration.message.MessagingException;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class ByteStreamTarget extends AbstractEndpoint {
|
||||
public class ByteStreamTarget extends AbstractMessageConsumingEndpoint {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
@@ -54,13 +54,13 @@ public class ByteStreamTarget extends AbstractEndpoint {
|
||||
|
||||
|
||||
@Override
|
||||
public boolean sendInternal(Message message) {
|
||||
public void processMessage(Message<?> message) {
|
||||
Object payload = message.getPayload();
|
||||
if (payload == null) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn(this.getClass().getSimpleName() + " received null object");
|
||||
}
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (payload instanceof String) {
|
||||
@@ -74,7 +74,6 @@ public class ByteStreamTarget extends AbstractEndpoint {
|
||||
" only supports byte array and String-based messages");
|
||||
}
|
||||
this.stream.flush();
|
||||
return true;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new MessagingException("IO failure occurred in target", e);
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.integration.ConfigurationException;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.endpoint.AbstractMessageConsumingEndpoint;
|
||||
import org.springframework.integration.message.Message;
|
||||
import org.springframework.integration.message.MessagingException;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -41,7 +41,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class CharacterStreamTarget extends AbstractEndpoint {
|
||||
public class CharacterStreamTarget extends AbstractMessageConsumingEndpoint {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
@@ -118,13 +118,13 @@ public class CharacterStreamTarget extends AbstractEndpoint {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean sendInternal(Message message) {
|
||||
public void processMessage(Message<?> message) {
|
||||
Object payload = message.getPayload();
|
||||
if (payload == null) {
|
||||
if (logger.isWarnEnabled()) {
|
||||
logger.warn("target received null payload");
|
||||
}
|
||||
return false;
|
||||
return;
|
||||
}
|
||||
try {
|
||||
if (payload instanceof String) {
|
||||
@@ -143,7 +143,6 @@ public class CharacterStreamTarget extends AbstractEndpoint {
|
||||
writer.newLine();
|
||||
}
|
||||
writer.flush();
|
||||
return true;
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new MessagingException("IO failure occurred in target", e);
|
||||
|
||||
@@ -72,10 +72,10 @@ public class ConsoleTargetParser extends AbstractSingleBeanDefinitionParser {
|
||||
}
|
||||
String channelName = element.getAttribute("channel");
|
||||
if (StringUtils.hasText(channelName)) {
|
||||
builder.addPropertyReference("source", channelName);
|
||||
builder.addPropertyReference("inputChannel", channelName);
|
||||
}
|
||||
else {
|
||||
builder.addPropertyReference("source", this.createDirectChannel(element, parserContext));
|
||||
builder.addPropertyReference("inputChannel", this.createDirectChannel(element, parserContext));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user