INT-1129 renamed MessageChannelTemplate to MessagingTemplate
This commit is contained in:
@@ -20,7 +20,7 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.core.MessageHeaders;
|
||||
@@ -41,7 +41,7 @@ public abstract class AbstractAggregatingMessageGroupProcessor implements Messag
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public final void processAndSend(MessageGroup group, MessageChannelTemplate channelTemplate,
|
||||
public final void processAndSend(MessageGroup group, MessagingTemplate channelTemplate,
|
||||
MessageChannel outputChannel) {
|
||||
Assert.notNull(group, "MessageGroup must not be null");
|
||||
Assert.notNull(outputChannel, "'outputChannel' must not be null");
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.concurrent.ConcurrentMap;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.integration.channel.ChannelResolver;
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.channel.NullChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
@@ -51,11 +51,9 @@ import org.springframework.util.Assert;
|
||||
* @author Dave Syer
|
||||
* @since 2.0
|
||||
*/
|
||||
public class CorrelatingMessageHandler extends AbstractMessageHandler implements
|
||||
MessageProducer {
|
||||
public class CorrelatingMessageHandler extends AbstractMessageHandler implements MessageProducer {
|
||||
|
||||
private static final Log logger = LogFactory
|
||||
.getLog(CorrelatingMessageHandler.class);
|
||||
private static final Log logger = LogFactory.getLog(CorrelatingMessageHandler.class);
|
||||
|
||||
public static final long DEFAULT_SEND_TIMEOUT = 1000L;
|
||||
|
||||
@@ -63,6 +61,7 @@ public class CorrelatingMessageHandler extends AbstractMessageHandler implements
|
||||
|
||||
public static final long DEFAULT_TIMEOUT = 60000L;
|
||||
|
||||
|
||||
private MessageGroupStore messageStore;
|
||||
|
||||
private final MessageGroupProcessor outputProcessor;
|
||||
@@ -73,7 +72,7 @@ public class CorrelatingMessageHandler extends AbstractMessageHandler implements
|
||||
|
||||
private MessageChannel outputChannel;
|
||||
|
||||
private final MessageChannelTemplate channelTemplate = new MessageChannelTemplate();
|
||||
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
|
||||
private volatile MessageChannel discardChannel = new NullChannel();
|
||||
|
||||
@@ -81,23 +80,19 @@ public class CorrelatingMessageHandler extends AbstractMessageHandler implements
|
||||
|
||||
private final ConcurrentMap<Object, Object> locks = new ConcurrentHashMap<Object, Object>();
|
||||
|
||||
public CorrelatingMessageHandler(MessageGroupProcessor processor,
|
||||
MessageGroupStore store, CorrelationStrategy correlationStrategy,
|
||||
ReleaseStrategy releaseStrategy) {
|
||||
Assert.notNull(store);
|
||||
public CorrelatingMessageHandler(MessageGroupProcessor processor, MessageGroupStore store,
|
||||
CorrelationStrategy correlationStrategy, ReleaseStrategy releaseStrategy) {
|
||||
Assert.notNull(processor);
|
||||
Assert.notNull(store);
|
||||
setMessageStore(store);
|
||||
this.outputProcessor = processor;
|
||||
this.correlationStrategy = correlationStrategy == null ? new HeaderAttributeCorrelationStrategy(
|
||||
MessageHeaders.CORRELATION_ID)
|
||||
: correlationStrategy;
|
||||
this.releaseStrategy = releaseStrategy == null ? new SequenceSizeReleaseStrategy()
|
||||
: releaseStrategy;
|
||||
this.channelTemplate.setSendTimeout(DEFAULT_SEND_TIMEOUT);
|
||||
this.correlationStrategy = correlationStrategy == null ?
|
||||
new HeaderAttributeCorrelationStrategy(MessageHeaders.CORRELATION_ID) : correlationStrategy;
|
||||
this.releaseStrategy = releaseStrategy == null ? new SequenceSizeReleaseStrategy() : releaseStrategy;
|
||||
this.messagingTemplate.setSendTimeout(DEFAULT_SEND_TIMEOUT);
|
||||
}
|
||||
|
||||
public CorrelatingMessageHandler(MessageGroupProcessor processor,
|
||||
MessageGroupStore store) {
|
||||
public CorrelatingMessageHandler(MessageGroupProcessor processor, MessageGroupStore store) {
|
||||
this(processor, store, null, null);
|
||||
}
|
||||
|
||||
@@ -138,7 +133,7 @@ public class CorrelatingMessageHandler extends AbstractMessageHandler implements
|
||||
}
|
||||
|
||||
public void setSendTimeout(long sendTimeout) {
|
||||
this.channelTemplate.setSendTimeout(sendTimeout);
|
||||
this.messagingTemplate.setSendTimeout(sendTimeout);
|
||||
}
|
||||
|
||||
public void setSendPartialResultOnExpiry(boolean sendPartialResultOnExpiry) {
|
||||
@@ -162,24 +157,19 @@ public class CorrelatingMessageHandler extends AbstractMessageHandler implements
|
||||
// TODO: INT-1117 - make the lock global?
|
||||
Object lock = getLock(correlationKey);
|
||||
synchronized (lock) {
|
||||
|
||||
MessageGroup group = messageStore.getMessageGroup(correlationKey);
|
||||
|
||||
if (group.canAdd(message)) {
|
||||
|
||||
group = store(correlationKey, message);
|
||||
|
||||
if (releaseStrategy.canRelease(group)) {
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("Completing group with correlationKey ["
|
||||
+ correlationKey + "]");
|
||||
}
|
||||
try {
|
||||
outputProcessor.processAndSend(group, channelTemplate,
|
||||
this.resolveReplyChannel(message,
|
||||
this.outputChannel));
|
||||
} finally {
|
||||
outputProcessor.processAndSend(group, messagingTemplate,
|
||||
this.resolveReplyChannel(message, this.outputChannel));
|
||||
}
|
||||
finally {
|
||||
|
||||
// Always clean up even if there was an exception
|
||||
// processing messages
|
||||
@@ -187,34 +177,31 @@ public class CorrelatingMessageHandler extends AbstractMessageHandler implements
|
||||
// The group is complete or else there is no
|
||||
// sequence so there is no more state to track
|
||||
remove(group);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Mark these messages as processed, but do not
|
||||
// remove the group from store
|
||||
mark(group);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else if (group.isComplete()) {
|
||||
|
||||
}
|
||||
else if (group.isComplete()) {
|
||||
try {
|
||||
// If not releasing any messages the group might still
|
||||
// be complete
|
||||
for (Message<?> discard : group.getUnmarked()) {
|
||||
discardChannel.send(discard);
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
remove(group);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
discardChannel.send(message);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private final boolean forceComplete(MessageGroup group) {
|
||||
@@ -227,43 +214,36 @@ public class CorrelatingMessageHandler extends AbstractMessageHandler implements
|
||||
// last chance for normal completion
|
||||
try {
|
||||
if (releaseStrategy.canRelease(group)) {
|
||||
outputProcessor.processAndSend(group, channelTemplate,
|
||||
resolveReplyChannel(group.getOne(),
|
||||
this.outputChannel));
|
||||
} else {
|
||||
outputProcessor.processAndSend(group, messagingTemplate,
|
||||
resolveReplyChannel(group.getOne(), this.outputChannel));
|
||||
}
|
||||
else {
|
||||
if (sendPartialResultOnExpiry) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger
|
||||
.info("Processing partially complete messages for key ["
|
||||
+ correlationKey
|
||||
+ "] to: "
|
||||
+ outputChannel);
|
||||
logger.info("Processing partially complete messages for key ["
|
||||
+ correlationKey + "] to: " + outputChannel);
|
||||
}
|
||||
outputProcessor.processAndSend(group,
|
||||
channelTemplate, resolveReplyChannel(group
|
||||
.getOne(), this.outputChannel));
|
||||
} else {
|
||||
outputProcessor.processAndSend(group, messagingTemplate,
|
||||
resolveReplyChannel(group.getOne(), this.outputChannel));
|
||||
}
|
||||
else {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger
|
||||
.info("Discarding partially complete messages for key ["
|
||||
+ correlationKey
|
||||
+ "] to: "
|
||||
+ discardChannel);
|
||||
logger.info("Discarding partially complete messages for key ["
|
||||
+ correlationKey + "] to: " + discardChannel);
|
||||
}
|
||||
for (Message<?> message : group.getUnmarked()) {
|
||||
discardChannel.send(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
remove(group);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private Object getLock(Object correlationKey) {
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.aggregator;
|
||||
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
|
||||
@@ -13,10 +26,11 @@ import org.springframework.integration.store.MessageGroup;
|
||||
public interface MessageGroupProcessor {
|
||||
|
||||
/**
|
||||
* Process the given group and send the resulting message(s) to the output channel using the channel template.
|
||||
* Process the given group and send the resulting message(s) to the output channel using the messaging template.
|
||||
* Implementations are free to send as little or as many messages based on the invocation as needed. For example an
|
||||
* aggregating processor will send only a single message representing the group, where a resequencing strategy will
|
||||
* send all messages in the group individually.
|
||||
*/
|
||||
void processAndSend(MessageGroup group, MessageChannelTemplate channelTemplate, MessageChannel outputChannel);
|
||||
}
|
||||
void processAndSend(MessageGroup group, MessagingTemplate messagingTemplate, MessageChannel outputChannel);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,19 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
|
||||
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.aggregator;
|
||||
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
@@ -15,9 +28,9 @@ import org.springframework.integration.store.MessageGroup;
|
||||
*/
|
||||
public class PassThroughMessageGroupProcessor implements MessageGroupProcessor {
|
||||
|
||||
public void processAndSend(MessageGroup group, MessageChannelTemplate channelTemplate, MessageChannel outputChannel) {
|
||||
public void processAndSend(MessageGroup group, MessagingTemplate messagingTemplate, MessageChannel outputChannel) {
|
||||
for (Message<?> message : group.getUnmarked()) {
|
||||
channelTemplate.send(message, outputChannel);
|
||||
messagingTemplate.send(message, outputChannel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
@@ -45,13 +45,13 @@ public class ResequencingMessageGroupProcessor implements MessageGroupProcessor
|
||||
this.comparator = comparator;
|
||||
}
|
||||
|
||||
public void processAndSend(MessageGroup group, MessageChannelTemplate channelTemplate, MessageChannel outputChannel) {
|
||||
public void processAndSend(MessageGroup group, MessagingTemplate messagingTemplate, MessageChannel outputChannel) {
|
||||
Collection<Message<?>> messages = group.getUnmarked();
|
||||
if (messages.size() > 0) {
|
||||
List<Message<?>> sorted = new ArrayList<Message<?>>(messages);
|
||||
Collections.sort(sorted, comparator);
|
||||
for (Message<?> message : sorted) {
|
||||
channelTemplate.send(message, outputChannel);
|
||||
messagingTemplate.send(message, outputChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.expression.spel.SpelParserConfiguration;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.integration.channel.ChannelResolver;
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
@@ -51,7 +51,7 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class MessagePublishingInterceptor implements MethodInterceptor {
|
||||
|
||||
private final MessageChannelTemplate channelTemplate = new MessageChannelTemplate();
|
||||
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
|
||||
private volatile ExpressionSource expressionSource;
|
||||
|
||||
@@ -72,7 +72,7 @@ public class MessagePublishingInterceptor implements MethodInterceptor {
|
||||
}
|
||||
|
||||
public void setDefaultChannel(MessageChannel defaultChannel) {
|
||||
this.channelTemplate.setDefaultChannel(defaultChannel);
|
||||
this.messagingTemplate.setDefaultChannel(defaultChannel);
|
||||
}
|
||||
|
||||
public void setChannelResolver(ChannelResolver channelResolver) {
|
||||
@@ -136,10 +136,10 @@ public class MessagePublishingInterceptor implements MethodInterceptor {
|
||||
channel = this.channelResolver.resolveChannelName(channelName);
|
||||
}
|
||||
if (channel != null) {
|
||||
this.channelTemplate.send(message, channel);
|
||||
this.messagingTemplate.send(message, channel);
|
||||
}
|
||||
else {
|
||||
this.channelTemplate.send(message);
|
||||
this.messagingTemplate.send(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class MessageChannelTemplate implements InitializingBean {
|
||||
public class MessagingTemplate implements InitializingBean {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
@@ -79,13 +79,13 @@ public class MessageChannelTemplate implements InitializingBean {
|
||||
* Create a MessageChannelTemplate with no default channel. Note, that one
|
||||
* may be provided by invoking {@link #setDefaultChannel(MessageChannel)}.
|
||||
*/
|
||||
public MessageChannelTemplate() {
|
||||
public MessagingTemplate() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a MessageChannelTemplate with the given default channel.
|
||||
*/
|
||||
public MessageChannelTemplate(MessageChannel defaultChannel) {
|
||||
public MessagingTemplate(MessageChannel defaultChannel) {
|
||||
this.defaultChannel = defaultChannel;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.endpoint;
|
||||
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.core.MessageProducer;
|
||||
@@ -32,7 +32,7 @@ public abstract class MessageProducerSupport extends AbstractEndpoint implements
|
||||
|
||||
private volatile MessageChannel outputChannel;
|
||||
|
||||
private final MessageChannelTemplate channelTemplate = new MessageChannelTemplate();
|
||||
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
|
||||
|
||||
public void setOutputChannel(MessageChannel outputChannel) {
|
||||
@@ -40,7 +40,7 @@ public abstract class MessageProducerSupport extends AbstractEndpoint implements
|
||||
}
|
||||
|
||||
public void setSendTimeout(long sendTimeout) {
|
||||
this.channelTemplate.setSendTimeout(sendTimeout);
|
||||
this.messagingTemplate.setSendTimeout(sendTimeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -52,7 +52,7 @@ public abstract class MessageProducerSupport extends AbstractEndpoint implements
|
||||
if (message != null) {
|
||||
message.getHeaders().getHistory().addEvent(this);
|
||||
}
|
||||
return this.channelTemplate.send(message, this.outputChannel);
|
||||
return this.messagingTemplate.send(message, this.outputChannel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.endpoint;
|
||||
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageSource;
|
||||
@@ -34,7 +34,7 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint {
|
||||
|
||||
private volatile MessageChannel outputChannel;
|
||||
|
||||
private final MessageChannelTemplate channelTemplate = new MessageChannelTemplate();
|
||||
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint {
|
||||
* output channel.
|
||||
*/
|
||||
public void setSendTimeout(long sendTimeout) {
|
||||
this.channelTemplate.setSendTimeout(sendTimeout);
|
||||
this.messagingTemplate.setSendTimeout(sendTimeout);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -75,7 +75,7 @@ public class SourcePollingChannelAdapter extends AbstractPollingEndpoint {
|
||||
protected boolean doPoll() {
|
||||
Message<?> message = this.source.receive();
|
||||
if (message != null) {
|
||||
return this.channelTemplate.send(message, this.outputChannel);
|
||||
return this.messagingTemplate.send(message, this.outputChannel);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.gateway;
|
||||
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.channel.SubscribableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
@@ -52,7 +52,7 @@ public abstract class AbstractMessagingGateway extends AbstractEndpoint {
|
||||
|
||||
private volatile long replyTimeout = 1000;
|
||||
|
||||
private final MessageChannelTemplate channelTemplate = new MessageChannelTemplate();
|
||||
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
|
||||
private volatile boolean shouldThrowErrors = true;
|
||||
|
||||
@@ -93,7 +93,7 @@ public abstract class AbstractMessagingGateway extends AbstractEndpoint {
|
||||
* @param requestTimeout the timeout value in milliseconds
|
||||
*/
|
||||
public void setRequestTimeout(long requestTimeout) {
|
||||
this.channelTemplate.setSendTimeout(requestTimeout);
|
||||
this.messagingTemplate.setSendTimeout(requestTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,7 +104,7 @@ public abstract class AbstractMessagingGateway extends AbstractEndpoint {
|
||||
*/
|
||||
public void setReplyTimeout(long replyTimeout) {
|
||||
this.replyTimeout = replyTimeout;
|
||||
this.channelTemplate.setReceiveTimeout(replyTimeout);
|
||||
this.messagingTemplate.setReceiveTimeout(replyTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,7 +144,7 @@ public abstract class AbstractMessagingGateway extends AbstractEndpoint {
|
||||
"send is not supported, because no request channel has been configured");
|
||||
Message<?> message = this.toMessage(object);
|
||||
Assert.notNull(message, "message must not be null");
|
||||
if (!this.channelTemplate.send(message, this.requestChannel)) {
|
||||
if (!this.messagingTemplate.send(message, this.requestChannel)) {
|
||||
throw new MessageDeliveryException(message, "failed to send Message to channel");
|
||||
}
|
||||
}
|
||||
@@ -153,7 +153,7 @@ public abstract class AbstractMessagingGateway extends AbstractEndpoint {
|
||||
this.initializeIfNecessary();
|
||||
Assert.state(this.replyChannel != null && (this.replyChannel instanceof PollableChannel),
|
||||
"receive is not supported, because no pollable reply channel has been configured");
|
||||
Message<?> message = this.channelTemplate.receive((PollableChannel) this.replyChannel);
|
||||
Message<?> message = this.messagingTemplate.receive((PollableChannel) this.replyChannel);
|
||||
try {
|
||||
return this.fromMessage(message);
|
||||
}
|
||||
@@ -195,7 +195,7 @@ public abstract class AbstractMessagingGateway extends AbstractEndpoint {
|
||||
Message<?> reply = null;
|
||||
Throwable error = null;
|
||||
try {
|
||||
reply = this.channelTemplate.sendAndReceive(message, this.requestChannel);
|
||||
reply = this.messagingTemplate.sendAndReceive(message, this.requestChannel);
|
||||
if (reply instanceof ErrorMessage) {
|
||||
error = ((ErrorMessage) reply).getPayload();
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.integration.handler;
|
||||
|
||||
import org.springframework.integration.channel.ChannelResolver;
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.core.MessageHeaders;
|
||||
@@ -34,8 +34,7 @@ import org.springframework.util.Assert;
|
||||
* @author Iwein Fuld
|
||||
* @author Oleg Zhurakousky
|
||||
*/
|
||||
public abstract class AbstractReplyProducingMessageHandler extends AbstractMessageHandler
|
||||
implements MessageProducer {
|
||||
public abstract class AbstractReplyProducingMessageHandler extends AbstractMessageHandler implements MessageProducer {
|
||||
|
||||
public static final long DEFAULT_SEND_TIMEOUT = 1000;
|
||||
|
||||
@@ -44,12 +43,12 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
|
||||
|
||||
private volatile boolean requiresReply = false;
|
||||
|
||||
private final MessageChannelTemplate channelTemplate;
|
||||
private final MessagingTemplate messagingTemplate;
|
||||
|
||||
|
||||
public AbstractReplyProducingMessageHandler() {
|
||||
this.channelTemplate = new MessageChannelTemplate();
|
||||
this.channelTemplate.setSendTimeout(DEFAULT_SEND_TIMEOUT);
|
||||
this.messagingTemplate = new MessagingTemplate();
|
||||
this.messagingTemplate.setSendTimeout(DEFAULT_SEND_TIMEOUT);
|
||||
}
|
||||
|
||||
|
||||
@@ -65,7 +64,7 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
|
||||
* Set the timeout for sending reply Messages.
|
||||
*/
|
||||
public void setSendTimeout(long sendTimeout) {
|
||||
this.channelTemplate.setSendTimeout(sendTimeout);
|
||||
this.messagingTemplate.setSendTimeout(sendTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +128,7 @@ public abstract class AbstractReplyProducingMessageHandler extends AbstractMessa
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("handler '" + this + "' sending reply Message: " + replyMessage);
|
||||
}
|
||||
return this.channelTemplate.send(replyMessage, replyChannel);
|
||||
return this.messagingTemplate.send(replyMessage, replyChannel);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.core.Ordered;
|
||||
import org.springframework.integration.channel.BeanFactoryChannelResolver;
|
||||
import org.springframework.integration.channel.ChannelResolutionException;
|
||||
import org.springframework.integration.channel.ChannelResolver;
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.integration.core.Message;
|
||||
@@ -86,7 +86,7 @@ public class DelayHandler extends IntegrationObjectSupport implements MessageHan
|
||||
|
||||
private volatile MessageStore messageStore;
|
||||
|
||||
private final MessageChannelTemplate channelTemplate = new MessageChannelTemplate();
|
||||
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
|
||||
private volatile int order = Ordered.LOWEST_PRECEDENCE;
|
||||
|
||||
@@ -152,7 +152,7 @@ public class DelayHandler extends IntegrationObjectSupport implements MessageHan
|
||||
* Set the timeout for sending reply Messages.
|
||||
*/
|
||||
public void setSendTimeout(long sendTimeout) {
|
||||
this.channelTemplate.setSendTimeout(sendTimeout);
|
||||
this.messagingTemplate.setSendTimeout(sendTimeout);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -241,7 +241,7 @@ public class DelayHandler extends IntegrationObjectSupport implements MessageHan
|
||||
MessageChannel errorChannel = resolveErrorChannelIfPossible(message);
|
||||
if (errorChannel != null) {
|
||||
ErrorMessage errorMessage = new ErrorMessage(exception);
|
||||
boolean sent = channelTemplate.send(errorMessage, errorChannel);
|
||||
boolean sent = messagingTemplate.send(errorMessage, errorChannel);
|
||||
if (!sent && logger.isWarnEnabled()) {
|
||||
logger.warn("Failed to send MessageDeliveryException to error channel.", exception);
|
||||
}
|
||||
@@ -263,7 +263,7 @@ public class DelayHandler extends IntegrationObjectSupport implements MessageHan
|
||||
|
||||
private void sendMessageToReplyChannel(Message<?> message) {
|
||||
MessageChannel replyChannel = this.resolveReplyChannel(message);
|
||||
this.channelTemplate.send(message, replyChannel);
|
||||
this.messagingTemplate.send(message, replyChannel);
|
||||
}
|
||||
|
||||
private MessageChannel resolveReplyChannel(Message<?> message) {
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.integration.router;
|
||||
import java.util.Collection;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.core.MessageHeaders;
|
||||
@@ -42,7 +42,7 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler {
|
||||
|
||||
private volatile boolean applySequence;
|
||||
|
||||
private final MessageChannelTemplate channelTemplate = new MessageChannelTemplate();
|
||||
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
|
||||
|
||||
/**
|
||||
@@ -60,7 +60,7 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler {
|
||||
* default, there is no timeout, meaning the send will block indefinitely.
|
||||
*/
|
||||
public void setTimeout(long timeout) {
|
||||
this.channelTemplate.setSendTimeout(timeout);
|
||||
this.messagingTemplate.setSendTimeout(timeout);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +116,7 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler {
|
||||
.setHeader(MessageHeaders.ID, UUID.randomUUID())
|
||||
.build();
|
||||
if (channel != null) {
|
||||
if (this.channelTemplate.send(messageToSend, channel)) {
|
||||
if (this.messagingTemplate.send(messageToSend, channel)) {
|
||||
sent = true;
|
||||
}
|
||||
else if (!this.ignoreSendFailures) {
|
||||
@@ -128,7 +128,7 @@ public abstract class AbstractMessageRouter extends AbstractMessageHandler {
|
||||
}
|
||||
if (!sent) {
|
||||
if (this.defaultOutputChannel != null) {
|
||||
sent = this.channelTemplate.send(message, this.defaultOutputChannel);
|
||||
sent = this.messagingTemplate.send(message, this.defaultOutputChannel);
|
||||
}
|
||||
else if (this.resolutionRequired) {
|
||||
throw new MessageDeliveryException(message,
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
@@ -42,7 +42,7 @@ public class AggregatingMessageGroupProcessorHeaderTests {
|
||||
|
||||
private final QueueChannel outputChannel = new QueueChannel(1);
|
||||
|
||||
private final MessageChannelTemplate channelTemplate = new MessageChannelTemplate();
|
||||
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
|
||||
private final DefaultAggregatingMessageGroupProcessor defaultProcessor = new DefaultAggregatingMessageGroupProcessor();
|
||||
|
||||
@@ -107,7 +107,7 @@ public class AggregatingMessageGroupProcessorHeaderTests {
|
||||
Message<?> message = correlatedMessage(1, 1, 1, headers);
|
||||
List<Message<?>> messages = Collections.<Message<?>>singletonList(message);
|
||||
MessageGroup group = new SimpleMessageGroup(messages, 1);
|
||||
processor.processAndSend(group, channelTemplate, outputChannel);
|
||||
processor.processAndSend(group, messagingTemplate, outputChannel);
|
||||
Message<?> result = outputChannel.receive(0);
|
||||
assertNotNull(result);
|
||||
assertEquals("value1", result.getHeaders().get("k1"));
|
||||
@@ -122,7 +122,7 @@ public class AggregatingMessageGroupProcessorHeaderTests {
|
||||
Message<?> message2 = correlatedMessage(1, 2, 2, headers);
|
||||
List<Message<?>> messages = Arrays.<Message<?>>asList(message1, message2);
|
||||
MessageGroup group = new SimpleMessageGroup(messages, 1);
|
||||
processor.processAndSend(group, channelTemplate, outputChannel);
|
||||
processor.processAndSend(group, messagingTemplate, outputChannel);
|
||||
Message<?> result = outputChannel.receive(0);
|
||||
assertNotNull(result);
|
||||
assertEquals("value1", result.getHeaders().get("k1"));
|
||||
@@ -140,7 +140,7 @@ public class AggregatingMessageGroupProcessorHeaderTests {
|
||||
Message<?> message2 = correlatedMessage(1, 2, 2, headers2);
|
||||
List<Message<?>> messages = Arrays.<Message<?>>asList(message1, message2);
|
||||
MessageGroup group = new SimpleMessageGroup(messages, 1);
|
||||
processor.processAndSend(group, channelTemplate, outputChannel);
|
||||
processor.processAndSend(group, messagingTemplate, outputChannel);
|
||||
Message<?> result = outputChannel.receive(0);
|
||||
assertNotNull(result);
|
||||
assertNull(result.getHeaders().get("k1"));
|
||||
@@ -170,7 +170,7 @@ public class AggregatingMessageGroupProcessorHeaderTests {
|
||||
Message<?> message3 = correlatedMessage(1, 3, 3, headers3);
|
||||
List<Message<?>> messages = Arrays.<Message<?>>asList(message1, message2, message3);
|
||||
MessageGroup group = new SimpleMessageGroup(messages, 1);
|
||||
processor.processAndSend(group, channelTemplate, outputChannel);
|
||||
processor.processAndSend(group, messagingTemplate, outputChannel);
|
||||
Message<?> result = outputChannel.receive(0);
|
||||
assertNotNull(result);
|
||||
assertEquals("value1", result.getHeaders().get("only1"));
|
||||
@@ -198,7 +198,7 @@ public class AggregatingMessageGroupProcessorHeaderTests {
|
||||
Message<?> message3 = correlatedMessage(1, 3, 3, headers3);
|
||||
List<Message<?>> messages = Arrays.<Message<?>>asList(message1, message2, message3);
|
||||
MessageGroup group = new SimpleMessageGroup(messages, 1);
|
||||
processor.processAndSend(group, channelTemplate, outputChannel);
|
||||
processor.processAndSend(group, messagingTemplate, outputChannel);
|
||||
Message<?> result = outputChannel.receive(0);
|
||||
assertNotNull(result);
|
||||
assertEquals("valueForAll", result.getHeaders().get("common"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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. You may obtain a copy of the License at
|
||||
@@ -25,7 +25,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
@@ -231,18 +231,18 @@ public class AggregatorTests {
|
||||
}
|
||||
|
||||
private class MultiplyingProcessor implements MessageGroupProcessor {
|
||||
public void processAndSend(MessageGroup group, MessageChannelTemplate channelTemplate,
|
||||
public void processAndSend(MessageGroup group, MessagingTemplate messagingTemplate,
|
||||
MessageChannel outputChannel) {
|
||||
Integer product = 1;
|
||||
for (Message<?> message : group.getUnmarked()) {
|
||||
product *= (Integer) message.getPayload();
|
||||
}
|
||||
channelTemplate.send(MessageBuilder.withPayload(product).build(), outputChannel);
|
||||
messagingTemplate.send(MessageBuilder.withPayload(product).build(), outputChannel);
|
||||
}
|
||||
}
|
||||
|
||||
private class NullReturningMessageProcessor implements MessageGroupProcessor {
|
||||
public void processAndSend(MessageGroup group, MessageChannelTemplate channelTemplate,
|
||||
public void processAndSend(MessageGroup group, MessagingTemplate messagingTemplate,
|
||||
MessageChannel outputChannel) {
|
||||
// noop
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -30,7 +30,7 @@ import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.springframework.core.task.SimpleAsyncTaskExecutor;
|
||||
import org.springframework.core.task.TaskExecutor;
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
@@ -344,21 +344,19 @@ public class ConcurrentAggregatorTests {
|
||||
|
||||
private class MultiplyingProcessor implements MessageGroupProcessor {
|
||||
public void processAndSend(MessageGroup group,
|
||||
MessageChannelTemplate channelTemplate,
|
||||
MessagingTemplate messagingTemplate,
|
||||
MessageChannel outputChannel) {
|
||||
Integer product = 1;
|
||||
for (Message<?> message : group.getUnmarked()) {
|
||||
product *= (Integer) message.getPayload();
|
||||
}
|
||||
channelTemplate.send(MessageBuilder.withPayload(product).build(),
|
||||
outputChannel);
|
||||
messagingTemplate.send(MessageBuilder.withPayload(product).build(), outputChannel);
|
||||
}
|
||||
}
|
||||
|
||||
private class NullReturningMessageProcessor implements
|
||||
MessageGroupProcessor {
|
||||
private class NullReturningMessageProcessor implements MessageGroupProcessor {
|
||||
public void processAndSend(MessageGroup group,
|
||||
MessageChannelTemplate channelTemplate,
|
||||
MessagingTemplate messagingTemplate,
|
||||
MessageChannel outputChannel) {
|
||||
// noop
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ import org.mockito.Mock;
|
||||
import org.mockito.internal.stubbing.answers.DoesNothing;
|
||||
import org.mockito.internal.stubbing.answers.ThrowsException;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
import org.springframework.integration.message.MessageBuilder;
|
||||
@@ -75,7 +75,7 @@ public class CorrelatingMessageHandlerTests {
|
||||
ReleaseStrategy);
|
||||
handler.setOutputChannel(outputChannel);
|
||||
doAnswer(new DoesNothing()).when(processor).processAndSend(isA(SimpleMessageGroup.class),
|
||||
isA(MessageChannelTemplate.class), eq(outputChannel));
|
||||
isA(MessagingTemplate.class), eq(outputChannel));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,7 +94,7 @@ public class CorrelatingMessageHandlerTests {
|
||||
|
||||
verify(correlationStrategy).getCorrelationKey(message1);
|
||||
verify(correlationStrategy).getCorrelationKey(message2);
|
||||
verify(processor).processAndSend(isA(SimpleMessageGroup.class), isA(MessageChannelTemplate.class), eq(outputChannel));
|
||||
verify(processor).processAndSend(isA(SimpleMessageGroup.class), isA(MessagingTemplate.class), eq(outputChannel));
|
||||
}
|
||||
|
||||
private void verifyLocks(CorrelatingMessageHandler handler, int lockCount) {
|
||||
@@ -105,7 +105,7 @@ public class CorrelatingMessageHandlerTests {
|
||||
public void bufferCompletesWithException() throws Exception {
|
||||
|
||||
doAnswer(new ThrowsException(new RuntimeException("Planned test exception"))).when(processor).processAndSend(isA(SimpleMessageGroup.class),
|
||||
isA(MessageChannelTemplate.class), eq(outputChannel));
|
||||
isA(MessagingTemplate.class), eq(outputChannel));
|
||||
|
||||
String correlationKey = "key";
|
||||
Message<?> message1 = testMessage(correlationKey, 1, 2);
|
||||
@@ -124,7 +124,7 @@ public class CorrelatingMessageHandlerTests {
|
||||
|
||||
verify(correlationStrategy).getCorrelationKey(message1);
|
||||
verify(correlationStrategy).getCorrelationKey(message2);
|
||||
verify(processor).processAndSend(isA(SimpleMessageGroup.class), isA(MessageChannelTemplate.class), eq(outputChannel));
|
||||
verify(processor).processAndSend(isA(SimpleMessageGroup.class), isA(MessagingTemplate.class), eq(outputChannel));
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2002-2010 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.integration.aggregator;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.is;
|
||||
@@ -19,12 +35,13 @@ import org.junit.runner.RunWith;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
|
||||
import org.springframework.aop.framework.ProxyFactory;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.integration.annotation.Aggregator;
|
||||
import org.springframework.integration.annotation.Header;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
@@ -44,7 +61,7 @@ public class MethodInvokingMessageGroupProcessorTests {
|
||||
private MessageGroup messageGroupMock;
|
||||
|
||||
@Mock
|
||||
private MessageChannelTemplate channelTemplate;
|
||||
private MessagingTemplate messagingTemplate;
|
||||
|
||||
@Before
|
||||
public void initializeMessagesUpForProcessing() {
|
||||
@@ -77,9 +94,9 @@ public class MethodInvokingMessageGroupProcessorTests {
|
||||
ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
|
||||
when(outputChannel.send(isA(Message.class))).thenReturn(true);
|
||||
when(messageGroupMock.getUnmarked()).thenReturn(messagesUpForProcessing);
|
||||
processor.processAndSend(messageGroupMock, channelTemplate, outputChannel);
|
||||
processor.processAndSend(messageGroupMock, messagingTemplate, outputChannel);
|
||||
// verify
|
||||
verify(channelTemplate).send(messageCaptor.capture(), eq(outputChannel));
|
||||
verify(messagingTemplate).send(messageCaptor.capture(), eq(outputChannel));
|
||||
assertThat((Integer) messageCaptor.getValue().getPayload(), is(7));
|
||||
}
|
||||
|
||||
@@ -101,9 +118,9 @@ public class MethodInvokingMessageGroupProcessorTests {
|
||||
ArgumentCaptor<Message> messageCaptor = ArgumentCaptor.forClass(Message.class);
|
||||
when(outputChannel.send(isA(Message.class))).thenReturn(true);
|
||||
when(messageGroupMock.getUnmarked()).thenReturn(messagesUpForProcessing);
|
||||
processor.processAndSend(messageGroupMock, channelTemplate, outputChannel);
|
||||
processor.processAndSend(messageGroupMock, messagingTemplate, outputChannel);
|
||||
// verify
|
||||
verify(channelTemplate).send(messageCaptor.capture(), eq(outputChannel));
|
||||
verify(messagingTemplate).send(messageCaptor.capture(), eq(outputChannel));
|
||||
assertThat((Integer) messageCaptor.getValue().getPayload(), is(7));
|
||||
}
|
||||
|
||||
@@ -136,9 +153,9 @@ public class MethodInvokingMessageGroupProcessorTests {
|
||||
|
||||
when(outputChannel.send(isA(Message.class))).thenReturn(true);
|
||||
when(messageGroupMock.getUnmarked()).thenReturn(messagesUpForProcessing);
|
||||
processor.processAndSend(messageGroupMock, channelTemplate, outputChannel);
|
||||
processor.processAndSend(messageGroupMock, messagingTemplate, outputChannel);
|
||||
// verify
|
||||
verify(channelTemplate).send(messageCaptor.capture(), eq(outputChannel));
|
||||
verify(messagingTemplate).send(messageCaptor.capture(), eq(outputChannel));
|
||||
assertThat((Integer) messageCaptor.getValue().getPayload(), is(7));
|
||||
}
|
||||
|
||||
@@ -167,9 +184,9 @@ public class MethodInvokingMessageGroupProcessorTests {
|
||||
|
||||
when(outputChannel.send(isA(Message.class))).thenReturn(true);
|
||||
when(messageGroupMock.getUnmarked()).thenReturn(messagesUpForProcessing);
|
||||
processor.processAndSend(messageGroupMock, channelTemplate, outputChannel);
|
||||
processor.processAndSend(messageGroupMock, messagingTemplate, outputChannel);
|
||||
// verify
|
||||
verify(channelTemplate).send(messageCaptor.capture(), eq(outputChannel));
|
||||
verify(messagingTemplate).send(messageCaptor.capture(), eq(outputChannel));
|
||||
assertThat((Integer) messageCaptor.getValue().getPayload(), is(7));
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2009 the original author or authors.
|
||||
* Copyright 2002-2010 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.
|
||||
@@ -43,7 +43,7 @@ import org.springframework.scheduling.support.PeriodicTrigger;
|
||||
/**
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class MessageChannelTemplateTests {
|
||||
public class MessagingTemplateTests {
|
||||
|
||||
private TestApplicationContext context = TestUtils.createTestApplicationContext();
|
||||
|
||||
@@ -78,7 +78,7 @@ public class MessageChannelTemplateTests {
|
||||
|
||||
@Test
|
||||
public void send() {
|
||||
MessageChannelTemplate template = new MessageChannelTemplate();
|
||||
MessagingTemplate template = new MessagingTemplate();
|
||||
QueueChannel channel = new QueueChannel();
|
||||
template.send(new StringMessage("test"), channel);
|
||||
Message<?> reply = channel.receive(0);
|
||||
@@ -89,7 +89,7 @@ public class MessageChannelTemplateTests {
|
||||
@Test
|
||||
public void sendWithDefaultChannelProvidedBySetter() {
|
||||
QueueChannel channel = new QueueChannel();
|
||||
MessageChannelTemplate template = new MessageChannelTemplate();
|
||||
MessagingTemplate template = new MessagingTemplate();
|
||||
template.setDefaultChannel(channel);
|
||||
template.send(new StringMessage("test"));
|
||||
Message<?> reply = channel.receive(0);
|
||||
@@ -100,7 +100,7 @@ public class MessageChannelTemplateTests {
|
||||
@Test
|
||||
public void sendWithDefaultChannelProvidedByConstructor() {
|
||||
QueueChannel channel = new QueueChannel();
|
||||
MessageChannelTemplate template = new MessageChannelTemplate(channel);
|
||||
MessagingTemplate template = new MessagingTemplate(channel);
|
||||
template.send(new StringMessage("test"));
|
||||
Message<?> reply = channel.receive(0);
|
||||
assertNotNull(reply);
|
||||
@@ -111,7 +111,7 @@ public class MessageChannelTemplateTests {
|
||||
public void sendWithExplicitChannelTakesPrecedenceOverDefault() {
|
||||
QueueChannel explicitChannel = new QueueChannel();
|
||||
QueueChannel defaultChannel = new QueueChannel();
|
||||
MessageChannelTemplate template = new MessageChannelTemplate(defaultChannel);
|
||||
MessagingTemplate template = new MessagingTemplate(defaultChannel);
|
||||
template.send(new StringMessage("test"), explicitChannel);
|
||||
Message<?> reply = explicitChannel.receive(0);
|
||||
assertNotNull(reply);
|
||||
@@ -121,7 +121,7 @@ public class MessageChannelTemplateTests {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void sendWithoutChannelArgFailsIfNoDefaultAvailable() {
|
||||
MessageChannelTemplate template = new MessageChannelTemplate();
|
||||
MessagingTemplate template = new MessagingTemplate();
|
||||
template.send(new StringMessage("test"));
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ public class MessageChannelTemplateTests {
|
||||
public void receive() {
|
||||
QueueChannel channel = new QueueChannel();
|
||||
channel.send(new StringMessage("test"));
|
||||
MessageChannelTemplate template = new MessageChannelTemplate();
|
||||
MessagingTemplate template = new MessagingTemplate();
|
||||
Message<?> reply = template.receive(channel);
|
||||
assertEquals("test", reply.getPayload());
|
||||
}
|
||||
@@ -138,7 +138,7 @@ public class MessageChannelTemplateTests {
|
||||
public void receiveWithDefaultChannelProvidedBySetter() {
|
||||
QueueChannel channel = new QueueChannel();
|
||||
channel.send(new StringMessage("test"));
|
||||
MessageChannelTemplate template = new MessageChannelTemplate();
|
||||
MessagingTemplate template = new MessagingTemplate();
|
||||
template.setDefaultChannel(channel);
|
||||
Message<?> reply = template.receive();
|
||||
assertEquals("test", reply.getPayload());
|
||||
@@ -148,7 +148,7 @@ public class MessageChannelTemplateTests {
|
||||
public void receiveWithDefaultChannelProvidedByConstructor() {
|
||||
QueueChannel channel = new QueueChannel();
|
||||
channel.send(new StringMessage("test"));
|
||||
MessageChannelTemplate template = new MessageChannelTemplate(channel);
|
||||
MessagingTemplate template = new MessagingTemplate(channel);
|
||||
Message<?> reply = template.receive();
|
||||
assertEquals("test", reply.getPayload());
|
||||
}
|
||||
@@ -158,7 +158,7 @@ public class MessageChannelTemplateTests {
|
||||
QueueChannel explicitChannel = new QueueChannel();
|
||||
QueueChannel defaultChannel = new QueueChannel();
|
||||
explicitChannel.send(new StringMessage("test"));
|
||||
MessageChannelTemplate template = new MessageChannelTemplate(defaultChannel);
|
||||
MessagingTemplate template = new MessagingTemplate(defaultChannel);
|
||||
template.setReceiveTimeout(0);
|
||||
Message<?> reply = template.receive(explicitChannel);
|
||||
assertEquals("test", reply.getPayload());
|
||||
@@ -167,20 +167,20 @@ public class MessageChannelTemplateTests {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void receiveWithoutChannelArgFailsIfNoDefaultAvailable() {
|
||||
MessageChannelTemplate template = new MessageChannelTemplate();
|
||||
MessagingTemplate template = new MessagingTemplate();
|
||||
template.receive();
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void receiveWithNonPollableDefaultFails() {
|
||||
DirectChannel channel = new DirectChannel();
|
||||
MessageChannelTemplate template = new MessageChannelTemplate(channel);
|
||||
MessagingTemplate template = new MessagingTemplate(channel);
|
||||
template.receive();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sendAndReceive() {
|
||||
MessageChannelTemplate template = new MessageChannelTemplate();
|
||||
MessagingTemplate template = new MessagingTemplate();
|
||||
template.setReceiveTimeout(3000);
|
||||
Message<?> reply = template.sendAndReceive(new StringMessage("test"), this.requestChannel);
|
||||
assertEquals("TEST", reply.getPayload());
|
||||
@@ -188,7 +188,7 @@ public class MessageChannelTemplateTests {
|
||||
|
||||
@Test
|
||||
public void sendAndReceiveWithDefaultChannel() {
|
||||
MessageChannelTemplate template = new MessageChannelTemplate();
|
||||
MessagingTemplate template = new MessagingTemplate();
|
||||
template.setReceiveTimeout(3000);
|
||||
template.setDefaultChannel(this.requestChannel);
|
||||
Message<?> reply = template.sendAndReceive(new StringMessage("test"));
|
||||
@@ -198,7 +198,7 @@ public class MessageChannelTemplateTests {
|
||||
@Test
|
||||
public void sendAndReceiveWithExplicitChannelTakesPrecedenceOverDefault() {
|
||||
QueueChannel defaultChannel = new QueueChannel();
|
||||
MessageChannelTemplate template = new MessageChannelTemplate(defaultChannel);
|
||||
MessagingTemplate template = new MessagingTemplate(defaultChannel);
|
||||
template.setReceiveTimeout(3000);
|
||||
Message<?> message = new StringMessage("test");
|
||||
Message<?> reply = template.sendAndReceive(message, this.requestChannel);
|
||||
@@ -208,7 +208,7 @@ public class MessageChannelTemplateTests {
|
||||
|
||||
@Test(expected = IllegalStateException.class)
|
||||
public void sendAndReceiveWithoutChannelArgFailsIfNoDefaultAvailable() {
|
||||
MessageChannelTemplate template = new MessageChannelTemplate();
|
||||
MessagingTemplate template = new MessagingTemplate();
|
||||
template.sendAndReceive(new StringMessage("test"));
|
||||
}
|
||||
|
||||
@@ -224,7 +224,7 @@ public class MessageChannelTemplateTests {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
MessageChannelTemplate template = new MessageChannelTemplate();
|
||||
MessagingTemplate template = new MessagingTemplate();
|
||||
Message<String> message1 = MessageBuilder.withPayload("test1").setReplyChannel(replyChannel).build();
|
||||
Message<String> message2 = MessageBuilder.withPayload("test2").setReplyChannel(replyChannel).build();
|
||||
Message<String> message3 = MessageBuilder.withPayload("test3").setReplyChannel(replyChannel).build();
|
||||
@@ -30,7 +30,7 @@ import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.annotation.Router;
|
||||
import org.springframework.integration.channel.ChannelResolver;
|
||||
import org.springframework.integration.channel.MessageChannelTemplate;
|
||||
import org.springframework.integration.channel.MessagingTemplate;
|
||||
import org.springframework.integration.channel.PollableChannel;
|
||||
import org.springframework.integration.core.Message;
|
||||
import org.springframework.integration.core.MessageChannel;
|
||||
@@ -131,7 +131,7 @@ public class RouterParserTests {
|
||||
"routerParserTests.xml", this.getClass());
|
||||
Object endpoint = context.getBean("routerWithTimeout");
|
||||
MethodInvokingRouter router = TestUtils.getPropertyValue(endpoint, "handler", MethodInvokingRouter.class);
|
||||
MessageChannelTemplate template = (MessageChannelTemplate)
|
||||
MessagingTemplate template = (MessagingTemplate)
|
||||
new DirectFieldAccessor(router).getPropertyValue("channelTemplate");
|
||||
Long timeout = (Long) new DirectFieldAccessor(template).getPropertyValue("sendTimeout");
|
||||
assertEquals(new Long(1234), timeout);
|
||||
|
||||
Reference in New Issue
Block a user