Build on top of Spring 4's new messaging types
This commit updates Spring Integration to depend upon Spring 4, making use of the message types that have moved from Spring Integration into Spring's new spring-messaging module. The default message converter no longer supports conversion of a message that is null, throwing an IllegalArgumentException if an attempt is made to convert null. Furthermore, GenericMessagingTemplate does not support sending null, again throwing an IllegalArgumentException. Previously, MessagingTemplate had no-oped an attempt to send null. ConcurrentAggregatorTests and AggregatorTests both had a single test that was specifically testing the behaviour of an aggregator that returns null for its message. These tests have been removed. CorrelatingMessageHandlerTests have been updated to specify some additional behaviour for its mocks so that null messages are not returned. These are the only functional changes that have been made. All other changes are simply for moving to the repackaged and/or renamed types. In the move to being part of core Spring, a number of constants and header accessor methods have moved from MessageHeaders to MessageHeaderAccessor. This commit continues this pattern for the enterprise integration headers that are specific to Spring Integration. A new class, EiMessageHeaderAccessor, has been created. This class provides constants and methods for working with SI-specific headers. The main code and tests have been updated to use this new class.
This commit is contained in:
committed by
Gary Russell
parent
8dca61c62a
commit
28ab8394de
@@ -58,7 +58,7 @@ subprojects { subproject ->
|
||||
mockitoVersion = '1.9.5'
|
||||
eaioUUIDVersion = '3.2'
|
||||
|
||||
springVersionDefault = '3.1.4.RELEASE'
|
||||
springVersionDefault = '4.0.0.M3'
|
||||
springVersion = project.hasProperty('springVersion') ? getProperty('springVersion') : springVersionDefault
|
||||
|
||||
springAmqpVersion = '1.2.0.RELEASE'
|
||||
@@ -189,6 +189,7 @@ project('spring-integration-core') {
|
||||
dependencies {
|
||||
compile "org.springframework:spring-aop:$springVersion"
|
||||
compile "org.springframework:spring-context:$springVersion"
|
||||
compile "org.springframework:spring-messaging:$springVersion"
|
||||
compile "org.springframework:spring-tx:$springVersion"
|
||||
compile "org.springframework.retry:spring-retry:$springRetryVersion"
|
||||
compile "com.eaio.uuid:uuid:$eaioUUIDVersion"
|
||||
|
||||
@@ -1 +1 @@
|
||||
version=3.0.0.BUILD-SNAPSHOT
|
||||
version=4.0.0.BUILD-SNAPSHOT
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.amqp;
|
||||
|
||||
import org.springframework.integration.MessageHeaders;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper;
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.integration.amqp.channel;
|
||||
|
||||
import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
@@ -29,15 +29,15 @@ import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.amqp.support.converter.SimpleMessageConverter;
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageDeliveryException;
|
||||
import org.springframework.integration.MessageDispatchingException;
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.core.SubscribableChannel;
|
||||
import org.springframework.integration.dispatcher.AbstractDispatcher;
|
||||
import org.springframework.integration.dispatcher.MessageDispatcher;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,8 +21,8 @@ import org.springframework.amqp.core.AmqpTemplate;
|
||||
import org.springframework.amqp.core.Queue;
|
||||
import org.springframework.amqp.rabbit.core.RabbitAdmin;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Provides classes related to AMQP-backed channels.
|
||||
*/
|
||||
package org.springframework.integration.amqp.channel;
|
||||
package org.springframework.integration.amqp.channel;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Provides classes for configuration - parsers, namespace handlers, factory beans.
|
||||
*/
|
||||
package org.springframework.integration.amqp.config;
|
||||
package org.springframework.integration.amqp.config;
|
||||
|
||||
@@ -82,9 +82,9 @@ public class AmqpInboundGateway extends MessagingGatewaySupport {
|
||||
public void onMessage(Message message) {
|
||||
Object payload = amqpMessageConverter.fromMessage(message);
|
||||
Map<String, ?> headers = headerMapper.toHeadersFromRequest(message.getMessageProperties());
|
||||
org.springframework.integration.Message<?> request =
|
||||
org.springframework.messaging.Message<?> request =
|
||||
MessageBuilder.withPayload(payload).copyHeaders(headers).build();
|
||||
final org.springframework.integration.Message<?> reply = sendAndReceiveMessage(request);
|
||||
final org.springframework.messaging.Message<?> reply = sendAndReceiveMessage(request);
|
||||
if (reply != null) {
|
||||
// TODO: fallback to a reply address property of this gateway
|
||||
Address replyTo = message.getMessageProperties().getReplyToAddress();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Provides classes supporting inbound endpoints.
|
||||
*/
|
||||
package org.springframework.integration.amqp.inbound;
|
||||
package org.springframework.integration.amqp.inbound;
|
||||
|
||||
@@ -28,8 +28,8 @@ import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.spel.SpelParserConfiguration;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.amqp.AmqpHeaders;
|
||||
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
|
||||
import org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Provides classes supporting outbound endpoints.
|
||||
*/
|
||||
package org.springframework.integration.amqp.outbound;
|
||||
package org.springframework.integration.amqp.outbound;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Base package for AMQP support.
|
||||
*/
|
||||
package org.springframework.integration.amqp;
|
||||
package org.springframework.integration.amqp;
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.amqp.core.MessageDeliveryMode;
|
||||
import org.springframework.amqp.core.MessageProperties;
|
||||
import org.springframework.integration.MessageHeaders;
|
||||
import org.springframework.integration.EiMessageHeaderAccessor;
|
||||
import org.springframework.integration.amqp.AmqpHeaders;
|
||||
import org.springframework.integration.mapping.AbstractHeaderMapper;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -127,7 +127,7 @@ public class DefaultAmqpHeaderMapper extends AbstractHeaderMapper<MessagePropert
|
||||
}
|
||||
Integer priority = amqpMessageProperties.getPriority();
|
||||
if (priority != null && priority > 0) {
|
||||
headers.put(MessageHeaders.PRIORITY, priority);
|
||||
headers.put(EiMessageHeaderAccessor.PRIORITY, priority);
|
||||
}
|
||||
String receivedExchange = amqpMessageProperties.getReceivedExchange();
|
||||
if (StringUtils.hasText(receivedExchange)) {
|
||||
@@ -240,7 +240,7 @@ public class DefaultAmqpHeaderMapper extends AbstractHeaderMapper<MessagePropert
|
||||
if (StringUtils.hasText(messageId)) {
|
||||
amqpMessageProperties.setMessageId(messageId);
|
||||
}
|
||||
Integer priority = getHeaderIfAvailable(headers, MessageHeaders.PRIORITY, Integer.class);
|
||||
Integer priority = getHeaderIfAvailable(headers, EiMessageHeaderAccessor.PRIORITY, Integer.class);
|
||||
if (priority != null) {
|
||||
amqpMessageProperties.setPriority(priority);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Provides AMQP support classes.
|
||||
*/
|
||||
package org.springframework.integration.amqp.support;
|
||||
package org.springframework.integration.amqp.support;
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type
|
||||
type="org.springframework.integration.MessageChannel" />
|
||||
type="org.springframework.messaging.MessageChannel" />
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
@@ -65,7 +65,7 @@
|
||||
]]></xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.MessageChannel"/>
|
||||
<tool:expected-type type="org.springframework.messaging.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
@@ -81,7 +81,7 @@
|
||||
]]></xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.MessageChannel"/>
|
||||
<tool:expected-type type="org.springframework.messaging.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
@@ -109,7 +109,7 @@
|
||||
</xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.MessageChannel"/>
|
||||
<tool:expected-type type="org.springframework.messaging.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
@@ -144,7 +144,7 @@
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type
|
||||
type="org.springframework.integration.MessageChannel"/>
|
||||
type="org.springframework.messaging.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
@@ -157,7 +157,7 @@
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type
|
||||
type="org.springframework.integration.MessageChannel"/>
|
||||
type="org.springframework.messaging.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
@@ -230,7 +230,7 @@
|
||||
</xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.MessageChannel"/>
|
||||
<tool:expected-type type="org.springframework.messaging.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
@@ -242,7 +242,7 @@
|
||||
</xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.MessageChannel"/>
|
||||
<tool:expected-type type="org.springframework.messaging.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
@@ -459,7 +459,7 @@ property set to TRUE.
|
||||
]]></xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.MessageChannel"/>
|
||||
<tool:expected-type type="org.springframework.messaging.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
@@ -487,7 +487,7 @@ property set to TRUE.
|
||||
</xsd:documentation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type type="org.springframework.integration.MessageChannel"/>
|
||||
<tool:expected-type type="org.springframework.messaging.MessageChannel"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
</xsd:annotation>
|
||||
|
||||
@@ -42,8 +42,8 @@ import org.springframework.amqp.rabbit.connection.Connection;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.listener.SimpleMessageListenerContainer;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
import org.springframework.integration.MessageDeliveryException;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
|
||||
import com.rabbitmq.client.Channel;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.interceptor.ChannelInterceptorAdapter;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.core.MessageListener;
|
||||
import org.springframework.amqp.core.MessageProperties;
|
||||
import org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -87,7 +86,7 @@ public class AmqpInboundChannelAdapterParserTests {
|
||||
Message amqpMessage = new Message("hello".getBytes(), amqpProperties);
|
||||
listener.onMessage(amqpMessage);
|
||||
QueueChannel requestChannel = context.getBean("requestChannel", QueueChannel.class);
|
||||
org.springframework.integration.Message<?> siMessage = requestChannel.receive(0);
|
||||
org.springframework.messaging.Message<?> siMessage = requestChannel.receive(0);
|
||||
assertEquals("foo", siMessage.getHeaders().get("foo"));
|
||||
assertNull(siMessage.getHeaders().get("bar"));
|
||||
assertNotNull(siMessage.getHeaders().get(AmqpHeaders.CONTENT_ENCODING));
|
||||
@@ -114,7 +113,7 @@ public class AmqpInboundChannelAdapterParserTests {
|
||||
Message amqpMessage = new Message("hello".getBytes(), amqpProperties);
|
||||
listener.onMessage(amqpMessage);
|
||||
QueueChannel requestChannel = context.getBean("requestChannel", QueueChannel.class);
|
||||
org.springframework.integration.Message<?> siMessage = requestChannel.receive(0);
|
||||
org.springframework.messaging.Message<?> siMessage = requestChannel.receive(0);
|
||||
assertEquals("foo", siMessage.getHeaders().get("foo"));
|
||||
assertNull(siMessage.getHeaders().get("bar"));
|
||||
assertNull(siMessage.getHeaders().get(AmqpHeaders.CONTENT_ENCODING));
|
||||
@@ -142,7 +141,7 @@ public class AmqpInboundChannelAdapterParserTests {
|
||||
listener.onMessage(amqpMessage);
|
||||
|
||||
QueueChannel requestChannel = context.getBean("requestChannel", QueueChannel.class);
|
||||
org.springframework.integration.Message<?> siMessage = requestChannel.receive(0);
|
||||
org.springframework.messaging.Message<?> siMessage = requestChannel.receive(0);
|
||||
assertNull(siMessage.getHeaders().get("foo"));
|
||||
assertNull(siMessage.getHeaders().get("bar"));
|
||||
assertNull(siMessage.getHeaders().get(AmqpHeaders.CONTENT_ENCODING));
|
||||
@@ -169,7 +168,7 @@ public class AmqpInboundChannelAdapterParserTests {
|
||||
Message amqpMessage = new Message("hello".getBytes(), amqpProperties);
|
||||
listener.onMessage(amqpMessage);
|
||||
QueueChannel requestChannel = context.getBean("requestChannel", QueueChannel.class);
|
||||
org.springframework.integration.Message<?> siMessage = requestChannel.receive(0);
|
||||
org.springframework.messaging.Message<?> siMessage = requestChannel.receive(0);
|
||||
assertNull(siMessage.getHeaders().get("bar"));
|
||||
assertNull(siMessage.getHeaders().get("foo"));
|
||||
assertNotNull(siMessage.getHeaders().get(AmqpHeaders.CONTENT_ENCODING));
|
||||
|
||||
@@ -39,11 +39,11 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.integration.amqp.inbound.AmqpInboundGateway;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
@@ -87,9 +87,9 @@ public class AmqpInboundGatewayParserTests {
|
||||
public void verifyUsageWithHeaderMapper() throws Exception{
|
||||
DirectChannel requestChannel = context.getBean("requestChannel", DirectChannel.class);
|
||||
requestChannel.subscribe(new MessageHandler() {
|
||||
public void handleMessage(org.springframework.integration.Message<?> siMessage)
|
||||
public void handleMessage(org.springframework.messaging.Message<?> siMessage)
|
||||
throws MessagingException {
|
||||
org.springframework.integration.Message<?> replyMessage = MessageBuilder.fromMessage(siMessage).setHeader("bar", "bar").build();
|
||||
org.springframework.messaging.Message<?> replyMessage = MessageBuilder.fromMessage(siMessage).setHeader("bar", "bar").build();
|
||||
MessageChannel replyChannel = (MessageChannel) siMessage.getHeaders().getReplyChannel();
|
||||
replyChannel.send(replyMessage);
|
||||
}
|
||||
|
||||
@@ -50,15 +50,15 @@ import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.integration.amqp.AmqpHeaders;
|
||||
import org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint;
|
||||
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.NullChannel;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.handler.advice.AbstractRequestHandlerAdvice;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
|
||||
@@ -34,8 +34,8 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.beans.factory.parsing.BeanDefinitionParsingException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.amqp.AmqpHeaders;
|
||||
import org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
|
||||
@@ -33,13 +33,13 @@ import org.springframework.beans.factory.NoSuchBeanDefinitionException;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.amqp.outbound.AmqpOutboundEndpoint;
|
||||
import org.springframework.integration.config.IntegrationEvaluationContextFactoryBean;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.integration.message.GenericMessage;
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
|
||||
import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.amqp.rabbit.support.CorrelationData;
|
||||
import org.springframework.integration.MessageHeaders;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
|
||||
/**
|
||||
@@ -59,7 +59,7 @@ public class OutboundEndpointTests {
|
||||
}
|
||||
}).when(amqpTemplate).send(anyString(), anyString(), any(Message.class),
|
||||
any(CorrelationData.class));
|
||||
org.springframework.integration.Message<?> message = MessageBuilder.withPayload("foo")
|
||||
org.springframework.messaging.Message<?> message = MessageBuilder.withPayload("foo")
|
||||
.setHeader(MessageHeaders.CONTENT_TYPE, "bar")
|
||||
.build();
|
||||
endpoint.handleMessage(message);
|
||||
@@ -83,7 +83,7 @@ public class OutboundEndpointTests {
|
||||
return null;
|
||||
}
|
||||
}).when(amqpTemplate).doSendAndReceiveWithTemporary(anyString(), anyString(), any(Message.class));
|
||||
org.springframework.integration.Message<?> message = MessageBuilder.withPayload("foo")
|
||||
org.springframework.messaging.Message<?> message = MessageBuilder.withPayload("foo")
|
||||
.setHeader(MessageHeaders.CONTENT_TYPE, "bar")
|
||||
.build();
|
||||
endpoint.handleMessage(message);
|
||||
|
||||
@@ -30,7 +30,7 @@ import org.springframework.amqp.core.MessageDeliveryMode;
|
||||
import org.springframework.amqp.core.MessageProperties;
|
||||
import org.springframework.amqp.support.converter.JsonMessageConverter;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.integration.MessageHeaders;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.integration.amqp.AmqpHeaders;
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package org.springframework.integration;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.support.MessageHeaderAccessor;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
public class EiMessageHeaderAccessor extends MessageHeaderAccessor {
|
||||
|
||||
public static final String CORRELATION_ID = "correlationId";
|
||||
|
||||
public static final String EXPIRATION_DATE = "expirationDate";
|
||||
|
||||
public static final String PRIORITY = "priority";
|
||||
|
||||
public static final String SEQUENCE_NUMBER = "sequenceNumber";
|
||||
|
||||
public static final String SEQUENCE_SIZE = "sequenceSize";
|
||||
|
||||
public static final String SEQUENCE_DETAILS = "sequenceDetails";
|
||||
|
||||
public static final String POSTPROCESS_RESULT = "postProcessResult";
|
||||
|
||||
public EiMessageHeaderAccessor(Message<?> message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public Long getExpirationDate() {
|
||||
return this.getHeader(EXPIRATION_DATE, Long.class);
|
||||
}
|
||||
|
||||
public Object getCorrelationId() {
|
||||
return this.getHeader(CORRELATION_ID);
|
||||
}
|
||||
|
||||
public Integer getSequenceNumber() {
|
||||
Integer sequenceNumber = this.getHeader(SEQUENCE_NUMBER, Integer.class);
|
||||
return (sequenceNumber != null ? sequenceNumber : 0);
|
||||
}
|
||||
|
||||
public Integer getSequenceSize() {
|
||||
Integer sequenceSize = this.getHeader(SEQUENCE_SIZE, Integer.class);
|
||||
return (sequenceSize != null ? sequenceSize : 0);
|
||||
}
|
||||
|
||||
public Integer getPriority() {
|
||||
return this.getHeader(PRIORITY, Integer.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T getHeader(String key, Class<T> type) {
|
||||
Object value = getHeader(key);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (!type.isAssignableFrom(value.getClass())) {
|
||||
throw new IllegalArgumentException("Incorrect type specified for header '" + key + "'. Expected [" + type
|
||||
+ "] but actual type is [" + value.getClass() + "]");
|
||||
}
|
||||
return (T) value;
|
||||
}
|
||||
|
||||
protected void verifyType(String headerName, Object headerValue) {
|
||||
if (headerName != null && headerValue != null) {
|
||||
super.verifyType(headerName, headerValue);
|
||||
if (EiMessageHeaderAccessor.EXPIRATION_DATE.equals(headerName)) {
|
||||
Assert.isTrue(headerValue instanceof Date || headerValue instanceof Long, "The '" + headerName
|
||||
+ "' header value must be a Date or Long.");
|
||||
}
|
||||
else if (EiMessageHeaderAccessor.SEQUENCE_NUMBER.equals(headerName)
|
||||
|| EiMessageHeaderAccessor.SEQUENCE_SIZE.equals(headerName)) {
|
||||
Assert.isTrue(Integer.class.isAssignableFrom(headerValue.getClass()), "The '" + headerName
|
||||
+ "' header value must be an Integer.");
|
||||
}
|
||||
else if (EiMessageHeaderAccessor.PRIORITY.equals(headerName)) {
|
||||
Assert.isTrue(Integer.class.isAssignableFrom(headerValue.getClass()), "The '" + headerName
|
||||
+ "' header value must be an Integer.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* The central interface that any Message type must implement.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Arjen Poutsma
|
||||
*/
|
||||
public interface Message<T> {
|
||||
|
||||
MessageHeaders getHeaders();
|
||||
|
||||
T getPayload();
|
||||
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Base channel interface defining common behavior for sending messages.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public interface MessageChannel {
|
||||
|
||||
/**
|
||||
* Send a {@link Message} to this channel. May throw a RuntimeException for
|
||||
* non-recoverable errors. Otherwise, if the Message cannot be sent for a
|
||||
* non-fatal reason this method will return 'false', and if the Message is
|
||||
* sent successfully, it will return 'true'.
|
||||
*
|
||||
* <p>Depending on the implementation, this method may block indefinitely.
|
||||
* To provide a maximum wait time, use {@link #send(Message, long)}.
|
||||
*
|
||||
* @param message the {@link Message} to send
|
||||
*
|
||||
* @return whether or not the Message has been sent successfully
|
||||
*/
|
||||
boolean send(Message<?> message);
|
||||
|
||||
/**
|
||||
* Send a message, blocking until either the message is accepted or the
|
||||
* specified timeout period elapses.
|
||||
*
|
||||
* @param message the {@link Message} to send
|
||||
* @param timeout the timeout in milliseconds
|
||||
*
|
||||
* @return <code>true</code> if the message is sent successfully,
|
||||
* <code>false</code> if the specified timeout period elapses or
|
||||
* the send is interrupted
|
||||
*/
|
||||
boolean send(Message<?> message, long timeout);
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* Exception that indicates an error occurred during message delivery.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class MessageDeliveryException extends MessagingException {
|
||||
|
||||
public MessageDeliveryException(String description) {
|
||||
super(description);
|
||||
}
|
||||
|
||||
public MessageDeliveryException(Message<?> undeliveredMessage) {
|
||||
super(undeliveredMessage);
|
||||
}
|
||||
|
||||
public MessageDeliveryException(Message<?> undeliveredMessage, String description) {
|
||||
super(undeliveredMessage, description);
|
||||
}
|
||||
|
||||
public MessageDeliveryException(Message<?> undeliveredMessage, String description, Throwable cause) {
|
||||
super(undeliveredMessage, description, cause);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,6 +16,8 @@
|
||||
package org.springframework.integration;
|
||||
|
||||
import org.springframework.integration.dispatcher.MessageDispatcher;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
|
||||
/**
|
||||
* Exception that indicates an internal error occurred within
|
||||
|
||||
@@ -16,9 +16,12 @@
|
||||
|
||||
package org.springframework.integration;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
|
||||
/**
|
||||
* Exception that indicates an error occurred during message handling.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
|
||||
@@ -1,305 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2013 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;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import com.eaio.uuid.UUIDGen;
|
||||
|
||||
/**
|
||||
* The headers for a {@link Message}.<br>
|
||||
* IMPORTANT: MessageHeaders are immutable. Any mutating operation (e.g., put(..), putAll(..) etc.)
|
||||
* will result in {@link UnsupportedOperationException}
|
||||
* To create MessageHeaders instance use fluent MessageBuilder API
|
||||
* <pre>
|
||||
* MessageBuilder.withPayload("foo").setHeader("key1", "value1").setHeader("key2", "value2");
|
||||
* </pre>
|
||||
* or create an instance of GenericMessage passing payload as {@link Object} and headers as a regular {@link Map}
|
||||
* <pre>
|
||||
* Map headers = new HashMap();
|
||||
* headers.put("key1", "value1");
|
||||
* headers.put("key2", "value2");
|
||||
* new GenericMessage("foo", headers);
|
||||
* </pre>
|
||||
*
|
||||
* @author Arjen Poutsma
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public final class MessageHeaders implements Map<String, Object>, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 6901029029524535147L;
|
||||
|
||||
private static final Log logger = LogFactory.getLog(MessageHeaders.class);
|
||||
|
||||
private static volatile IdGenerator idGenerator = null;
|
||||
|
||||
/**
|
||||
* The key for the Message ID. This is an automatically generated UUID and
|
||||
* should never be explicitly set in the header map <b>except</b> in the
|
||||
* case of Message deserialization where the serialized Message's generated
|
||||
* UUID is being restored.
|
||||
*/
|
||||
public static final String ID = "id";
|
||||
|
||||
public static final String TIMESTAMP = "timestamp";
|
||||
|
||||
public static final String CORRELATION_ID = "correlationId";
|
||||
|
||||
public static final String REPLY_CHANNEL = "replyChannel";
|
||||
|
||||
public static final String ERROR_CHANNEL = "errorChannel";
|
||||
|
||||
public static final String EXPIRATION_DATE = "expirationDate";
|
||||
|
||||
public static final String PRIORITY = "priority";
|
||||
|
||||
public static final String SEQUENCE_NUMBER = "sequenceNumber";
|
||||
|
||||
public static final String SEQUENCE_SIZE = "sequenceSize";
|
||||
|
||||
public static final String SEQUENCE_DETAILS = "sequenceDetails";
|
||||
|
||||
public static final String CONTENT_TYPE = "content-type";
|
||||
|
||||
public static final String POSTPROCESS_RESULT = "postProcessResult";
|
||||
|
||||
|
||||
private final Map<String, Object> headers;
|
||||
|
||||
|
||||
public MessageHeaders(Map<String, Object> headers) {
|
||||
this.headers = (headers != null) ? new HashMap<String, Object>(headers) : new HashMap<String, Object>();
|
||||
if (MessageHeaders.idGenerator == null) {
|
||||
UUID uuid = new UUID(UUIDGen.newTime(), UUIDGen.getClockSeqAndNode());
|
||||
this.headers.put(ID, uuid);
|
||||
}
|
||||
else {
|
||||
this.headers.put(ID, MessageHeaders.idGenerator.generateId());
|
||||
}
|
||||
|
||||
this.headers.put(TIMESTAMP, new Long(System.currentTimeMillis()));
|
||||
}
|
||||
|
||||
public UUID getId() {
|
||||
return this.get(ID, UUID.class);
|
||||
}
|
||||
|
||||
public Long getTimestamp() {
|
||||
return this.get(TIMESTAMP, Long.class);
|
||||
}
|
||||
|
||||
public Long getExpirationDate() {
|
||||
return this.get(EXPIRATION_DATE, Long.class);
|
||||
}
|
||||
|
||||
public Object getCorrelationId() {
|
||||
return this.get(CORRELATION_ID);
|
||||
}
|
||||
|
||||
public Object getReplyChannel() {
|
||||
return this.get(REPLY_CHANNEL);
|
||||
}
|
||||
|
||||
public Object getErrorChannel() {
|
||||
return this.get(ERROR_CHANNEL);
|
||||
}
|
||||
|
||||
public Integer getSequenceNumber() {
|
||||
Integer sequenceNumber = this.get(SEQUENCE_NUMBER, Integer.class);
|
||||
return (sequenceNumber != null ? sequenceNumber : 0);
|
||||
}
|
||||
|
||||
public Integer getSequenceSize() {
|
||||
Integer sequenceSize = this.get(SEQUENCE_SIZE, Integer.class);
|
||||
return (sequenceSize != null ? sequenceSize : 0);
|
||||
}
|
||||
|
||||
public Integer getPriority() {
|
||||
return this.get(PRIORITY, Integer.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T get(Object key, Class<T> type) {
|
||||
Object value = this.headers.get(key);
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (!type.isAssignableFrom(value.getClass())) {
|
||||
throw new IllegalArgumentException("Incorrect type specified for header '" + key + "'. Expected [" + type
|
||||
+ "] but actual type is [" + value.getClass() + "]");
|
||||
}
|
||||
return (T) value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.headers.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object object) {
|
||||
if (this == object) {
|
||||
return true;
|
||||
}
|
||||
if (object != null && object instanceof MessageHeaders) {
|
||||
MessageHeaders other = (MessageHeaders) object;
|
||||
return this.headers.equals(other.headers);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.headers.toString();
|
||||
}
|
||||
|
||||
/*
|
||||
* Map implementation
|
||||
*/
|
||||
|
||||
public boolean containsKey(Object key) {
|
||||
return this.headers.containsKey(key);
|
||||
}
|
||||
|
||||
public boolean containsValue(Object value) {
|
||||
return this.headers.containsValue(value);
|
||||
}
|
||||
|
||||
public Set<Map.Entry<String, Object>> entrySet() {
|
||||
return Collections.unmodifiableSet(this.headers.entrySet());
|
||||
}
|
||||
|
||||
public Object get(Object key) {
|
||||
return this.headers.get(key);
|
||||
}
|
||||
|
||||
public boolean isEmpty() {
|
||||
return this.headers.isEmpty();
|
||||
}
|
||||
|
||||
public Set<String> keySet() {
|
||||
return Collections.unmodifiableSet(this.headers.keySet());
|
||||
}
|
||||
|
||||
public int size() {
|
||||
return this.headers.size();
|
||||
}
|
||||
|
||||
public Collection<Object> values() {
|
||||
return Collections.unmodifiableCollection(this.headers.values());
|
||||
}
|
||||
|
||||
/*
|
||||
* Unsupported operations
|
||||
*/
|
||||
/**
|
||||
* Since MessageHeaders are immutable the call to this method will result in {@link UnsupportedOperationException}
|
||||
*/
|
||||
public Object put(String key, Object value) {
|
||||
throw new UnsupportedOperationException("MessageHeaders is immutable.");
|
||||
}
|
||||
/**
|
||||
* Since MessageHeaders are immutable the call to this method will result in {@link UnsupportedOperationException}
|
||||
*/
|
||||
public void putAll(Map<? extends String, ? extends Object> t) {
|
||||
throw new UnsupportedOperationException("MessageHeaders is immutable.");
|
||||
}
|
||||
/**
|
||||
* Since MessageHeaders are immutable the call to this method will result in {@link UnsupportedOperationException}
|
||||
*/
|
||||
public Object remove(Object key) {
|
||||
throw new UnsupportedOperationException("MessageHeaders is immutable.");
|
||||
}
|
||||
/**
|
||||
* Since MessageHeaders are immutable the call to this method will result in {@link UnsupportedOperationException}
|
||||
*/
|
||||
public void clear() {
|
||||
throw new UnsupportedOperationException("MessageHeaders is immutable.");
|
||||
}
|
||||
|
||||
/*
|
||||
* Serialization methods
|
||||
*/
|
||||
|
||||
private void writeObject(ObjectOutputStream out) throws IOException {
|
||||
List<String> keysToRemove = new ArrayList<String>();
|
||||
for (Map.Entry<String, Object> entry : this.headers.entrySet()) {
|
||||
if (!(entry.getValue() instanceof Serializable)) {
|
||||
keysToRemove.add(entry.getKey());
|
||||
}
|
||||
}
|
||||
for (String key : keysToRemove) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("removing non-serializable header: " + key);
|
||||
}
|
||||
this.headers.remove(key);
|
||||
}
|
||||
out.defaultWriteObject();
|
||||
}
|
||||
|
||||
private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException {
|
||||
in.defaultReadObject();
|
||||
}
|
||||
|
||||
public static interface IdGenerator {
|
||||
UUID generateId();
|
||||
}
|
||||
|
||||
public static class JdkIdGenerator implements IdGenerator {
|
||||
|
||||
@Override
|
||||
public UUID generateId() {
|
||||
return UUID.randomUUID();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static class SimpleIncrementingIdGenerator implements IdGenerator {
|
||||
|
||||
private final AtomicLong topBits = new AtomicLong();
|
||||
|
||||
private final AtomicLong bottomBits = new AtomicLong();
|
||||
|
||||
@Override
|
||||
public UUID generateId() {
|
||||
long bottomBits = this.bottomBits.incrementAndGet();
|
||||
if (bottomBits == 0) {
|
||||
this.topBits.incrementAndGet();
|
||||
}
|
||||
return new UUID(this.topBits.get(), bottomBits);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,9 +16,11 @@
|
||||
|
||||
package org.springframework.integration;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* Exception that indicates a message has been rejected by a selector.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
|
||||
@@ -16,14 +16,17 @@
|
||||
|
||||
package org.springframework.integration;
|
||||
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
|
||||
/**
|
||||
* Exception that indicates a timeout elapsed prior to successful message delivery.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class MessageTimeoutException extends MessageDeliveryException {
|
||||
|
||||
|
||||
public MessageTimeoutException(String description) {
|
||||
super(description);
|
||||
}
|
||||
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* The base exception for any failures related to messaging.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Gary Russell
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class MessagingException extends RuntimeException {
|
||||
|
||||
private volatile Message<?> failedMessage;
|
||||
|
||||
|
||||
public MessagingException(Message<?> message) {
|
||||
super();
|
||||
this.failedMessage = message;
|
||||
}
|
||||
|
||||
public MessagingException(String description) {
|
||||
super(description);
|
||||
this.failedMessage = null;
|
||||
}
|
||||
|
||||
public MessagingException(String description, Throwable cause) {
|
||||
super(description, cause);
|
||||
this.failedMessage = null;
|
||||
}
|
||||
|
||||
public MessagingException(Message<?> message, String description) {
|
||||
super(description);
|
||||
this.failedMessage = message;
|
||||
}
|
||||
|
||||
public MessagingException(Message<?> message, Throwable cause) {
|
||||
super(cause);
|
||||
this.failedMessage = message;
|
||||
}
|
||||
|
||||
public MessagingException(Message<?> message, String description, Throwable cause) {
|
||||
super(description, cause);
|
||||
this.failedMessage = message;
|
||||
}
|
||||
|
||||
public Message<?> getFailedMessage() {
|
||||
return this.failedMessage;
|
||||
}
|
||||
|
||||
public void setFailedMessage(Message<?> message) {
|
||||
this.failedMessage = message;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -20,15 +20,16 @@ import java.util.Set;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageHeaders;
|
||||
import org.springframework.integration.EiMessageHeaderAccessor;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base class for MessageGroupProcessor implementations that aggregate the group of Messages into a single Message.
|
||||
*
|
||||
*
|
||||
* @author Iwein Fuld
|
||||
* @author Alexander Peters
|
||||
* @author Mark Fisher
|
||||
@@ -41,7 +42,7 @@ public abstract class AbstractAggregatingMessageGroupProcessor implements Messag
|
||||
|
||||
public final Object processMessageGroup(MessageGroup group) {
|
||||
Assert.notNull(group, "MessageGroup must not be null");
|
||||
|
||||
|
||||
Map<String, Object> headers = this.aggregateHeaders(group);
|
||||
Object payload = this.aggregatePayloads(group, headers);
|
||||
MessageBuilder<?> builder;
|
||||
@@ -51,7 +52,7 @@ public abstract class AbstractAggregatingMessageGroupProcessor implements Messag
|
||||
else {
|
||||
builder = MessageBuilder.withPayload(payload).copyHeadersIfAbsent(headers);
|
||||
}
|
||||
|
||||
|
||||
return builder.popSequenceDetails().build();
|
||||
}
|
||||
|
||||
@@ -67,7 +68,7 @@ public abstract class AbstractAggregatingMessageGroupProcessor implements Messag
|
||||
MessageHeaders currentHeaders = message.getHeaders();
|
||||
for (String key : currentHeaders.keySet()) {
|
||||
if (MessageHeaders.ID.equals(key) || MessageHeaders.TIMESTAMP.equals(key)
|
||||
|| MessageHeaders.SEQUENCE_SIZE.equals(key) || MessageHeaders.SEQUENCE_NUMBER.equals(key)) {
|
||||
|| EiMessageHeaderAccessor.SEQUENCE_SIZE.equals(key) || EiMessageHeaderAccessor.SEQUENCE_NUMBER.equals(key)) {
|
||||
continue;
|
||||
}
|
||||
Object value = currentHeaders.get(key);
|
||||
|
||||
@@ -22,13 +22,9 @@ import java.util.concurrent.locks.Lock;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.MessageHeaders;
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.integration.EiMessageHeaderAccessor;
|
||||
import org.springframework.integration.channel.NullChannel;
|
||||
import org.springframework.integration.core.MessageProducer;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.integration.handler.AbstractMessageHandler;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
@@ -36,9 +32,14 @@ import org.springframework.integration.store.MessageGroupStore.MessageGroupCallb
|
||||
import org.springframework.integration.store.MessageStore;
|
||||
import org.springframework.integration.store.SimpleMessageGroup;
|
||||
import org.springframework.integration.store.SimpleMessageStore;
|
||||
import org.springframework.integration.support.converter.SimpleMessageConverter;
|
||||
import org.springframework.integration.util.DefaultLockRegistry;
|
||||
import org.springframework.integration.util.LockRegistry;
|
||||
import org.springframework.integration.util.UUIDConverter;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.core.GenericMessagingTemplate;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@@ -80,7 +81,7 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageH
|
||||
|
||||
private MessageChannel outputChannel;
|
||||
|
||||
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
private final GenericMessagingTemplate messagingTemplate = new GenericMessagingTemplate();
|
||||
|
||||
private volatile MessageChannel discardChannel = new NullChannel();
|
||||
|
||||
@@ -102,7 +103,7 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageH
|
||||
setMessageStore(store);
|
||||
this.outputProcessor = processor;
|
||||
this.correlationStrategy = correlationStrategy == null ?
|
||||
new HeaderAttributeCorrelationStrategy(MessageHeaders.CORRELATION_ID) : correlationStrategy;
|
||||
new HeaderAttributeCorrelationStrategy(EiMessageHeaderAccessor.CORRELATION_ID) : correlationStrategy;
|
||||
this.releaseStrategy = releaseStrategy == null ? new SequenceSizeReleaseStrategy() : releaseStrategy;
|
||||
this.messagingTemplate.setSendTimeout(DEFAULT_SEND_TIMEOUT);
|
||||
sequenceAware = this.releaseStrategy instanceof SequenceSizeReleaseStrategy;
|
||||
@@ -329,7 +330,7 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageH
|
||||
|
||||
Message<?> lastReleasedMessage = sorted.get(partialSequence.size()-1);
|
||||
|
||||
return lastReleasedMessage.getHeaders().getSequenceNumber();
|
||||
return new EiMessageHeaderAccessor(lastReleasedMessage).getSequenceNumber();
|
||||
}
|
||||
|
||||
private MessageGroup store(Object correlationKey, Message<?> message) {
|
||||
@@ -449,9 +450,10 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageH
|
||||
if (this.size() == 0) {
|
||||
return true;
|
||||
}
|
||||
Integer messageSequenceNumber = message.getHeaders().getSequenceNumber();
|
||||
EiMessageHeaderAccessor messageHeaderAccessor = new EiMessageHeaderAccessor(message);
|
||||
Integer messageSequenceNumber = messageHeaderAccessor.getSequenceNumber();
|
||||
if (messageSequenceNumber != null && messageSequenceNumber > 0) {
|
||||
Integer messageSequenceSize = message.getHeaders().getSequenceSize();
|
||||
Integer messageSequenceSize = messageHeaderAccessor.getSequenceSize();
|
||||
if (!messageSequenceSize.equals(this.getSequenceSize())) {
|
||||
return false;
|
||||
}
|
||||
@@ -464,7 +466,7 @@ public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageH
|
||||
|
||||
private boolean containsSequenceNumber(Collection<Message<?>> messages, Integer messageSequenceNumber) {
|
||||
for (Message<?> member : messages) {
|
||||
Integer memberSequenceNumber = member.getHeaders().getSequenceNumber();
|
||||
Integer memberSequenceNumber = new EiMessageHeaderAccessor(member).getSequenceNumber();
|
||||
if (messageSequenceNumber.equals(memberSequenceNumber)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ package org.springframework.integration.aggregator;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ import java.util.concurrent.ConcurrentMap;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.handler.AbstractMessageHandler;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.aggregator;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* Strategy for determining how messages can be correlated. Implementations
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.spel.SpelParserConfiguration;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
@@ -21,14 +21,13 @@ import java.util.Map;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
|
||||
/**
|
||||
* A {@link MessageGroupProcessor} implementation that evaluates a SpEL expression. The SpEL context root is the list of
|
||||
* all Messages in the group. The evaluation result can be any Object and is send as new Message payload to the output
|
||||
* channel.
|
||||
*
|
||||
*
|
||||
* @author Alex Peters
|
||||
* @author Dave Syer
|
||||
*/
|
||||
|
||||
@@ -23,7 +23,7 @@ import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.ParseException;
|
||||
import org.springframework.expression.spel.SpelParserConfiguration;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.util.AbstractExpressionEvaluator;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.integration.aggregator;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* Default implementation of {@link CorrelationStrategy}. Uses a header
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.integration.aggregator;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -27,4 +27,4 @@ public interface MessageListProcessor {
|
||||
|
||||
Object process(Collection<? extends Message<?>> messages);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,19 +18,20 @@ package org.springframework.integration.aggregator;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.EiMessageHeaderAccessor;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* A {@link Comparator} implementation based on the 'sequence number'
|
||||
* property of a {@link Message Message's} header.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class MessageSequenceComparator implements Comparator<Message<?>> {
|
||||
|
||||
public int compare(Message<?> message1, Message<?> message2) {
|
||||
Integer s1 = message1.getHeaders().getSequenceNumber();
|
||||
Integer s2 = message2.getHeaders().getSequenceNumber();
|
||||
Integer s1 = new EiMessageHeaderAccessor(message1).getSequenceNumber();
|
||||
Integer s2 = new EiMessageHeaderAccessor(message2).getSequenceNumber();
|
||||
if (s1 == null) {
|
||||
s1 = 0;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.integration.aggregator;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.handler.MethodInvokingMessageProcessor;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.annotation.Aggregator;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.util.AbstractExpressionEvaluator;
|
||||
import org.springframework.integration.util.MessagingMethodInvokerHelper;
|
||||
|
||||
|
||||
@@ -19,7 +19,8 @@ import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.EiMessageHeaderAccessor;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
|
||||
/**
|
||||
@@ -59,6 +60,6 @@ public class ResequencingMessageGroupProcessor implements MessageGroupProcessor
|
||||
}
|
||||
|
||||
private Integer extractSequenceNumber(Message<?> message) {
|
||||
return message.getHeaders().getSequenceNumber();
|
||||
return new EiMessageHeaderAccessor(message).getSequenceNumber();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2002-2011 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.
|
||||
@@ -15,13 +15,14 @@ package org.springframework.integration.aggregator;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.EiMessageHeaderAccessor;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.store.MessageGroupStore;
|
||||
|
||||
/**
|
||||
* Resequencer specific implementation of {@link AbstractCorrelatingMessageHandler}.
|
||||
* Will remove {@link MessageGroup}s only if 'sequenceSize' is provided and reached.
|
||||
* Resequencer specific implementation of {@link AbstractCorrelatingMessageHandler}.
|
||||
* Will remove {@link MessageGroup}s only if 'sequenceSize' is provided and reached.
|
||||
*
|
||||
* @author Oleg Zhurakousky
|
||||
* @since 2.1
|
||||
@@ -34,32 +35,32 @@ public class ResequencingMessageHandler extends AbstractCorrelatingMessageHandle
|
||||
super(processor, store, correlationStrategy, releaseStrategy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ResequencingMessageHandler(MessageGroupProcessor processor,
|
||||
MessageGroupStore store) {
|
||||
super(processor, store);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public ResequencingMessageHandler(MessageGroupProcessor processor) {
|
||||
super(processor);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void afterRelease(MessageGroup messageGroup, Collection<Message<?>> completedMessages) {
|
||||
|
||||
|
||||
int size = messageGroup.getMessages().size();
|
||||
int sequenceSize = 0;
|
||||
Message<?> message = messageGroup.getOne();
|
||||
if (message != null){
|
||||
sequenceSize = message.getHeaders().getSequenceSize();
|
||||
sequenceSize = new EiMessageHeaderAccessor(message).getSequenceSize();
|
||||
}
|
||||
// If there is no sequence then it must be incomplete or unbounded
|
||||
if (sequenceSize > 0 && sequenceSize == size){
|
||||
remove(messageGroup);
|
||||
}
|
||||
else {
|
||||
if (completedMessages != null){
|
||||
if (completedMessages != null){
|
||||
int lastReleasedSequenceNumber = this.findLastReleasedSequenceNumber(messageGroup.getGroupId(), completedMessages);
|
||||
messageStore.setLastReleasedSequenceNumberForGroup(messageGroup.getGroupId(), lastReleasedSequenceNumber);
|
||||
for (Message<?> msg : completedMessages) {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
/*
|
||||
* 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.
|
||||
@@ -15,13 +15,14 @@ package org.springframework.integration.aggregator;
|
||||
|
||||
import java.util.Comparator;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.EiMessageHeaderAccessor;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class SequenceNumberComparator implements Comparator<Message<?>> {
|
||||
|
||||
@@ -31,8 +32,8 @@ public class SequenceNumberComparator implements Comparator<Message<?>> {
|
||||
* rank.
|
||||
*/
|
||||
public int compare(Message<?> o1, Message<?> o2) {
|
||||
Integer sequenceNumber1 = o1.getHeaders().getSequenceNumber();
|
||||
Integer sequenceNumber2 = o2.getHeaders().getSequenceNumber();
|
||||
Integer sequenceNumber1 = new EiMessageHeaderAccessor(o1).getSequenceNumber();
|
||||
Integer sequenceNumber2 = new EiMessageHeaderAccessor(o2).getSequenceNumber();
|
||||
if (sequenceNumber1 == sequenceNumber2) {
|
||||
return 0;
|
||||
}
|
||||
@@ -45,4 +46,4 @@ public class SequenceNumberComparator implements Comparator<Message<?>> {
|
||||
return sequenceNumber1.compareTo(sequenceNumber2);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,13 +24,14 @@ import java.util.List;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.EiMessageHeaderAccessor;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
|
||||
/**
|
||||
* An implementation of {@link ReleaseStrategy} that simply compares the current size of the message list to the
|
||||
* expected 'sequenceSize'.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Marius Bogoevici
|
||||
* @author Dave Syer
|
||||
@@ -56,7 +57,7 @@ public class SequenceSizeReleaseStrategy implements ReleaseStrategy {
|
||||
/**
|
||||
* Flag that determines if partial sequences are allowed. If true then as soon as enough messages arrive that can be
|
||||
* ordered they will be released, provided they all have sequence numbers greater than those already released.
|
||||
*
|
||||
*
|
||||
* @param releasePartialSequences
|
||||
*/
|
||||
public void setReleasePartialSequences(boolean releasePartialSequences) {
|
||||
@@ -66,38 +67,38 @@ public class SequenceSizeReleaseStrategy implements ReleaseStrategy {
|
||||
public boolean canRelease(MessageGroup messageGroup) {
|
||||
|
||||
boolean canRelease = false;
|
||||
|
||||
|
||||
Collection<Message<?>> messages = messageGroup.getMessages();
|
||||
|
||||
|
||||
if (releasePartialSequences && !messages.isEmpty()) {
|
||||
|
||||
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Considering partial release of group [" + messageGroup + "]");
|
||||
}
|
||||
List<Message<?>> sorted = new ArrayList<Message<?>>(messages);
|
||||
Collections.sort(sorted, comparator);
|
||||
|
||||
int nextSequenceNumber = sorted.get(0).getHeaders().getSequenceNumber();
|
||||
|
||||
int nextSequenceNumber = new EiMessageHeaderAccessor(sorted.get(0)).getSequenceNumber();
|
||||
int lastReleasedMessageSequence = messageGroup.getLastReleasedMessageSequenceNumber();
|
||||
|
||||
|
||||
if (nextSequenceNumber - lastReleasedMessageSequence == 1){
|
||||
canRelease = true;;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
int size = messages.size();
|
||||
|
||||
|
||||
if (size == 0){
|
||||
canRelease = true;
|
||||
}
|
||||
else {
|
||||
int sequenceSize = messageGroup.getOne().getHeaders().getSequenceSize();
|
||||
int sequenceSize = new EiMessageHeaderAccessor(messageGroup.getOne()).getSequenceSize();
|
||||
// If there is no sequence then it must be incomplete....
|
||||
if (sequenceSize == size){
|
||||
canRelease = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return canRelease;
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
package org.springframework.integration.aggregator;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Provides classes related to message aggregation.
|
||||
*/
|
||||
package org.springframework.integration.aggregator;
|
||||
package org.springframework.integration.aggregator;
|
||||
|
||||
@@ -26,7 +26,7 @@ import java.lang.annotation.Target;
|
||||
* Indicates that a method is capable of playing the role of a Message Filter.
|
||||
* <p>
|
||||
* A method annotated with @Filter may accept a parameter of type
|
||||
* {@link org.springframework.integration.Message} or of the expected
|
||||
* {@link org.springframework.messaging.Message} or of the expected
|
||||
* Message payload's type. Any type conversion supported by default or any
|
||||
* Converters registered with the "integrationConversionService" bean will be
|
||||
* applied to the Message payload if necessary. Header values can also be passed
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.lang.annotation.Target;
|
||||
* where the annotation attributes can override the default channel settings.
|
||||
*
|
||||
* <p>A method annotated with @Gateway may accept a single non-annotated
|
||||
* parameter of type {@link org.springframework.integration.Message}
|
||||
* parameter of type {@link org.springframework.messaging.Message}
|
||||
* or of the intended Message payload type. Method parameters may be mapped
|
||||
* to individual Message header values by using the {@link Header @Header}
|
||||
* parameter annotation. Alternatively, to pass the entire Message headers
|
||||
|
||||
@@ -28,7 +28,7 @@ import java.lang.annotation.Target;
|
||||
* based on a message, message header(s), or both.
|
||||
* <p>
|
||||
* A method annotated with @Router may accept a parameter of type
|
||||
* {@link org.springframework.integration.Message} or of the expected
|
||||
* {@link org.springframework.messaging.Message} or of the expected
|
||||
* Message payload's type. Any type conversion supported by
|
||||
* {@link org.springframework.beans.SimpleTypeConverter} will be applied to
|
||||
* the Message payload if necessary. Header values can also be passed as
|
||||
@@ -36,7 +36,7 @@ import java.lang.annotation.Target;
|
||||
* <p>
|
||||
* Return values from the annotated method may be either a Collection or Array
|
||||
* whose elements are either
|
||||
* {@link org.springframework.integration.MessageChannel channels} or
|
||||
* {@link org.springframework.messaging.MessageChannel channels} or
|
||||
* Strings. In the latter case, the endpoint hosting this router will attempt
|
||||
* to resolve each channel name with the Channel Registry.
|
||||
*
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.lang.annotation.Target;
|
||||
* Indicates that a method is capable of handling a message or message payload.
|
||||
* <p>
|
||||
* A method annotated with @ServiceActivator may accept a parameter of type
|
||||
* {@link org.springframework.integration.Message} or of the expected
|
||||
* {@link org.springframework.messaging.Message} or of the expected
|
||||
* Message payload's type. Any type conversion supported by
|
||||
* {@link org.springframework.beans.SimpleTypeConverter} will be applied to
|
||||
* the Message payload if necessary. Header values can also be passed as
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.lang.annotation.Target;
|
||||
* payload to produce multiple messages or payloads.
|
||||
* <p>
|
||||
* A method annotated with @Splitter may accept a parameter of type
|
||||
* {@link org.springframework.integration.Message} or of the expected
|
||||
* {@link org.springframework.messaging.Message} or of the expected
|
||||
* Message payload's type. Any type conversion supported by
|
||||
* {@link org.springframework.beans.SimpleTypeConverter} will be applied to
|
||||
* the Message payload if necessary. Header values can also be passed as
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Provides annotations for annotation-based configuration.
|
||||
*/
|
||||
package org.springframework.integration.annotation;
|
||||
package org.springframework.integration.annotation;
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.util.Map;
|
||||
|
||||
import org.aopalliance.intercept.MethodInterceptor;
|
||||
import org.aopalliance.intercept.MethodInvocation;
|
||||
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
@@ -36,12 +35,12 @@ import org.springframework.expression.ParseException;
|
||||
import org.springframework.expression.spel.SpelParserConfiguration;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.expression.spel.support.StandardEvaluationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.core.MessagingTemplate;
|
||||
import org.springframework.integration.expression.ExpressionUtils;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.integration.support.channel.ChannelResolver;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.core.DestinationResolver;
|
||||
import org.springframework.messaging.core.GenericMessagingTemplate;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -56,13 +55,13 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
public class MessagePublishingInterceptor implements MethodInterceptor, BeanFactoryAware {
|
||||
|
||||
private final MessagingTemplate messagingTemplate = new MessagingTemplate();
|
||||
private final GenericMessagingTemplate messagingTemplate = new GenericMessagingTemplate();
|
||||
|
||||
private volatile PublisherMetadataSource metadataSource;
|
||||
|
||||
private final ExpressionParser parser = new SpelExpressionParser(new SpelParserConfiguration(true, true));
|
||||
|
||||
private volatile ChannelResolver channelResolver;
|
||||
private volatile DestinationResolver<MessageChannel> channelResolver;
|
||||
|
||||
private volatile BeanFactory beanFactory;
|
||||
|
||||
@@ -81,10 +80,10 @@ public class MessagePublishingInterceptor implements MethodInterceptor, BeanFact
|
||||
}
|
||||
|
||||
public void setDefaultChannel(MessageChannel defaultChannel) {
|
||||
this.messagingTemplate.setDefaultChannel(defaultChannel);
|
||||
this.messagingTemplate.setDefaultDestination(defaultChannel);
|
||||
}
|
||||
|
||||
public void setChannelResolver(ChannelResolver channelResolver) {
|
||||
public void setChannelResolver(DestinationResolver<MessageChannel> channelResolver) {
|
||||
this.channelResolver = channelResolver;
|
||||
}
|
||||
|
||||
@@ -150,7 +149,7 @@ public class MessagePublishingInterceptor implements MethodInterceptor, BeanFact
|
||||
MessageChannel channel = null;
|
||||
if (channelName != null) {
|
||||
Assert.state(this.channelResolver != null, "ChannelResolver is required to resolve channel names.");
|
||||
channel = this.channelResolver.resolveChannelName(channelName);
|
||||
channel = this.channelResolver.resolveDestination(channelName);
|
||||
}
|
||||
if (channel != null) {
|
||||
this.messagingTemplate.send(channel, message);
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
|
||||
import org.springframework.aop.ClassFilter;
|
||||
import org.springframework.aop.MethodMatcher;
|
||||
import org.springframework.aop.Pointcut;
|
||||
@@ -35,9 +34,9 @@ import org.springframework.aop.support.annotation.AnnotationMethodMatcher;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.annotation.Publisher;
|
||||
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.core.BeanFactoryMessageChannelDestinationResolver;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
@@ -73,7 +72,7 @@ public class PublisherAnnotationAdvisor extends AbstractPointcutAdvisor implemen
|
||||
}
|
||||
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
this.interceptor.setChannelResolver(new BeanFactoryChannelResolver(beanFactory));
|
||||
this.interceptor.setChannelResolver(new BeanFactoryMessageChannelDestinationResolver(beanFactory));
|
||||
this.interceptor.setBeanFactory(beanFactory);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.annotation.Publisher;
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Provides classes to support message publication using AOP.
|
||||
*/
|
||||
package org.springframework.integration.aop;
|
||||
package org.springframework.integration.aop;
|
||||
|
||||
@@ -24,14 +24,14 @@ import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.core.OrderComparator;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.MessageDeliveryException;
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.history.TrackableComponent;
|
||||
import org.springframework.integration.support.MessageBuilder;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.integration.channel;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
|
||||
/**
|
||||
* Base class for all pollable channels.
|
||||
|
||||
@@ -18,14 +18,14 @@ package org.springframework.integration.channel;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.MessageDeliveryException;
|
||||
import org.springframework.integration.MessageDispatchingException;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.core.SubscribableChannel;
|
||||
import org.springframework.integration.dispatcher.AbstractDispatcher;
|
||||
import org.springframework.integration.dispatcher.MessageDispatcher;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.integration.channel;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
* Interface for interceptors that are able to view and/or modify the
|
||||
|
||||
@@ -19,7 +19,7 @@ package org.springframework.integration.channel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@ package org.springframework.integration.channel;
|
||||
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.core.BeanFactoryMessageChannelDestinationResolver;
|
||||
import org.springframework.integration.dispatcher.LoadBalancingStrategy;
|
||||
import org.springframework.integration.dispatcher.RoundRobinLoadBalancingStrategy;
|
||||
import org.springframework.integration.dispatcher.UnicastingDispatcher;
|
||||
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
|
||||
import org.springframework.integration.util.ErrorHandlingTaskExecutor;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
@@ -111,7 +111,7 @@ public class ExecutorChannel extends AbstractSubscribableChannel {
|
||||
public final void onInit() {
|
||||
if (!(this.executor instanceof ErrorHandlingTaskExecutor)) {
|
||||
ErrorHandler errorHandler = new MessagePublishingErrorHandler(
|
||||
new BeanFactoryChannelResolver(this.getBeanFactory()));
|
||||
new BeanFactoryMessageChannelDestinationResolver(this.getBeanFactory()));
|
||||
this.executor = new ErrorHandlingTaskExecutor(this.executor, errorHandler);
|
||||
}
|
||||
this.dispatcher = new UnicastingDispatcher(this.executor);
|
||||
|
||||
@@ -21,20 +21,20 @@ import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.MessagingException;
|
||||
import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.message.ErrorMessage;
|
||||
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
|
||||
import org.springframework.integration.support.channel.ChannelResolver;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.messaging.core.BeanFactoryMessageChannelDestinationResolver;
|
||||
import org.springframework.messaging.core.DestinationResolver;
|
||||
import org.springframework.messaging.support.ErrorMessage;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
/**
|
||||
* {@link ErrorHandler} implementation that sends an {@link ErrorMessage} to a
|
||||
* {@link MessageChannel}.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Iwein Fuld
|
||||
* @author Oleg Zhurakousky
|
||||
@@ -43,7 +43,7 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
||||
private volatile ChannelResolver channelResolver;
|
||||
private volatile DestinationResolver<MessageChannel> channelResolver;
|
||||
|
||||
private volatile MessageChannel defaultErrorChannel;
|
||||
|
||||
@@ -53,7 +53,7 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA
|
||||
public MessagePublishingErrorHandler() {
|
||||
}
|
||||
|
||||
public MessagePublishingErrorHandler(ChannelResolver channelResolver) {
|
||||
public MessagePublishingErrorHandler(DestinationResolver<MessageChannel> channelResolver) {
|
||||
Assert.notNull(channelResolver, "channelResolver must not be null");
|
||||
this.channelResolver = channelResolver;
|
||||
}
|
||||
@@ -70,7 +70,7 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA
|
||||
public void setBeanFactory(BeanFactory beanFactory) {
|
||||
Assert.notNull(beanFactory, "beanFactory must not be null");
|
||||
if (this.channelResolver == null) {
|
||||
this.channelResolver = new BeanFactoryChannelResolver(beanFactory);
|
||||
this.channelResolver = new BeanFactoryMessageChannelDestinationResolver(beanFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -108,10 +108,10 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA
|
||||
Message<?> failedMessage = (t instanceof MessagingException) ?
|
||||
((MessagingException) t).getFailedMessage() : null;
|
||||
if (this.defaultErrorChannel == null && this.channelResolver != null) {
|
||||
this.defaultErrorChannel = this.channelResolver.resolveChannelName(
|
||||
this.defaultErrorChannel = this.channelResolver.resolveDestination(
|
||||
IntegrationContextUtils.ERROR_CHANNEL_BEAN_NAME);
|
||||
}
|
||||
|
||||
|
||||
if (failedMessage == null || failedMessage.getHeaders().getErrorChannel() == null) {
|
||||
return this.defaultErrorChannel;
|
||||
}
|
||||
@@ -122,7 +122,7 @@ public class MessagePublishingErrorHandler implements ErrorHandler, BeanFactoryA
|
||||
Assert.isInstanceOf(String.class, errorChannelHeader,
|
||||
"Unsupported error channel header type. Expected MessageChannel or String, but actual type is [" +
|
||||
errorChannelHeader.getClass() + "]");
|
||||
return this.channelResolver.resolveChannelName((String) errorChannelHeader);
|
||||
return this.channelResolver.resolveDestination((String) errorChannelHeader);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.integration.channel;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
|
||||
/**
|
||||
* A channel implementation that essentially behaves like "/dev/null".
|
||||
|
||||
@@ -20,21 +20,22 @@ import java.util.Comparator;
|
||||
import java.util.concurrent.PriorityBlockingQueue;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageHeaders;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.integration.EiMessageHeaderAccessor;
|
||||
import org.springframework.integration.util.UpperBound;
|
||||
|
||||
/**
|
||||
* A message channel that prioritizes messages based on a {@link Comparator}.
|
||||
* The default comparator is based upon the message header's 'priority'.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
*/
|
||||
public class PriorityChannel extends QueueChannel {
|
||||
|
||||
private final UpperBound upperBound;
|
||||
|
||||
|
||||
private final AtomicLong sequenceCounter = new AtomicLong();
|
||||
|
||||
/**
|
||||
@@ -93,11 +94,11 @@ public class PriorityChannel extends QueueChannel {
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
|
||||
private static class SequenceFallbackComparator implements Comparator<Message<?>> {
|
||||
|
||||
|
||||
private final Comparator<Message<?>> targetComparator;
|
||||
|
||||
|
||||
public SequenceFallbackComparator(Comparator<Message<?>> targetComparator){
|
||||
this.targetComparator = targetComparator;
|
||||
}
|
||||
@@ -108,14 +109,14 @@ public class PriorityChannel extends QueueChannel {
|
||||
compareResult = this.targetComparator.compare(message1, message2);
|
||||
}
|
||||
else {
|
||||
Integer priority1 = message1.getHeaders().getPriority();
|
||||
Integer priority2 = message2.getHeaders().getPriority();
|
||||
|
||||
Integer priority1 = new EiMessageHeaderAccessor(message1).getPriority();
|
||||
Integer priority2 = new EiMessageHeaderAccessor(message2).getPriority();
|
||||
|
||||
priority1 = priority1 != null ? priority1 : 0;
|
||||
priority2 = priority2 != null ? priority2 : 0;
|
||||
compareResult = priority2.compareTo(priority1);
|
||||
}
|
||||
|
||||
|
||||
if (compareResult == 0){
|
||||
Long sequence1 = ((MessageWrapper) message1).getSequence();
|
||||
Long sequence2 = ((MessageWrapper) message2).getSequence();
|
||||
@@ -124,7 +125,7 @@ public class PriorityChannel extends QueueChannel {
|
||||
return compareResult;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//we need this because of INT-2508
|
||||
private class MessageWrapper implements Message<Object>{
|
||||
private final Message<?> rootMessage;
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.integration.channel;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
import org.springframework.integration.dispatcher.BroadcastingDispatcher;
|
||||
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
|
||||
import org.springframework.integration.util.ErrorHandlingTaskExecutor;
|
||||
import org.springframework.messaging.core.BeanFactoryMessageChannelDestinationResolver;
|
||||
import org.springframework.util.ErrorHandler;
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ public class PublishSubscribeChannel extends AbstractSubscribableChannel {
|
||||
if (!(this.executor instanceof ErrorHandlingTaskExecutor)) {
|
||||
if (this.errorHandler == null) {
|
||||
this.errorHandler = new MessagePublishingErrorHandler(
|
||||
new BeanFactoryChannelResolver(this.getBeanFactory()));
|
||||
new BeanFactoryMessageChannelDestinationResolver(this.getBeanFactory()));
|
||||
}
|
||||
this.executor = new ErrorHandlingTaskExecutor(this.executor, this.errorHandler);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ package org.springframework.integration.channel;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.integration.channel;
|
||||
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
* A zero-capacity version of {@link QueueChannel} that delegates to a
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
|
||||
package org.springframework.integration.channel.interceptor;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
|
||||
/**
|
||||
|
||||
@@ -33,7 +33,7 @@ import org.springframework.beans.NotReadablePropertyException;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.core.OrderComparator;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
import org.springframework.util.PatternMatchUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -19,16 +19,16 @@ package org.springframework.integration.channel.interceptor;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.MessageDeliveryException;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
|
||||
/**
|
||||
* A {@link org.springframework.integration.channel.ChannelInterceptor} that
|
||||
* delegates to a list of {@link MessageSelector MessageSelectors} to decide
|
||||
* whether a {@link Message} should be accepted on the {@link MessageChannel}.
|
||||
*
|
||||
*
|
||||
* @author Mark Fisher
|
||||
*/
|
||||
public class MessageSelectingInterceptor extends ChannelInterceptorAdapter {
|
||||
|
||||
@@ -19,8 +19,8 @@ package org.springframework.integration.channel.interceptor;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.ChannelInterceptor;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Provides classes related to channel interception.
|
||||
*/
|
||||
package org.springframework.integration.channel.interceptor;
|
||||
package org.springframework.integration.channel.interceptor;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/**
|
||||
* Provides classes representing various channel types.
|
||||
*/
|
||||
package org.springframework.integration.channel;
|
||||
package org.springframework.integration.channel;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
package org.springframework.integration.channel.registry;
|
||||
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
* A strategy interface used to bind a {@link MessageChannel} to a logical name. The name
|
||||
|
||||
@@ -18,12 +18,12 @@ import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.context.support.AbstractApplicationContext;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.channel.AbstractMessageChannel;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.channel.PublishSubscribeChannel;
|
||||
import org.springframework.integration.channel.interceptor.WireTap;
|
||||
import org.springframework.integration.core.SubscribableChannel;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.integration.handler.BridgeHandler;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
|
||||
@@ -25,12 +25,12 @@ import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.BeanInitializationException;
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.integration.context.Orderable;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.core.MessageProducer;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
|
||||
@@ -22,9 +22,9 @@ import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.ExpressionParser;
|
||||
import org.springframework.expression.spel.SpelParserConfiguration;
|
||||
import org.springframework.expression.spel.standard.SpelExpressionParser;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
||||
@@ -33,11 +33,11 @@ import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.core.PollableChannel;
|
||||
import org.springframework.integration.core.SubscribableChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.endpoint.PollingConsumer;
|
||||
|
||||
@@ -18,26 +18,26 @@ package org.springframework.integration.config;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.integration.MessageHeaders;
|
||||
import org.springframework.integration.EiMessageHeaderAccessor;
|
||||
import org.springframework.integration.aggregator.CorrelationStrategy;
|
||||
import org.springframework.integration.aggregator.MethodInvokingCorrelationStrategy;
|
||||
import org.springframework.integration.aggregator.HeaderAttributeCorrelationStrategy;
|
||||
import org.springframework.integration.aggregator.MethodInvokingCorrelationStrategy;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* Convenience factory for XML configuration of a {@link CorrelationStrategy}. Encapsulates the knowledge of the default
|
||||
* strategy and search algorithms for POJO and annotated methods.
|
||||
*
|
||||
*
|
||||
* @author Dave Syer
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class CorrelationStrategyFactoryBean implements FactoryBean<CorrelationStrategy> {
|
||||
|
||||
private CorrelationStrategy delegate = new HeaderAttributeCorrelationStrategy(MessageHeaders.CORRELATION_ID);
|
||||
private CorrelationStrategy delegate = new HeaderAttributeCorrelationStrategy(EiMessageHeaderAccessor.CORRELATION_ID);
|
||||
|
||||
/**
|
||||
* Create a factory and set up the delegate which clients of the factory will see as its product.
|
||||
*
|
||||
*
|
||||
* @param target the target object (null if default strategy is acceptable)
|
||||
*/
|
||||
public CorrelationStrategyFactoryBean(Object target) {
|
||||
@@ -46,7 +46,7 @@ public class CorrelationStrategyFactoryBean implements FactoryBean<CorrelationSt
|
||||
|
||||
/**
|
||||
* Create a factory and set up the delegate which clients of the factory will see as its product.
|
||||
*
|
||||
*
|
||||
* @param target the target object (null if default strategy is acceptable)
|
||||
* @param methodName the method name to invoke in the target (null if it can be inferred)
|
||||
*/
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.List;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.expression.MethodFilter;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.integration.handler.ExpressionCommandMessageProcessor;
|
||||
import org.springframework.integration.handler.ServiceActivatingHandler;
|
||||
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.filter.ExpressionEvaluatingSelector;
|
||||
import org.springframework.integration.filter.MessageFilter;
|
||||
|
||||
@@ -30,8 +30,8 @@ import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ApplicationContextEvent;
|
||||
import org.springframework.context.event.ContextClosedEvent;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.integration.MessageHeaders;
|
||||
import org.springframework.integration.MessageHeaders.IdGenerator;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
import org.springframework.messaging.MessageHeaders.IdGenerator;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
/*
|
||||
<<<<<<< HEAD
|
||||
* Copyright 2002-2013 the original author or authors.
|
||||
=======
|
||||
* Copyright 2002-2011 the original author or authors.
|
||||
>>>>>>> Further Spring 4 updates.
|
||||
*
|
||||
* 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
|
||||
@@ -17,16 +21,15 @@ import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.router.AbstractMappingMessageRouter;
|
||||
import org.springframework.integration.router.AbstractMessageRouter;
|
||||
import org.springframework.integration.router.ExpressionEvaluatingRouter;
|
||||
import org.springframework.integration.router.MethodInvokingRouter;
|
||||
import org.springframework.integration.support.channel.ChannelResolver;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.core.DestinationResolver;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -55,10 +58,9 @@ public class RouterFactoryBean extends AbstractStandardMessageHandlerFactoryBean
|
||||
|
||||
private volatile Boolean ignoreSendFailures;
|
||||
|
||||
private volatile ChannelResolver channelResolver;
|
||||
private volatile DestinationResolver<MessageChannel> channelResolver;
|
||||
|
||||
|
||||
public void setChannelResolver(ChannelResolver channelResolver) {
|
||||
public void setChannelResolver(DestinationResolver<MessageChannel> channelResolver) {
|
||||
this.channelResolver = channelResolver;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.handler.ExpressionEvaluatingMessageProcessor;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.integration.handler.ServiceActivatingHandler;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,7 @@ import org.springframework.beans.factory.FactoryBean;
|
||||
import org.springframework.beans.factory.InitializingBean;
|
||||
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
|
||||
import org.springframework.integration.scheduling.PollerMetadata;
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.splitter.AbstractMessageSplitter;
|
||||
import org.springframework.integration.splitter.DefaultMessageSplitter;
|
||||
import org.springframework.integration.splitter.ExpressionEvaluatingSplitter;
|
||||
import org.springframework.integration.splitter.MethodInvokingSplitter;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
||||
@@ -17,12 +17,12 @@
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.transformer.ExpressionEvaluatingTransformer;
|
||||
import org.springframework.integration.transformer.MessageTransformingHandler;
|
||||
import org.springframework.integration.transformer.MethodInvokingTransformer;
|
||||
import org.springframework.integration.transformer.Transformer;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
||||
@@ -23,22 +23,21 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
import org.aopalliance.aop.Advice;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.core.annotation.AnnotationUtils;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.context.Orderable;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.integration.core.SubscribableChannel;
|
||||
import org.springframework.integration.endpoint.AbstractEndpoint;
|
||||
import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.support.channel.BeanFactoryChannelResolver;
|
||||
import org.springframework.integration.support.channel.ChannelResolver;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.messaging.SubscribableChannel;
|
||||
import org.springframework.messaging.core.BeanFactoryMessageChannelDestinationResolver;
|
||||
import org.springframework.messaging.core.DestinationResolver;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -57,13 +56,13 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
|
||||
protected final BeanFactory beanFactory;
|
||||
|
||||
protected final ChannelResolver channelResolver;
|
||||
protected final DestinationResolver<MessageChannel> channelResolver;
|
||||
|
||||
|
||||
public AbstractMethodAnnotationPostProcessor(ListableBeanFactory beanFactory) {
|
||||
Assert.notNull(beanFactory, "BeanFactory must not be null");
|
||||
this.beanFactory = beanFactory;
|
||||
this.channelResolver = new BeanFactoryChannelResolver(beanFactory);
|
||||
this.channelResolver = new BeanFactoryMessageChannelDestinationResolver(beanFactory);
|
||||
}
|
||||
|
||||
|
||||
@@ -128,7 +127,7 @@ public abstract class AbstractMethodAnnotationPostProcessor<T extends Annotation
|
||||
AbstractEndpoint endpoint = null;
|
||||
String inputChannelName = (String) AnnotationUtils.getValue(annotation, INPUT_CHANNEL_ATTRIBUTE);
|
||||
if (StringUtils.hasText(inputChannelName)) {
|
||||
MessageChannel inputChannel = this.channelResolver.resolveChannelName(inputChannelName);
|
||||
MessageChannel inputChannel = this.channelResolver.resolveDestination(inputChannelName);
|
||||
Assert.notNull(inputChannel, "failed to resolve inputChannel '" + inputChannelName + "'");
|
||||
Assert.isTrue(inputChannel instanceof SubscribableChannel,
|
||||
"The input channel for an Annotation-based endpoint must be a SubscribableChannel.");
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user