The "defaultOutputChannelName" property of HandlerEndpoint is now "outputChannelName", and the "defaultOutput" attribute of the @MessageEndpoint annotation is now "output".
This commit is contained in:
@@ -39,7 +39,7 @@ public @interface MessageEndpoint {
|
|||||||
|
|
||||||
String input() default "";
|
String input() default "";
|
||||||
|
|
||||||
String defaultOutput() default "";
|
String output() default "";
|
||||||
|
|
||||||
int pollPeriod() default 0;
|
int pollPeriod() default 0;
|
||||||
|
|
||||||
|
|||||||
@@ -342,11 +342,11 @@ public class MessageBus implements ChannelRegistry, EndpointRegistry, Applicatio
|
|||||||
}
|
}
|
||||||
if (endpoint instanceof HandlerEndpoint) {
|
if (endpoint instanceof HandlerEndpoint) {
|
||||||
HandlerEndpoint handlerEndpoint = (HandlerEndpoint) endpoint;
|
HandlerEndpoint handlerEndpoint = (HandlerEndpoint) endpoint;
|
||||||
String outputChannelName = handlerEndpoint.getDefaultOutputChannelName();
|
String outputChannelName = handlerEndpoint.getOutputChannelName();
|
||||||
if (outputChannelName != null && this.lookupChannel(outputChannelName) == null) {
|
if (outputChannelName != null && this.lookupChannel(outputChannelName) == null) {
|
||||||
if (!this.autoCreateChannels) {
|
if (!this.autoCreateChannels) {
|
||||||
throw new ConfigurationException("Unknown channel '" + outputChannelName +
|
throw new ConfigurationException("Unknown channel '" + outputChannelName +
|
||||||
"' configured as 'default-output' for endpoint '" + endpoint +
|
"' configured as output channel for endpoint '" + endpoint +
|
||||||
"'. Consider enabling the 'autoCreateChannels' option for the message bus.");
|
"'. Consider enabling the 'autoCreateChannels' option for the message bus.");
|
||||||
}
|
}
|
||||||
this.registerChannel(outputChannelName, new QueueChannel());
|
this.registerChannel(outputChannelName, new QueueChannel());
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ import org.springframework.util.StringUtils;
|
|||||||
*
|
*
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
*/
|
*/
|
||||||
public class EndpointParser extends AbstractTargetEndpointParser {
|
public class HandlerEndpointParser extends AbstractTargetEndpointParser {
|
||||||
|
|
||||||
private static final String OUTPUT_CHANNEL_ATTRIBUTE = "output-channel";
|
private static final String OUTPUT_CHANNEL_ATTRIBUTE = "output-channel";
|
||||||
|
|
||||||
private static final String DEFAULT_OUTPUT_CHANNEL_PROPERTY = "defaultOutputChannelName";
|
private static final String OUTPUT_CHANNEL_PROPERTY = "outputChannelName";
|
||||||
|
|
||||||
private static final String RETURN_ADDRESS_OVERRIDES_ATTRIBUTE = "return-address-overrides";
|
private static final String RETURN_ADDRESS_OVERRIDES_ATTRIBUTE = "return-address-overrides";
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ public class EndpointParser extends AbstractTargetEndpointParser {
|
|||||||
protected void postProcess(BeanDefinitionBuilder builder, Element element) {
|
protected void postProcess(BeanDefinitionBuilder builder, Element element) {
|
||||||
String outputChannel = element.getAttribute(OUTPUT_CHANNEL_ATTRIBUTE);
|
String outputChannel = element.getAttribute(OUTPUT_CHANNEL_ATTRIBUTE);
|
||||||
if (StringUtils.hasText(outputChannel)) {
|
if (StringUtils.hasText(outputChannel)) {
|
||||||
builder.addPropertyValue(DEFAULT_OUTPUT_CHANNEL_PROPERTY, outputChannel);
|
builder.addPropertyValue(OUTPUT_CHANNEL_PROPERTY, outputChannel);
|
||||||
}
|
}
|
||||||
String returnAddressOverridesAttribute = element.getAttribute(RETURN_ADDRESS_OVERRIDES_ATTRIBUTE);
|
String returnAddressOverridesAttribute = element.getAttribute(RETURN_ADDRESS_OVERRIDES_ATTRIBUTE);
|
||||||
boolean returnAddressOverrides = "true".equals(returnAddressOverridesAttribute);
|
boolean returnAddressOverrides = "true".equals(returnAddressOverridesAttribute);
|
||||||
@@ -52,7 +52,7 @@ public class IntegrationNamespaceHandler extends NamespaceHandlerSupport {
|
|||||||
registerBeanDefinitionParser("source-adapter", new MethodInvokingAdapterParser());
|
registerBeanDefinitionParser("source-adapter", new MethodInvokingAdapterParser());
|
||||||
registerBeanDefinitionParser("target-adapter", new MethodInvokingAdapterParser());
|
registerBeanDefinitionParser("target-adapter", new MethodInvokingAdapterParser());
|
||||||
registerBeanDefinitionParser("source-endpoint", new SourceEndpointParser());
|
registerBeanDefinitionParser("source-endpoint", new SourceEndpointParser());
|
||||||
registerBeanDefinitionParser("handler-endpoint", new EndpointParser());
|
registerBeanDefinitionParser("handler-endpoint", new HandlerEndpointParser());
|
||||||
registerBeanDefinitionParser("target-endpoint", new TargetEndpointParser());
|
registerBeanDefinitionParser("target-endpoint", new TargetEndpointParser());
|
||||||
registerBeanDefinitionParser("handler", new HandlerParser());
|
registerBeanDefinitionParser("handler", new HandlerParser());
|
||||||
registerBeanDefinitionParser("handler-chain", new HandlerParser());
|
registerBeanDefinitionParser("handler-chain", new HandlerParser());
|
||||||
|
|||||||
@@ -115,18 +115,18 @@ public class MessageEndpointAnnotationPostProcessor implements BeanPostProcessor
|
|||||||
if (bean instanceof ChannelRegistryAware) {
|
if (bean instanceof ChannelRegistryAware) {
|
||||||
((ChannelRegistryAware) bean).setChannelRegistry(this.messageBus);
|
((ChannelRegistryAware) bean).setChannelRegistry(this.messageBus);
|
||||||
}
|
}
|
||||||
String defaultOutputChannelName = endpointAnnotation.defaultOutput();
|
String outputChannelName = endpointAnnotation.output();
|
||||||
MessageHandlerChain handlerChain = this.createHandlerChain(bean, defaultOutputChannelName);
|
MessageHandlerChain handlerChain = this.createHandlerChain(bean, outputChannelName);
|
||||||
if (handlerChain == null) {
|
if (handlerChain == null) {
|
||||||
throw new ConfigurationException("@MessageEndpoint has no handler method");
|
throw new ConfigurationException("@MessageEndpoint has no handler method");
|
||||||
}
|
}
|
||||||
HandlerEndpoint endpoint = new HandlerEndpoint(handlerChain);
|
HandlerEndpoint endpoint = new HandlerEndpoint(handlerChain);
|
||||||
this.configureInput(bean, beanName, endpointAnnotation, endpoint);
|
this.configureInput(bean, beanName, endpointAnnotation, endpoint);
|
||||||
if (StringUtils.hasText(defaultOutputChannelName)) {
|
if (StringUtils.hasText(outputChannelName)) {
|
||||||
endpoint.setDefaultOutputChannelName(defaultOutputChannelName);
|
endpoint.setOutputChannelName(outputChannelName);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.configureDefaultOutput(bean, beanName, endpoint);
|
this.configureOutput(bean, beanName, endpoint);
|
||||||
}
|
}
|
||||||
Concurrency concurrencyAnnotation = AnnotationUtils.findAnnotation(beanClass, Concurrency.class);
|
Concurrency concurrencyAnnotation = AnnotationUtils.findAnnotation(beanClass, Concurrency.class);
|
||||||
if (concurrencyAnnotation != null) {
|
if (concurrencyAnnotation != null) {
|
||||||
@@ -174,13 +174,13 @@ public class MessageEndpointAnnotationPostProcessor implements BeanPostProcessor
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void configureDefaultOutput(final Object bean, final String beanName, final HandlerEndpoint endpoint) {
|
private void configureOutput(final Object bean, final String beanName, final HandlerEndpoint endpoint) {
|
||||||
ReflectionUtils.doWithMethods(this.getBeanClass(bean), new ReflectionUtils.MethodCallback() {
|
ReflectionUtils.doWithMethods(this.getBeanClass(bean), new ReflectionUtils.MethodCallback() {
|
||||||
boolean foundDefaultOutput = false;
|
boolean foundOutput = false;
|
||||||
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
|
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
|
||||||
Annotation annotation = AnnotationUtils.getAnnotation(method, DefaultOutput.class);
|
Annotation annotation = AnnotationUtils.getAnnotation(method, DefaultOutput.class);
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
if (foundDefaultOutput) {
|
if (foundOutput) {
|
||||||
throw new ConfigurationException("only one @DefaultOutput allowed per endpoint");
|
throw new ConfigurationException("only one @DefaultOutput allowed per endpoint");
|
||||||
}
|
}
|
||||||
MethodInvokingTarget target = new MethodInvokingTarget();
|
MethodInvokingTarget target = new MethodInvokingTarget();
|
||||||
@@ -189,7 +189,7 @@ public class MessageEndpointAnnotationPostProcessor implements BeanPostProcessor
|
|||||||
target.afterPropertiesSet();
|
target.afterPropertiesSet();
|
||||||
MessageHandler handler = endpoint.getHandler();
|
MessageHandler handler = endpoint.getHandler();
|
||||||
((MessageHandlerChain) handler).add(target);
|
((MessageHandlerChain) handler).add(target);
|
||||||
foundDefaultOutput = true;
|
foundOutput = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -229,7 +229,7 @@ public class MessageEndpointAnnotationPostProcessor implements BeanPostProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
private MessageHandlerChain createHandlerChain(final Object bean, final String defaultOutputChannelName) {
|
private MessageHandlerChain createHandlerChain(final Object bean, final String outputChannelName) {
|
||||||
final List<MessageHandler> handlers = new ArrayList<MessageHandler>();
|
final List<MessageHandler> handlers = new ArrayList<MessageHandler>();
|
||||||
ReflectionUtils.doWithMethods(this.getBeanClass(bean), new ReflectionUtils.MethodCallback() {
|
ReflectionUtils.doWithMethods(this.getBeanClass(bean), new ReflectionUtils.MethodCallback() {
|
||||||
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
|
public void doWith(Method method) throws IllegalArgumentException, IllegalAccessException {
|
||||||
@@ -237,7 +237,7 @@ public class MessageEndpointAnnotationPostProcessor implements BeanPostProcessor
|
|||||||
for (Annotation annotation : annotations) {
|
for (Annotation annotation : annotations) {
|
||||||
if (isHandlerAnnotation(annotation)) {
|
if (isHandlerAnnotation(annotation)) {
|
||||||
Map<String, Object> attributes = AnnotationUtils.getAnnotationAttributes(annotation);
|
Map<String, Object> attributes = AnnotationUtils.getAnnotationAttributes(annotation);
|
||||||
attributes.put(AbstractMessageHandlerAdapter.DEFAULT_OUTPUT_CHANNEL_NAME_KEY, defaultOutputChannelName);
|
attributes.put(AbstractMessageHandlerAdapter.OUTPUT_CHANNEL_NAME_KEY, outputChannelName);
|
||||||
MessageHandlerCreator handlerCreator = handlerCreators.get(annotation.annotationType());
|
MessageHandlerCreator handlerCreator = handlerCreators.get(annotation.annotationType());
|
||||||
if (handlerCreator == null) {
|
if (handlerCreator == null) {
|
||||||
if (logger.isWarnEnabled()) {
|
if (logger.isWarnEnabled()) {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class HandlerEndpoint extends TargetEndpoint {
|
|||||||
|
|
||||||
private volatile long replyTimeout = 1000;
|
private volatile long replyTimeout = 1000;
|
||||||
|
|
||||||
private volatile String defaultOutputChannelName;
|
private volatile String outputChannelName;
|
||||||
|
|
||||||
private volatile boolean returnAddressOverrides = false;
|
private volatile boolean returnAddressOverrides = false;
|
||||||
|
|
||||||
@@ -75,14 +75,14 @@ public class HandlerEndpoint extends TargetEndpoint {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the name of the channel to which this endpoint should send reply
|
* Set the name of the channel to which this endpoint should send reply
|
||||||
* messages by default.
|
* messages.
|
||||||
*/
|
*/
|
||||||
public void setDefaultOutputChannelName(String defaultOutputChannelName) {
|
public void setOutputChannelName(String outputChannelName) {
|
||||||
this.defaultOutputChannelName = defaultOutputChannelName;
|
this.outputChannelName = outputChannelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDefaultOutputChannelName() {
|
public String getOutputChannelName() {
|
||||||
return this.defaultOutputChannelName;
|
return this.outputChannelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReturnAddressOverrides(boolean returnAddressOverrides) {
|
public void setReturnAddressOverrides(boolean returnAddressOverrides) {
|
||||||
@@ -134,8 +134,8 @@ public class HandlerEndpoint extends TargetEndpoint {
|
|||||||
|
|
||||||
private MessageChannel getOutputChannel() {
|
private MessageChannel getOutputChannel() {
|
||||||
ChannelRegistry registry = this.getChannelRegistry();
|
ChannelRegistry registry = this.getChannelRegistry();
|
||||||
if (this.defaultOutputChannelName != null && registry != null) {
|
if (this.outputChannelName != null && registry != null) {
|
||||||
return registry.lookupChannel(this.defaultOutputChannelName);
|
return registry.lookupChannel(this.outputChannelName);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -177,7 +177,7 @@ public class HandlerEndpoint extends TargetEndpoint {
|
|||||||
MessageChannel replyChannel = resolveReplyChannel(originalMessageHeader);
|
MessageChannel replyChannel = resolveReplyChannel(originalMessageHeader);
|
||||||
if (replyChannel == null) {
|
if (replyChannel == null) {
|
||||||
throw new MessageHandlingException(replyMessage, "Unable to determine reply channel for message. " +
|
throw new MessageHandlingException(replyMessage, "Unable to determine reply channel for message. " +
|
||||||
"Provide a 'returnAddress' in the message header or a 'defaultOutputChannelName' on the message endpoint.");
|
"Provide an 'outputChannelName' on the message endpoint or a 'returnAddress' in the message header");
|
||||||
}
|
}
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("endpoint '" + HandlerEndpoint.this + "' replying to channel '" + replyChannel + "' with message: " + replyMessage);
|
logger.debug("endpoint '" + HandlerEndpoint.this + "' replying to channel '" + replyChannel + "' with message: " + replyMessage);
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import org.springframework.util.Assert;
|
|||||||
*/
|
*/
|
||||||
public abstract class AbstractMessageHandlerAdapter<T> implements MessageHandler, Ordered, InitializingBean {
|
public abstract class AbstractMessageHandlerAdapter<T> implements MessageHandler, Ordered, InitializingBean {
|
||||||
|
|
||||||
public static final String DEFAULT_OUTPUT_CHANNEL_NAME_KEY = "defaultOutputChannelName";
|
public static final String OUTPUT_CHANNEL_NAME_KEY = "outputChannelName";
|
||||||
|
|
||||||
|
|
||||||
protected final Log logger = LogFactory.getLog(this.getClass());
|
protected final Log logger = LogFactory.getLog(this.getClass());
|
||||||
|
|||||||
@@ -51,12 +51,12 @@ public class SplitterMessageHandlerAdapter<T> extends AbstractMessageHandlerAdap
|
|||||||
public SplitterMessageHandlerAdapter(T object, Method method, Map<String, ?> attributes) {
|
public SplitterMessageHandlerAdapter(T object, Method method, Map<String, ?> attributes) {
|
||||||
Assert.notNull(object, "'object' must not be null");
|
Assert.notNull(object, "'object' must not be null");
|
||||||
Assert.notNull(method, "'method' must not be null");
|
Assert.notNull(method, "'method' must not be null");
|
||||||
Assert.isTrue(attributes != null && attributes.get(DEFAULT_OUTPUT_CHANNEL_NAME_KEY) != null,
|
Assert.isTrue(attributes != null && attributes.get(OUTPUT_CHANNEL_NAME_KEY) != null,
|
||||||
"The '" + DEFAULT_OUTPUT_CHANNEL_NAME_KEY + "' attribute is required.");
|
"The '" + OUTPUT_CHANNEL_NAME_KEY + "' attribute is required.");
|
||||||
this.setObject(object);
|
this.setObject(object);
|
||||||
this.setMethodName(method.getName());
|
this.setMethodName(method.getName());
|
||||||
this.method = method;
|
this.method = method;
|
||||||
this.outputChannelName = (String) attributes.get(DEFAULT_OUTPUT_CHANNEL_NAME_KEY);
|
this.outputChannelName = (String) attributes.get(OUTPUT_CHANNEL_NAME_KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setChannelRegistry(ChannelRegistry channelRegistry) {
|
public void setChannelRegistry(ChannelRegistry channelRegistry) {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class SynchronousChannelSubscriptionTests {
|
|||||||
public void testSendAndReceiveForRegisteredEndpoint() {
|
public void testSendAndReceiveForRegisteredEndpoint() {
|
||||||
HandlerEndpoint endpoint = new HandlerEndpoint(new TestHandler());
|
HandlerEndpoint endpoint = new HandlerEndpoint(new TestHandler());
|
||||||
endpoint.setSubscription(new Subscription("sourceChannel"));
|
endpoint.setSubscription(new Subscription("sourceChannel"));
|
||||||
endpoint.setDefaultOutputChannelName("targetChannel");
|
endpoint.setOutputChannelName("targetChannel");
|
||||||
bus.registerEndpoint("testEndpoint", endpoint);
|
bus.registerEndpoint("testEndpoint", endpoint);
|
||||||
bus.start();
|
bus.start();
|
||||||
this.sourceChannel.send(new StringMessage("foo"));
|
this.sourceChannel.send(new StringMessage("foo"));
|
||||||
@@ -89,7 +89,7 @@ public class SynchronousChannelSubscriptionTests {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
endpoint.setSubscription(new Subscription("sourceChannel"));
|
endpoint.setSubscription(new Subscription("sourceChannel"));
|
||||||
endpoint.setDefaultOutputChannelName("targetChannel");
|
endpoint.setOutputChannelName("targetChannel");
|
||||||
bus.registerEndpoint("testEndpoint", endpoint);
|
bus.registerEndpoint("testEndpoint", endpoint);
|
||||||
bus.start();
|
bus.start();
|
||||||
this.sourceChannel.send(new StringMessage("foo"));
|
this.sourceChannel.send(new StringMessage("foo"));
|
||||||
@@ -116,7 +116,7 @@ public class SynchronousChannelSubscriptionTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@MessageEndpoint(input="sourceChannel", defaultOutput="targetChannel")
|
@MessageEndpoint(input="sourceChannel", output="targetChannel")
|
||||||
public static class TestEndpoint {
|
public static class TestEndpoint {
|
||||||
|
|
||||||
@Handler
|
@Handler
|
||||||
@@ -126,7 +126,7 @@ public class SynchronousChannelSubscriptionTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@MessageEndpoint(input="sourceChannel", defaultOutput="targetChannel")
|
@MessageEndpoint(input="sourceChannel", output="targetChannel")
|
||||||
public static class FailingTestEndpoint {
|
public static class FailingTestEndpoint {
|
||||||
|
|
||||||
@Handler
|
@Handler
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
<constructor-arg ref="sourceChannel"/>
|
<constructor-arg ref="sourceChannel"/>
|
||||||
</bean>
|
</bean>
|
||||||
</property>
|
</property>
|
||||||
<property name="defaultOutputChannelName" value="targetChannel"/>
|
<property name="outputChannelName" value="targetChannel"/>
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
<bean id="handler" class="org.springframework.integration.handler.TestHandlers" factory-method="echoHandler"/>
|
<bean id="handler" class="org.springframework.integration.handler.TestHandlers" factory-method="echoHandler"/>
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class HandlerEndpointTests {
|
|||||||
};
|
};
|
||||||
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
|
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
|
||||||
endpoint.setChannelRegistry(channelRegistry);
|
endpoint.setChannelRegistry(channelRegistry);
|
||||||
endpoint.setDefaultOutputChannelName("replyChannel");
|
endpoint.setOutputChannelName("replyChannel");
|
||||||
endpoint.start();
|
endpoint.start();
|
||||||
endpoint.send(new StringMessage(1, "test"));
|
endpoint.send(new StringMessage(1, "test"));
|
||||||
endpoint.stop();
|
endpoint.stop();
|
||||||
@@ -171,7 +171,7 @@ public class HandlerEndpointTests {
|
|||||||
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
|
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
|
||||||
endpoint.setConcurrencyPolicy(new ConcurrencyPolicy(1, 1));
|
endpoint.setConcurrencyPolicy(new ConcurrencyPolicy(1, 1));
|
||||||
endpoint.setChannelRegistry(channelRegistry);
|
endpoint.setChannelRegistry(channelRegistry);
|
||||||
endpoint.setDefaultOutputChannelName("replyChannel");
|
endpoint.setOutputChannelName("replyChannel");
|
||||||
endpoint.start();
|
endpoint.start();
|
||||||
endpoint.send(new StringMessage(1, "test"));
|
endpoint.send(new StringMessage(1, "test"));
|
||||||
latch.await(500, TimeUnit.MILLISECONDS);
|
latch.await(500, TimeUnit.MILLISECONDS);
|
||||||
@@ -196,7 +196,7 @@ public class HandlerEndpointTests {
|
|||||||
};
|
};
|
||||||
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
|
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
|
||||||
endpoint.setChannelRegistry(channelRegistry);
|
endpoint.setChannelRegistry(channelRegistry);
|
||||||
endpoint.setDefaultOutputChannelName("replyChannel");
|
endpoint.setOutputChannelName("replyChannel");
|
||||||
endpoint.start();
|
endpoint.start();
|
||||||
endpoint.send(new StringMessage(1, "test"));
|
endpoint.send(new StringMessage(1, "test"));
|
||||||
endpoint.stop();
|
endpoint.stop();
|
||||||
@@ -221,7 +221,7 @@ public class HandlerEndpointTests {
|
|||||||
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
|
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
|
||||||
endpoint.setConcurrencyPolicy(new ConcurrencyPolicy(1, 1));
|
endpoint.setConcurrencyPolicy(new ConcurrencyPolicy(1, 1));
|
||||||
endpoint.setChannelRegistry(channelRegistry);
|
endpoint.setChannelRegistry(channelRegistry);
|
||||||
endpoint.setDefaultOutputChannelName("replyChannel");
|
endpoint.setOutputChannelName("replyChannel");
|
||||||
endpoint.start();
|
endpoint.start();
|
||||||
endpoint.send(new StringMessage(1, "test"));
|
endpoint.send(new StringMessage(1, "test"));
|
||||||
latch.await(500, TimeUnit.MILLISECONDS);
|
latch.await(500, TimeUnit.MILLISECONDS);
|
||||||
@@ -273,7 +273,7 @@ public class HandlerEndpointTests {
|
|||||||
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
|
HandlerEndpoint endpoint = new HandlerEndpoint(handler);
|
||||||
endpoint.setChannelRegistry(channelRegistry);
|
endpoint.setChannelRegistry(channelRegistry);
|
||||||
endpoint.setConcurrencyPolicy(new ConcurrencyPolicy(3, 14));
|
endpoint.setConcurrencyPolicy(new ConcurrencyPolicy(3, 14));
|
||||||
endpoint.setDefaultOutputChannelName("replyChannel");
|
endpoint.setOutputChannelName("replyChannel");
|
||||||
endpoint.start();
|
endpoint.start();
|
||||||
endpoint.send(new StringMessage(1, "test"));
|
endpoint.send(new StringMessage(1, "test"));
|
||||||
latch.await(500, TimeUnit.MILLISECONDS);
|
latch.await(500, TimeUnit.MILLISECONDS);
|
||||||
@@ -441,7 +441,7 @@ public class HandlerEndpointTests {
|
|||||||
return message;
|
return message;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
endpoint.setDefaultOutputChannelName("output");
|
endpoint.setOutputChannelName("output");
|
||||||
endpoint.setChannelRegistry(channelRegistry);
|
endpoint.setChannelRegistry(channelRegistry);
|
||||||
TestErrorHandler errorHandler = new TestErrorHandler();
|
TestErrorHandler errorHandler = new TestErrorHandler();
|
||||||
endpoint.setErrorHandler(errorHandler);
|
endpoint.setErrorHandler(errorHandler);
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ import org.springframework.integration.annotation.Polled;
|
|||||||
/**
|
/**
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
*/
|
*/
|
||||||
@MessageEndpoint(defaultOutput="outputChannel")
|
@MessageEndpoint(output="outputChannel")
|
||||||
public class InboundChannelAdapterTestBean {
|
public class InboundChannelAdapterTestBean {
|
||||||
|
|
||||||
@Polled(period=100)
|
@Polled(period=100)
|
||||||
|
|||||||
@@ -317,7 +317,7 @@ public class MessageEndpointAnnotationPostProcessorTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@MessageEndpoint(defaultOutput="testChannel")
|
@MessageEndpoint(output="testChannel")
|
||||||
private static class PolledAnnotationTestBean {
|
private static class PolledAnnotationTestBean {
|
||||||
|
|
||||||
@Polled(period=100)
|
@Polled(period=100)
|
||||||
@@ -396,7 +396,7 @@ public class MessageEndpointAnnotationPostProcessorTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@MessageEndpoint(input="inputChannel", defaultOutput="outputChannel", pollPeriod=25)
|
@MessageEndpoint(input="inputChannel", output="outputChannel", pollPeriod=25)
|
||||||
private static interface SimpleAnnotatedEndpointInterface {
|
private static interface SimpleAnnotatedEndpointInterface {
|
||||||
String test(String input);
|
String test(String input);
|
||||||
}
|
}
|
||||||
@@ -411,7 +411,7 @@ public class MessageEndpointAnnotationPostProcessorTests {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@MessageEndpoint(input="input", defaultOutput="output")
|
@MessageEndpoint(input="input", output="output")
|
||||||
private static class SplitterAnnotationTestEndpoint {
|
private static class SplitterAnnotationTestEndpoint {
|
||||||
|
|
||||||
@Splitter
|
@Splitter
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import org.springframework.integration.message.StringMessage;
|
|||||||
/**
|
/**
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
*/
|
*/
|
||||||
@MessageEndpoint(input="inputChannel", defaultOutput="outputChannel", pollPeriod=10)
|
@MessageEndpoint(input="inputChannel", output="outputChannel", pollPeriod=10)
|
||||||
public class MessageParameterAnnotatedEndpoint {
|
public class MessageParameterAnnotatedEndpoint {
|
||||||
|
|
||||||
@Handler
|
@Handler
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import org.springframework.integration.annotation.MessageEndpoint;
|
|||||||
/**
|
/**
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
*/
|
*/
|
||||||
@MessageEndpoint(input="inputChannel", defaultOutput="outputChannel", pollPeriod=10)
|
@MessageEndpoint(input="inputChannel", output="outputChannel", pollPeriod=10)
|
||||||
public class SimpleAnnotatedEndpoint implements ITestEndpoint {
|
public class SimpleAnnotatedEndpoint implements ITestEndpoint {
|
||||||
|
|
||||||
@Handler
|
@Handler
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import org.springframework.integration.annotation.MessageEndpoint;
|
|||||||
/**
|
/**
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
*/
|
*/
|
||||||
@MessageEndpoint(input="inputChannel", defaultOutput="outputChannel", pollPeriod=10)
|
@MessageEndpoint(input="inputChannel", output="outputChannel", pollPeriod=10)
|
||||||
public class TypeConvertingTestEndpoint {
|
public class TypeConvertingTestEndpoint {
|
||||||
|
|
||||||
@Handler
|
@Handler
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ public class CorrelationIdTests {
|
|||||||
ChannelRegistry channelRegistry = new DefaultChannelRegistry();
|
ChannelRegistry channelRegistry = new DefaultChannelRegistry();
|
||||||
channelRegistry.registerChannel("testChannel", testChannel);
|
channelRegistry.registerChannel("testChannel", testChannel);
|
||||||
Map<String, String> attributes = new HashMap<String, String>();
|
Map<String, String> attributes = new HashMap<String, String>();
|
||||||
attributes.put(AbstractMessageHandlerAdapter.DEFAULT_OUTPUT_CHANNEL_NAME_KEY, "testChannel");
|
attributes.put(AbstractMessageHandlerAdapter.OUTPUT_CHANNEL_NAME_KEY, "testChannel");
|
||||||
SplitterMessageHandlerAdapter<TestBean> splitter = new SplitterMessageHandlerAdapter<TestBean>(
|
SplitterMessageHandlerAdapter<TestBean> splitter = new SplitterMessageHandlerAdapter<TestBean>(
|
||||||
new TestBean(), TestBean.class.getMethod("split", String.class), attributes);
|
new TestBean(), TestBean.class.getMethod("split", String.class), attributes);
|
||||||
splitter.setChannelRegistry(channelRegistry);
|
splitter.setChannelRegistry(channelRegistry);
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class SplitterMessageHandlerAdapterTests {
|
|||||||
|
|
||||||
public SplitterMessageHandlerAdapterTests() {
|
public SplitterMessageHandlerAdapterTests() {
|
||||||
this.channelRegistry.registerChannel("testChannel", testChannel);
|
this.channelRegistry.registerChannel("testChannel", testChannel);
|
||||||
this.attribs.put(AbstractMessageHandlerAdapter.DEFAULT_OUTPUT_CHANNEL_NAME_KEY, "testChannel");
|
this.attribs.put(AbstractMessageHandlerAdapter.OUTPUT_CHANNEL_NAME_KEY, "testChannel");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@
|
|||||||
a <classname>MessageChannel</classname>, the reply message will be sent to that channel. If it is a
|
a <classname>MessageChannel</classname>, the reply message will be sent to that channel. If it is a
|
||||||
<classname>String</classname>, then the endpoint will attempt to resolve the channel by performing a
|
<classname>String</classname>, then the endpoint will attempt to resolve the channel by performing a
|
||||||
lookup in the <interfacename>ChannelRegistry</interfacename>. If the message header does not contain a
|
lookup in the <interfacename>ChannelRegistry</interfacename>. If the message header does not contain a
|
||||||
'returnAddress' property at all, then it will fallback to its own 'defaultOutputChannelName' property. If
|
'returnAddress' property at all, then it will fallback to its own 'outputChannelName' property. If
|
||||||
neither is available, then a <classname>MessageHandlingException</classname> will be thrown. To configure the
|
neither is available, then a <classname>MessageHandlingException</classname> will be thrown. To configure the
|
||||||
output channel when using the XML namespace, provide the 'output-channel' attribute:
|
output channel when using the XML namespace, provide the 'output-channel' attribute:
|
||||||
<programlisting><handler-endpoint input-channel="exampleChannel"
|
<programlisting><handler-endpoint input-channel="exampleChannel"
|
||||||
@@ -315,9 +315,9 @@ public class FooService {
|
|||||||
As described in the previous section, when the handler method returns a non-null value, the endpoint will
|
As described in the previous section, when the handler method returns a non-null value, the endpoint will
|
||||||
attempt to send a reply. This is consistent across both configuration options (namespace and annotations) in that
|
attempt to send a reply. This is consistent across both configuration options (namespace and annotations) in that
|
||||||
the message header's 'replyChannelName' property will be used if available, and the endpoint's default output is
|
the message header's 'replyChannelName' property will be used if available, and the endpoint's default output is
|
||||||
the fallback. To configure the default output for an annotation-driven endpoint, provide the 'defaultOutput'
|
the fallback. To configure the default output for an annotation-driven endpoint, provide the 'output'
|
||||||
attribute on the <interfacename>@MessageEndpoint</interfacename>.
|
attribute on the <interfacename>@MessageEndpoint</interfacename>.
|
||||||
<programlisting>@MessageEndpoint(input="exampleChannel", defaultOutput="replyChannel")</programlisting>
|
<programlisting>@MessageEndpoint(input="exampleChannel", output="replyChannel")</programlisting>
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
Just as the 'schedule' sub-element and its 'period' attribute can be provided for a namespace-based
|
Just as the 'schedule' sub-element and its 'period' attribute can be provided for a namespace-based
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import org.springframework.integration.annotation.Splitter;
|
|||||||
/**
|
/**
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
*/
|
*/
|
||||||
@MessageEndpoint(input="orders", defaultOutput="drinks")
|
@MessageEndpoint(input="orders", output="drinks")
|
||||||
public class OrderSplitter {
|
public class OrderSplitter {
|
||||||
|
|
||||||
@Splitter
|
@Splitter
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class Counter {
|
|||||||
|
|
||||||
private AtomicInteger count = new AtomicInteger();
|
private AtomicInteger count = new AtomicInteger();
|
||||||
|
|
||||||
@Polled(period=3000)
|
@Polled(initialDelay=1000, period=3000)
|
||||||
public int getNumber() {
|
public int getNumber() {
|
||||||
return count.incrementAndGet();
|
return count.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import org.springframework.integration.annotation.Polled;
|
|||||||
/**
|
/**
|
||||||
* @author Mark Fisher
|
* @author Mark Fisher
|
||||||
*/
|
*/
|
||||||
@MessageEndpoint(defaultOutput="quotes")
|
@MessageEndpoint(output="quotes")
|
||||||
public class QuotePublisher {
|
public class QuotePublisher {
|
||||||
|
|
||||||
@Polled(period=300)
|
@Polled(period=300)
|
||||||
|
|||||||
Reference in New Issue
Block a user