5.8.13

Performance of Spring Integration

Very simple test: one Gateway, two service activators.

<int:channel id="channel-in"/>
<int:gateway id="helloGateway" service-interface="simple.demo.springintegration.demo.chapter5.SimpleGateway"/>
<int:service-activator input-channel="channel-in" output-channel="channel2" expression="'result = ' + payload"/>
<int:service-activator input-channel="channel2" expression="'r2 :=' + payload"/>

Time to process 1 million messages: 8,919 milliseconds, in my i7 PC within Eclipse. Basically, it could handle 100K message in 1 second.

But if I directly use channel-in to send the message and channel2 to receive the message, the process time will be cut down to 3,821 milliseconds.

It seems that Gateway is kind of heavy.

@Test
public void test2() throws Exception {
final CountDownLatch latch = new CountDownLatch(1000 * 1000);

channel2.subscribe(new MessageHandler() {

@Override
public void handleMessage(Message<?> message) throws MessagingException {
latch.countDown();
}
});

Message<String> msg = MessageBuilder.withPayload("hello world").build();
long begin = System.currentTimeMillis();
for(int k=0; k<1000 * 1000; ++k) {
inputChannel.send(msg);
}
latch.await();
long end = System.currentTimeMillis();

System.out.println("end - begin " + (end - begin));

}

---------------------
Update on 8/5/2013

I replace the UUID generator:


With Default UUID Generator
With Customed UUID Generator
Using Gateway
8,919
6,519
Using Direct Channel
3,821
2,545

No comments: