首页 文章

Apache Camel ActiveMQ . 两个经纪人之间的邮件传输速度太慢

提问于
浏览
2

我正在尝试通过Apache Camel在2个ActiveMQ代理之间传输消息,而麻烦的是我每秒只能传输大约135个消息 . 我想增加这个数字 . 情况是我在远程服务器上有2个ActiveMQ代理 . 我想从第一个代理队列中获取消息,并通过Camel路由将这些消息传输到第二个代理上的多个队列 .

this is how I establish connections:
CamelContext context = new DefaultCamelContext();
            ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory("admin", "admin", "tcp://10.1**.6.195:62222");
            ActiveMQConnectionFactory connectionFactory2 = new ActiveMQConnectionFactory("admin", "admin", "tcp://10.1**.6.195:
            PooledConnectionFactory pf1 = new PooledConnectionFactory(connectionFactory);
            pf1.setMaximumActiveSessionPerConnection(45);
            pf1.setMaxConnections(40);
            PooledConnectionFactory pf2 = new PooledConnectionFactory(connectionFactory2);
            pf2.setMaximumActiveSessionPerConnection(45);
            pf2.setMaxConnections(40);
            context.addComponent("broker1", JmsComponent.jmsComponentAutoAcknowledge(pf1));
            context.addComponent("broker2", JmsComponent.jmsComponentAutoAcknowledge(pf2));

我的路线:

context.addRoutes(new RouteBuilder() {
            @Override
            public void configure() {
                onException(SetParamsException.class)
                    .filter()
                    .method(new IsDisableFlowLoggingFilter(), "filter")
                    .process(new CreateErrorHandlerLogMessageProcessor())
                    .to("broker2:queue:ESB.EVENT.LOGGING");

                from(fromBroker+":queue:"+sourceQueue+"?maxConcurrentConsumers=500&concurrentConsumers=40&asyncConsumer=true")
                    .process(new SetParamsProcessor())
                        .to("seda:EVENT.LOGGING")
                        .to("seda:EVENT.TRANSACTION.LOGGING")
                        .to("seda:EVENT.MONITOR.LOG")
                        .to("xslt:file://transform.xsl")
                            .to("broker2:queue:testMQDestinationOLOLO?maxConcurrentConsumers=500&concurrentConsumers=20&asyncConsumer=true")
                from("seda:EVENT.LOGGING")
                    .filter()
                    .method(new IsDisableFlowLoggingFilter(), "filter")
                    .process(new CreateEventMessageProcessor())
                    .to("broker2:queue:EVENT.LOGGING");

                from("seda:EVENT.TRANSACTION.LOGGING")
                    .process(new CreateTransactionDetailsMessageProcessor())
                    .to("broker2:queue:EVENT.TRANSACTION.LOGGING");

                from("seda:EVENT.MONITOR.LOG")
                    .process(new CreateMonitoringMessageProcessor())
                    .to("broker2:queue:EVENT.MONITOR.LOG");
            }
        });
        context.start();

这种配置每秒给我约135条消息 . 我认为这是因为我的消费者先后而不是并行工作 . 周围有人可以帮助我提高费率吗?

PS:顺便说一下,ping到远程服务器~2ms

1 回答

  • 0

    这是相当多的日志记录,我建议减少它 . 否则,看起来你在消息上使用xslt,考虑到通常的xslt速度,这可能会很慢 . 我还建议发布您的ActiveMQConnectionFactory配置 . 我强烈建议在会话数较多的池上运行这些 . 我目前在 生产环境 中使用camel和activemq,速度非常快 . 这是一个你可以建模的样品工厂:

    <bean id="myAmqBean" class="org.apache.activemq.camel.component.ActiveMQComponent" destroy-method="doStop">
        <property name="configuration">
            <bean class="org.apache.camel.component.jms.JmsConfiguration">
                <property name="concurrentConsumers" value="20" />
                <property name="maxConcurrentConsumers" value="20" />
                <property name="acceptMessagesWhileStopping" value="true" />
                <property name="connectionFactory">
                    <bean class="org.apache.activemq.pool.PooledConnectionFactory" init-method="start" destroy-method="stop">
                        <property name="maxConnections" value="10" />
                        <property name="MaximumActiveSessionPerConnection" value="500" />
                        <property name="connectionFactory">
                            <bean class="org.apache.activemq.ActiveMQConnectionFactory">
                                <property name="brokerURL" value="${activemq1.brokerUrl}" />
                                <property name="userName" value="${activemq1.username}" />
                                <property name="password" value="${activemq1.password}" />
                                <property name="dispatchAsync" value="true" />
                                <property name="alwaysSessionAsync" value="true" />
                                <property name="useAsyncSend" value="true" />
                            </bean>
                        </property>
                    </bean>
                </property>
            </bean>
        </property>
    

相关问题