INT-1257, INT-1263 Refactoring Message History (work in progress): Removed MessageHistoryWriter. Added MessageHistory.

This commit is contained in:
Mark Fisher
2010-08-25 19:25:26 +00:00
parent 85eaa2688f
commit 1c8da6f251
12 changed files with 293 additions and 142 deletions

View File

@@ -31,9 +31,9 @@ import org.springframework.integration.MessageDeliveryException;
import org.springframework.integration.MessagingException;
import org.springframework.integration.context.HistoryProvider;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.context.MessageHistoryWriter;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessageHistory;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
@@ -170,7 +170,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport im
Assert.notNull(message, "message must not be null");
Assert.notNull(message.getPayload(), "message payload must not be null");
if (this.shouldIncludeInHistory) {
message = MessageHistoryWriter.writeHistory(this, message);
message = MessageHistory.addComponentToHistory(message, this);
}
message = this.convertPayloadIfNecessary(message);
message = this.interceptors.preSend(message, this);

View File

@@ -1,71 +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.context;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessageHandler;
import org.springframework.util.StringUtils;
/**
* This component is responsible for maintaining the history of {@link MessageChannel}s and
* {@link MessageHandler}s. There can only be one instance of this class per ApplicationContext
* hierarchy otherwise an Exception will be thrown.
*
* @author Oleg Zhurakousky
* @author Mark Fisher
* @since 2.0
*/
public abstract class MessageHistoryWriter {
public static final String NAME_PROPERTY = "name";
public static final String TYPE_PROPERTY = "type";
public static final String TIMESTAMP_PROPERTY = "timestamp";
@SuppressWarnings({"unchecked", "rawtypes"})
public static <T> Message<T> writeHistory(NamedComponent component, Message<T> message) {
if (component != null && message != null) {
String componentName = component.getComponentName();
if (componentName != null && !componentName.startsWith("org.springframework.integration")) {
Properties historyEvent = new Properties();
String componentType = component.getComponentType();
if (StringUtils.hasText(componentType)) {
historyEvent.setProperty(TYPE_PROPERTY, componentType);
}
historyEvent.setProperty(NAME_PROPERTY, componentName);
historyEvent.setProperty(TIMESTAMP_PROPERTY, "" + System.currentTimeMillis());
List history = message.getHeaders().get(MessageHeaders.HISTORY, List.class);
if (history == null) {
history = new ArrayList();
}
history.add(historyEvent);
message = MessageBuilder.fromMessage(message).setHeader(MessageHeaders.HISTORY, history).build();
}
}
return message;
}
}

View File

@@ -0,0 +1,222 @@
/*
* 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.core;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Properties;
import org.springframework.integration.Message;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.context.NamedComponent;
import org.springframework.util.Assert;
/**
* @author Mark Fisher
* @since 2.0
*/
public class MessageHistory implements List<Properties> {
public static final String HEADER_NAME = MessageHeaders.PREFIX + "history";
public static final String NAME_PROPERTY = "name";
public static final String TYPE_PROPERTY = "type";
public static final String TIMESTAMP_PROPERTY = "timestamp";
private final List<Properties> components;
public static <T> Message<T> addComponentToHistory(Message<T> message, NamedComponent component) {
Assert.notNull(message, "Message must not be null");
Assert.notNull(component, "Component must not be null");
Properties metadata = extractMetadata(component);
if (!metadata.isEmpty()) {
MessageHistory previousHistory = message.getHeaders().get(HEADER_NAME, MessageHistory.class);
List<Properties> components = (previousHistory != null) ?
new ArrayList<Properties>(previousHistory) : new ArrayList<Properties>();
components.add(metadata);
MessageHistory history = new MessageHistory(components);
message = MessageBuilder.fromMessage(message).setHeader(HEADER_NAME, history).build();
}
return message;
}
private MessageHistory(List<Properties> components) {
Assert.notEmpty(components, "component list must not be empty");
this.components = components;
}
public int size() {
return this.components.size();
}
public boolean isEmpty() {
return this.components.isEmpty();
}
public boolean contains(Object o) {
return this.components.contains(o);
}
public boolean containsAll(Collection<?> c) {
return this.components.containsAll(c);
}
public Properties get(int index) {
return this.components.get(index);
}
public Iterator<Properties> iterator() {
return Collections.unmodifiableList(this.components).iterator();
}
public ListIterator<Properties> listIterator() {
return Collections.unmodifiableList(this.components).listIterator();
}
public ListIterator<Properties> listIterator(int index) {
return Collections.unmodifiableList(this.components).listIterator(index);
}
public List<Properties> subList(int fromIndex, int toIndex) {
return Collections.unmodifiableList(this.components).subList(fromIndex, toIndex);
}
public Object[] toArray() {
return this.components.toArray();
}
public <T> T[] toArray(T[] a) {
return this.components.toArray(a);
}
public int indexOf(Object o) {
return this.components.indexOf(o);
}
public int lastIndexOf(Object o) {
return this.components.lastIndexOf(o);
}
public String toString() {
return this.components.toString();
}
/*
* Unsupported Operations
*/
public boolean add(Properties e) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
}
public void add(int index, Properties element) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
}
public boolean addAll(Collection<? extends Properties> c) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
}
public boolean addAll(int index, Collection<? extends Properties> c) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
}
public Properties set(int index, Properties element) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
}
public Properties remove(int index) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
}
public boolean remove(Object o) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
}
public boolean removeAll(Collection<?> c) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
}
public boolean retainAll(Collection<?> c) {
throw new UnsupportedOperationException("MessageHistory is immutable.");
}
public void clear() {
throw new UnsupportedOperationException("MessageHistory is immutable.");
}
private static Properties extractMetadata(NamedComponent component) {
Entry entry = new Entry();
String name = component.getComponentName();
String type = component.getComponentType();
if (name != null && !name.startsWith("org.springframework.integration")) {
entry.setName(name);
if (type != null) {
entry.setType(type);
}
}
if (!entry.isEmpty()) {
entry.setTimestamp(Long.toString(System.currentTimeMillis()));
}
return entry;
}
/**
* Inner class for each Entry in the history.
*/
@SuppressWarnings("serial")
public static class Entry extends Properties {
public String getName() {
return this.getProperty(NAME_PROPERTY);
}
private void setName(String name) {
this.setProperty(NAME_PROPERTY, name);
}
public String getType() {
return this.getProperty(TYPE_PROPERTY);
}
private void setType(String type) {
this.setProperty(TYPE_PROPERTY, type);
}
public String getTimestamp() {
return this.getProperty(TIMESTAMP_PROPERTY);
}
private void setTimestamp(String timestamp) {
this.setProperty(TIMESTAMP_PROPERTY, timestamp);
}
}
}

View File

@@ -17,8 +17,8 @@
package org.springframework.integration.endpoint;
import org.springframework.integration.Message;
import org.springframework.integration.context.MessageHistoryWriter;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessageHistory;
import org.springframework.integration.core.MessageProducer;
import org.springframework.integration.core.MessagingTemplate;
import org.springframework.util.Assert;
@@ -51,7 +51,7 @@ public abstract class MessageProducerSupport extends AbstractEndpoint implements
protected void sendMessage(Message<?> message) {
if (message != null) {
message = MessageHistoryWriter.writeHistory(this, message);
message = MessageHistory.addComponentToHistory(message, this);
}
this.messagingTemplate.send(this.outputChannel, message);
}

View File

@@ -19,7 +19,7 @@ package org.springframework.integration.gateway;
import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
import org.springframework.integration.context.HistoryProvider;
import org.springframework.integration.context.MessageHistoryWriter;
import org.springframework.integration.core.MessageHistory;
import org.springframework.integration.mapping.InboundMessageMapper;
import org.springframework.integration.mapping.OutboundMessageMapper;
import org.springframework.util.Assert;
@@ -90,7 +90,7 @@ public class SimpleMessagingGateway extends AbstractMessagingGateway implements
try {
message = this.inboundMapper.toMessage(object);
if (this.shouldIncludeInHistory) {
message = MessageHistoryWriter.writeHistory(this, message);
message = MessageHistory.addComponentToHistory(message, this);
}
}
catch (Exception e) {

View File

@@ -25,8 +25,8 @@ import org.springframework.integration.MessageHandlingException;
import org.springframework.integration.MessagingException;
import org.springframework.integration.context.HistoryProvider;
import org.springframework.integration.context.IntegrationObjectSupport;
import org.springframework.integration.context.MessageHistoryWriter;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.MessageHistory;
import org.springframework.util.Assert;
/**
@@ -72,7 +72,7 @@ public abstract class AbstractMessageHandler extends IntegrationObjectSupport im
}
try {
if (message != null && this.shouldIncludeInHistory) {
message = MessageHistoryWriter.writeHistory(this, message);
message = MessageHistory.addComponentToHistory(message, this);
}
this.handleMessageInternal(message);
}

View File

@@ -38,9 +38,9 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.integration.Message;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.config.ConsumerEndpointFactoryBean;
import org.springframework.integration.context.MessageHistoryWriter;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.MessageHistory;
/**
* @author Oleg Zhurakousky
@@ -79,60 +79,60 @@ public class MessageHistoryIntegrationTests {
Iterator<Properties> historyIterator = message.getHeaders().getHistory().iterator();
Properties event1 = historyIterator.next();
assertEquals("sampleGateway", event1.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("gateway", event1.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("sampleGateway", event1.getProperty(MessageHistory.NAME_PROPERTY));
assertEquals("gateway", event1.getProperty(MessageHistory.TYPE_PROPERTY));
Properties event2 = historyIterator.next();
assertEquals("bridgeInChannel", event2.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("channel", event2.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("bridgeInChannel", event2.getProperty(MessageHistory.NAME_PROPERTY));
assertEquals("channel", event2.getProperty(MessageHistory.TYPE_PROPERTY));
Properties event3 = historyIterator.next();
assertEquals("testBridge", event3.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("bridge", event3.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("testBridge", event3.getProperty(MessageHistory.NAME_PROPERTY));
assertEquals("bridge", event3.getProperty(MessageHistory.TYPE_PROPERTY));
Properties event4 = historyIterator.next();
assertEquals("headerEnricherChannel", event4.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("channel", event4.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("headerEnricherChannel", event4.getProperty(MessageHistory.NAME_PROPERTY));
assertEquals("channel", event4.getProperty(MessageHistory.TYPE_PROPERTY));
Properties event5 = historyIterator.next();
assertEquals("testHeaderEnricher", event5.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("transformer", event5.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("testHeaderEnricher", event5.getProperty(MessageHistory.NAME_PROPERTY));
assertEquals("transformer", event5.getProperty(MessageHistory.TYPE_PROPERTY));
Properties event6 = historyIterator.next();
assertEquals("chainChannel", event6.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("channel", event6.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("chainChannel", event6.getProperty(MessageHistory.NAME_PROPERTY));
assertEquals("channel", event6.getProperty(MessageHistory.TYPE_PROPERTY));
Properties event7 = historyIterator.next();
assertEquals("sampleChain", event7.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("chain", event7.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("sampleChain", event7.getProperty(MessageHistory.NAME_PROPERTY));
assertEquals("chain", event7.getProperty(MessageHistory.TYPE_PROPERTY));
Properties event8 = historyIterator.next();
assertEquals("filterChannel", event8.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("channel", event8.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("filterChannel", event8.getProperty(MessageHistory.NAME_PROPERTY));
assertEquals("channel", event8.getProperty(MessageHistory.TYPE_PROPERTY));
Properties event9 = historyIterator.next();
assertEquals("testFilter", event9.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("filter", event9.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("testFilter", event9.getProperty(MessageHistory.NAME_PROPERTY));
assertEquals("filter", event9.getProperty(MessageHistory.TYPE_PROPERTY));
Properties event10 = historyIterator.next();
assertEquals("splitterChannel", event10.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("channel", event10.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("splitterChannel", event10.getProperty(MessageHistory.NAME_PROPERTY));
assertEquals("channel", event10.getProperty(MessageHistory.TYPE_PROPERTY));
Properties event11 = historyIterator.next();
assertEquals("testSplitter", event11.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("splitter", event11.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("testSplitter", event11.getProperty(MessageHistory.NAME_PROPERTY));
assertEquals("splitter", event11.getProperty(MessageHistory.TYPE_PROPERTY));
Properties event12 = historyIterator.next();
assertEquals("aggregatorChannel", event12.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("channel", event12.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("aggregatorChannel", event12.getProperty(MessageHistory.NAME_PROPERTY));
assertEquals("channel", event12.getProperty(MessageHistory.TYPE_PROPERTY));
Properties event13 = historyIterator.next();
assertEquals("testAggregator", event13.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("aggregator", event13.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("testAggregator", event13.getProperty(MessageHistory.NAME_PROPERTY));
assertEquals("aggregator", event13.getProperty(MessageHistory.TYPE_PROPERTY));
Properties event14 = historyIterator.next();
assertEquals("endOfThePipeChannel", event14.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("channel", event14.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("endOfThePipeChannel", event14.getProperty(MessageHistory.NAME_PROPERTY));
assertEquals("channel", event14.getProperty(MessageHistory.TYPE_PROPERTY));
MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
replyChannel.send(message);
@@ -181,12 +181,12 @@ public class MessageHistoryIntegrationTests {
}
@Test(expected=BeanDefinitionParsingException.class)
public void testMessageHistoryMoreThenOneNamespaceFail() {
public void testMessageHistoryMoreThanOneNamespaceFail() {
new ClassPathXmlApplicationContext("messageHistoryWithHistoryWriterNamespace-fail.xml", MessageHistoryIntegrationTests.class);
}
@Test(expected=BeanCreationException.class)
public void testMessageHistoryMoreThenOneFail() {
@Test(expected=BeanCreationException.class) @Ignore
public void testMessageHistoryMoreThanOneFail() {
new ClassPathXmlApplicationContext("messageHistoryWithHistoryWriter-fail.xml", MessageHistoryIntegrationTests.class);
}

View File

@@ -5,7 +5,7 @@
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-2.0.xsd">
<bean class="org.springframework.integration.context.MessageHistoryWriter"/>
<bean class="org.springframework.integration.context.MessageHistoryWriter"/>
<bean class="org.springframework.integration.context.MessageHistoryBeanPostProcessor"/>
<bean class="org.springframework.integration.context.MessageHistoryBeanPostProcessor"/>
</beans>

View File

@@ -27,8 +27,8 @@ import javax.jms.Session;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.integration.Message;
import org.springframework.integration.context.MessageHistoryWriter;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageHistory;
import org.springframework.integration.gateway.AbstractMessagingGateway;
import org.springframework.jms.listener.SessionAwareMessageListener;
import org.springframework.jms.support.converter.MessageConverter;
@@ -223,7 +223,7 @@ public class ChannelPublishingJmsMessageListener extends AbstractMessagingGatewa
Message<?> requestMessage = (object instanceof Message<?>) ?
MessageBuilder.fromMessage((Message<?>) object).copyHeaders(headers).build() :
MessageBuilder.withPayload(object).copyHeaders(headers).build();
requestMessage = MessageHistoryWriter.writeHistory(this, requestMessage);
requestMessage = MessageHistory.addComponentToHistory(requestMessage, this);
if (!this.expectReply) {
this.send(requestMessage);
}

View File

@@ -23,8 +23,8 @@ import javax.jms.Destination;
import org.springframework.integration.Message;
import org.springframework.integration.MessagingException;
import org.springframework.integration.context.MessageHistoryWriter;
import org.springframework.integration.core.MessageBuilder;
import org.springframework.integration.core.MessageHistory;
import org.springframework.integration.core.MessageSource;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.support.converter.MessageConverter;
@@ -88,7 +88,7 @@ public class JmsDestinationPollingSource extends AbstractJmsTemplateBasedAdapter
MessageBuilder<Object> builder = (convertedObject instanceof Message)
? MessageBuilder.fromMessage((Message<Object>) convertedObject) : MessageBuilder.withPayload(convertedObject);
convertedMessage = builder.copyHeadersIfAbsent(mappedHeaders).build();
convertedMessage = MessageHistoryWriter.writeHistory(this, convertedMessage);
convertedMessage = MessageHistory.addComponentToHistory(convertedMessage, this);
}
catch (Exception e) {
throw new MessagingException(e.getMessage(), e);

View File

@@ -20,8 +20,8 @@ import javax.jms.JMSException;
import org.springframework.core.Ordered;
import org.springframework.integration.Message;
import org.springframework.integration.context.MessageHistoryWriter;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.MessageHistory;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.jms.core.MessagePostProcessor;
@@ -63,7 +63,7 @@ public class JmsSendingMessageHandler extends AbstractJmsTemplateBasedAdapter im
if (message == null) {
throw new IllegalArgumentException("message must not be null");
}
final Message<?> messageToSend = MessageHistoryWriter.writeHistory(this, message);
final Message<?> messageToSend = MessageHistory.addComponentToHistory(message, this);
this.getJmsTemplate().convertAndSend(messageToSend, new MessagePostProcessor() {
public javax.jms.Message postProcessMessage(javax.jms.Message jmsMessage)
throws JMSException {

View File

@@ -35,10 +35,10 @@ import org.springframework.integration.Message;
import org.springframework.integration.MessageHeaders;
import org.springframework.integration.MessagingException;
import org.springframework.integration.channel.DirectChannel;
import org.springframework.integration.context.MessageHistoryWriter;
import org.springframework.integration.context.NamedComponent;
import org.springframework.integration.core.MessageChannel;
import org.springframework.integration.core.MessageHandler;
import org.springframework.integration.core.MessageHistory;
import org.springframework.integration.core.PollableChannel;
import org.springframework.integration.core.StringMessage;
import org.springframework.integration.core.SubscribableChannel;
@@ -61,11 +61,11 @@ public class JmsMessageHistoryTests {
Message<?> message = jmsInputChannel.receive(5000);
Iterator<Properties> historyIterator = message.getHeaders().getHistory().iterator();
Properties event = historyIterator.next();
assertEquals("jms:inbound-channel-adapter", event.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("sampleJmsInboundAdapter", event.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("jms:inbound-channel-adapter", event.getProperty(MessageHistory.TYPE_PROPERTY));
assertEquals("sampleJmsInboundAdapter", event.getProperty(MessageHistory.NAME_PROPERTY));
event = historyIterator.next();
assertEquals("channel", event.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("jmsInputChannel", event.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("channel", event.getProperty(MessageHistory.TYPE_PROPERTY));
assertEquals("jmsInputChannel", event.getProperty(MessageHistory.NAME_PROPERTY));
}
@Test @Ignore
@@ -78,17 +78,17 @@ public class JmsMessageHistoryTests {
Message<?> message = jmsInputChannel.receive(50000);
Iterator<Properties> historyIterator = message.getHeaders().getHistory().iterator();
Properties event = historyIterator.next();
assertEquals("channel", event.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("outbound-channel", event.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("channel", event.getProperty(MessageHistory.TYPE_PROPERTY));
assertEquals("outbound-channel", event.getProperty(MessageHistory.NAME_PROPERTY));
event = historyIterator.next();
assertEquals("jms:outbound-channel-adapter", event.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("jmsOutbound", event.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("jms:outbound-channel-adapter", event.getProperty(MessageHistory.TYPE_PROPERTY));
assertEquals("jmsOutbound", event.getProperty(MessageHistory.NAME_PROPERTY));
event = historyIterator.next();
assertEquals("jms:inbound-channel-adapter", event.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("sampleJmsInboundAdapter", event.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("jms:inbound-channel-adapter", event.getProperty(MessageHistory.TYPE_PROPERTY));
assertEquals("sampleJmsInboundAdapter", event.getProperty(MessageHistory.NAME_PROPERTY));
event = historyIterator.next();
assertEquals("channel", event.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("jmsInputChannel", event.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("channel", event.getProperty(MessageHistory.TYPE_PROPERTY));
assertEquals("jmsInputChannel", event.getProperty(MessageHistory.NAME_PROPERTY));
}
@Test @Ignore
@@ -101,20 +101,20 @@ public class JmsMessageHistoryTests {
public void handleMessage(Message<?> message) {
Iterator<Properties> historyIterator = message.getHeaders().getHistory().iterator();
Properties event = historyIterator.next();
assertEquals("gateway", event.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("sampleGateway", event.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("gateway", event.getProperty(MessageHistory.TYPE_PROPERTY));
assertEquals("sampleGateway", event.getProperty(MessageHistory.NAME_PROPERTY));
event = historyIterator.next();
assertEquals("publish-subscribe-channel", event.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("channel-a", event.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("publish-subscribe-channel", event.getProperty(MessageHistory.TYPE_PROPERTY));
assertEquals("channel-a", event.getProperty(MessageHistory.NAME_PROPERTY));
event = historyIterator.next();
assertEquals("jms:outbound-gateway", event.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("jmsOutbound", event.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("jms:outbound-gateway", event.getProperty(MessageHistory.TYPE_PROPERTY));
assertEquals("jmsOutbound", event.getProperty(MessageHistory.NAME_PROPERTY));
event = historyIterator.next();
assertEquals("jms:inbound-gateway", event.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("jmsInbound", event.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("jms:inbound-gateway", event.getProperty(MessageHistory.TYPE_PROPERTY));
assertEquals("jmsInbound", event.getProperty(MessageHistory.NAME_PROPERTY));
event = historyIterator.next();
assertEquals("publish-subscribe-channel", event.getProperty(MessageHistoryWriter.TYPE_PROPERTY));
assertEquals("inbound-jms-channel", event.getProperty(MessageHistoryWriter.NAME_PROPERTY));
assertEquals("publish-subscribe-channel", event.getProperty(MessageHistory.TYPE_PROPERTY));
assertEquals("inbound-jms-channel", event.getProperty(MessageHistory.NAME_PROPERTY));
MessageChannel channel = (MessageChannel) message.getHeaders().getReplyChannel();
channel.send(new StringMessage("OK"));