INT-1257 added MessageHistory performance test
This commit is contained in:
@@ -20,6 +20,7 @@ import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mockito;
|
||||
import org.springframework.beans.DirectFieldAccessor;
|
||||
@@ -28,9 +29,15 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.support.ClassPathXmlApplicationContext;
|
||||
import org.springframework.integration.Message;
|
||||
import org.springframework.integration.MessageChannel;
|
||||
import org.springframework.integration.MessageDeliveryException;
|
||||
import org.springframework.integration.MessageHandlingException;
|
||||
import org.springframework.integration.MessageRejectedException;
|
||||
import org.springframework.integration.channel.DirectChannel;
|
||||
import org.springframework.integration.config.ConsumerEndpointFactoryBean;
|
||||
import org.springframework.integration.core.MessageHandler;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertFalse;
|
||||
@@ -193,6 +200,49 @@ public class MessageHistoryIntegrationTests {
|
||||
public void testMessageHistoryMoreThanOneNamespaceFail() {
|
||||
new ClassPathXmlApplicationContext("messageHistoryWithHistoryWriterNamespace-fail.xml", MessageHistoryIntegrationTests.class);
|
||||
}
|
||||
|
||||
@Test @Ignore
|
||||
public void testMessageHistoryWithHistoryPerformance() {
|
||||
ApplicationContext acWithHistory = new ClassPathXmlApplicationContext("perfWithMessageHistory.xml", MessageHistoryIntegrationTests.class);
|
||||
ApplicationContext acWithoutHistory = new ClassPathXmlApplicationContext("perfWithoutMessageHistory.xml", MessageHistoryIntegrationTests.class);
|
||||
|
||||
SampleGateway gatewayHistory = acWithHistory.getBean("sampleGateway", SampleGateway.class);
|
||||
DirectChannel endOfThePipeChannelHistory = acWithHistory.getBean("endOfThePipeChannel", DirectChannel.class);
|
||||
endOfThePipeChannelHistory.subscribe(new MessageHandler() {
|
||||
public void handleMessage(Message<?> message)
|
||||
throws MessageRejectedException, MessageHandlingException,
|
||||
MessageDeliveryException {
|
||||
MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
|
||||
replyChannel.send(message);
|
||||
}
|
||||
});
|
||||
|
||||
SampleGateway gateway = acWithoutHistory.getBean("sampleGateway", SampleGateway.class);
|
||||
DirectChannel endOfThePipeChannel = acWithoutHistory.getBean("endOfThePipeChannel", DirectChannel.class);
|
||||
endOfThePipeChannel.subscribe(new MessageHandler() {
|
||||
public void handleMessage(Message<?> message)
|
||||
throws MessageRejectedException, MessageHandlingException,
|
||||
MessageDeliveryException {
|
||||
MessageChannel replyChannel = (MessageChannel) message.getHeaders().getReplyChannel();
|
||||
replyChannel.send(message);
|
||||
}
|
||||
});
|
||||
|
||||
StopWatch stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
gatewayHistory.echo("hello");
|
||||
}
|
||||
stopWatch.stop();
|
||||
System.out.println("Elapsed time with history 10000 calls: " + stopWatch.getTotalTimeSeconds());
|
||||
stopWatch = new StopWatch();
|
||||
stopWatch.start();
|
||||
for (int i = 0; i < 10000; i++) {
|
||||
gateway.echo("hello");
|
||||
}
|
||||
stopWatch.stop();
|
||||
System.out.println("Elapsed time without history 10000 calls: " + stopWatch.getTotalTimeSeconds());
|
||||
}
|
||||
|
||||
public static interface SampleGateway {
|
||||
public Message<?> echo(String value);
|
||||
|
||||
@@ -9,15 +9,10 @@
|
||||
service-interface="org.springframework.integration.history.MessageHistoryIntegrationTests.SampleGateway"
|
||||
default-request-channel="bridgeInChannel"/>
|
||||
|
||||
<int:channel id="bridgeInChannel">
|
||||
<int:queue/>
|
||||
</int:channel>
|
||||
|
||||
<int:bridge id="testBridge" input-channel="bridgeInChannel" output-channel="headerEnricherChannel">
|
||||
<int:poller max-messages-per-poll="1">
|
||||
<int:interval-trigger interval="100"/>
|
||||
</int:poller>
|
||||
</int:bridge>
|
||||
<int:channel id="bridgeInChannel"/>
|
||||
|
||||
<int:bridge id="testBridge" input-channel="bridgeInChannel" output-channel="headerEnricherChannel"/>
|
||||
|
||||
|
||||
<int:header-enricher id="testHeaderEnricher" input-channel="headerEnricherChannel" output-channel="chainChannel">
|
||||
<int:header name="foo" value="foo"/>
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
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">
|
||||
|
||||
<int:gateway id="sampleGateway"
|
||||
service-interface="org.springframework.integration.history.MessageHistoryIntegrationTests.SampleGateway"
|
||||
default-request-channel="bridgeInChannel"/>
|
||||
|
||||
<int:channel id="bridgeInChannel"/>
|
||||
|
||||
<int:bridge id="testBridge" input-channel="bridgeInChannel" output-channel="headerEnricherChannel"/>
|
||||
|
||||
|
||||
<int:header-enricher id="testHeaderEnricher" input-channel="headerEnricherChannel" output-channel="chainChannel">
|
||||
<int:header name="foo" value="foo"/>
|
||||
</int:header-enricher>
|
||||
|
||||
<int:chain id="sampleChain" input-channel="chainChannel" output-channel="filterChannel">
|
||||
<int:header-enricher>
|
||||
<int:header name="baz" value="baz"/>
|
||||
</int:header-enricher>
|
||||
</int:chain>
|
||||
|
||||
<int:filter id="testFilter" input-channel="filterChannel"
|
||||
output-channel="splitterChannel" expression="payload.equals('hello')"/>
|
||||
|
||||
<int:splitter id="testSplitter" input-channel="splitterChannel" output-channel="aggregatorChannel"/>
|
||||
|
||||
<int:aggregator id="testAggregator" input-channel="aggregatorChannel" output-channel="endOfThePipeChannel"/>
|
||||
|
||||
<int:channel id="endOfThePipeChannel"/>
|
||||
|
||||
<int:message-history/>
|
||||
|
||||
</beans>
|
||||
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:int="http://www.springframework.org/schema/integration"
|
||||
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">
|
||||
|
||||
<int:gateway id="sampleGateway"
|
||||
service-interface="org.springframework.integration.history.MessageHistoryIntegrationTests.SampleGateway"
|
||||
default-request-channel="bridgeInChannel"/>
|
||||
|
||||
<int:channel id="bridgeInChannel"/>
|
||||
|
||||
<int:bridge id="testBridge" input-channel="bridgeInChannel" output-channel="headerEnricherChannel"/>
|
||||
|
||||
|
||||
<int:header-enricher id="testHeaderEnricher" input-channel="headerEnricherChannel" output-channel="chainChannel">
|
||||
<int:header name="foo" value="foo"/>
|
||||
</int:header-enricher>
|
||||
|
||||
<int:chain id="sampleChain" input-channel="chainChannel" output-channel="filterChannel">
|
||||
<int:header-enricher>
|
||||
<int:header name="baz" value="baz"/>
|
||||
</int:header-enricher>
|
||||
</int:chain>
|
||||
|
||||
<int:filter id="testFilter" input-channel="filterChannel"
|
||||
output-channel="splitterChannel" expression="payload.equals('hello')"/>
|
||||
|
||||
<int:splitter id="testSplitter" input-channel="splitterChannel" output-channel="aggregatorChannel"/>
|
||||
|
||||
<int:aggregator id="testAggregator" input-channel="aggregatorChannel" output-channel="endOfThePipeChannel"/>
|
||||
|
||||
<int:channel id="endOfThePipeChannel"/>
|
||||
|
||||
</beans>
|
||||
Reference in New Issue
Block a user