I am trying to find the fastest way to transfer messages from one ActiveMQ
queue to another Artemis. And I thought that the SJMS2 component would be
faster than traditional JMS, but routing with JMS is 2.5 times faster (20
000 vs 8000 msg/s). I use Camel version 2.20.2 and Artemis version 2.11.0.

Route with JMS

import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.camel.builder.RouteBuilder;
import org.apache.camel.impl.JndiRegistry;
import org.apache.camel.test.junit4.CamelTestSupport;
import org.junit.Test;
import org.messaginghub.pooled.jms.JmsPoolConnectionFactory;

import javax.jms.ConnectionFactory;
import java.util.concurrent.TimeUnit;

public class JMSTransferTest extends CamelTestSupport {
    @Test
    public void testArtemis() throws Exception {
        TimeUnit.SECONDS.sleep(100);
    }

    @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() {

from("jms://TEST.IN?connectionFactory=#artemisCF&concurrentConsumers=200")
                        .to("jms://TEST.OUT?connectionFactory=#artemisCF");
            }
        };
    }

    @Override
    protected JndiRegistry createRegistry() throws Exception {
        JndiRegistry registry = super.createRegistry();

        final ConnectionFactory connFactory = new
ActiveMQConnectionFactory("tcp://localhost:61622");
        final ConnectionFactory connFactoryDeadLeatter = new
ActiveMQConnectionFactory("tcp://localhost:61622");
        JmsPoolConnectionFactory pooledConnectionFactory = new
JmsPoolConnectionFactory();

        pooledConnectionFactory.setConnectionFactory(connFactory);
        pooledConnectionFactory.setMaxConnections(20);
        pooledConnectionFactory.setMaxSessionsPerConnection(100);
        registry.bind("artemisCF", pooledConnectionFactory);
        registry.bind("deadLetterCF", connFactoryDeadLeatter);
        return registry;
    }
}

Route with SJMS2, other settings as in the code above

 @Override
    protected RouteBuilder createRouteBuilder() throws Exception {
        return new RouteBuilder() {
            public void configure() {

from("sjms2://SJMS.CONSUMER.TEST?connectionFactory=#artemisCF&consumerCount=200&asyncStartListener=true")

.to("sjms2://OUT.SJMS.CONSUMER.TEST?connectionFactory=#artemisCF");
            }
        };
    }

How can I use the SJMS2 component to get the same speeds as JMS component?

Reply via email to