INT-1964 added DEBUG level logging to the doPoll() method in PollingConsumer and SourcePollingChannelAdapter

This commit is contained in:
Oleg Zhurakousky
2011-07-08 09:54:55 -04:00
parent 1a0e823e0c
commit 16ebc11697
2 changed files with 22 additions and 0 deletions

View File

@@ -16,6 +16,9 @@
package org.springframework.integration.endpoint;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.Message;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.PollableChannel;
@@ -30,6 +33,8 @@ import org.springframework.util.Assert;
*/
public class PollingConsumer extends AbstractPollingEndpoint {
private final Log logger = LogFactory.getLog(this.getClass());
private final PollableChannel inputChannel;
private final MessageHandler handler;
@@ -53,7 +58,13 @@ public class PollingConsumer extends AbstractPollingEndpoint {
Message<?> message = (this.receiveTimeout >= 0)
? this.inputChannel.receive(this.receiveTimeout)
: this.inputChannel.receive();
if (this.logger.isDebugEnabled()){
this.logger.debug("Poll resulted in Message: " + message);
}
if (message == null) {
if (this.logger.isDebugEnabled()){
this.logger.debug("Received no Message during the poll, returning 'false'");
}
return false;
}
this.handler.handleMessage(message);

View File

@@ -16,6 +16,9 @@
package org.springframework.integration.endpoint;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.integration.Message;
import org.springframework.integration.MessageChannel;
import org.springframework.integration.context.NamedComponent;
@@ -33,6 +36,8 @@ import org.springframework.util.Assert;
* @author Oleg Zhurakousky
*/
public class SourcePollingChannelAdapter extends AbstractPollingEndpoint implements TrackableComponent {
private final Log logger = LogFactory.getLog(this.getClass());
private volatile MessageSource<?> source;
@@ -87,6 +92,9 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint impleme
@Override
protected boolean doPoll() {
Message<?> message = this.source.receive();
if (this.logger.isDebugEnabled()){
this.logger.debug("Poll resulted in Message: " + message);
}
if (message != null) {
if (this.shouldTrack) {
message = MessageHistory.write(message, this);
@@ -94,6 +102,9 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint impleme
this.messagingTemplate.send(this.outputChannel, message);
return true;
}
if (this.logger.isDebugEnabled()){
this.logger.debug("Received no Message during the poll, returning 'false'");
}
return false;
}
}