简体   繁体   English

Apache CXF-JMS 3.0和Spring配置

[英]Apache CXF-JMS 3.0 and Spring configuration

I am trying to configure JMS connection caching and consumer concurrency with Spring to perform some load tests. 我正在尝试使用Spring配置JMS连接缓存和使用者并发来执行一些负载测试。 The application context xml is below. 应用程序上下文xml如下。

<?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:context="http://www.springframework.org/schema/context"
    xmlns:cxf="http://cxf.apache.org/core" 
    xmlns:jaxws="http://cxf.apache.org/jaxws"
    xmlns:p="http://www.springframework.org/schema/p"
    xmlns:soap="http://cxf.apache.org/bindings/soap"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
    http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

    <context:annotation-config />

    <bean id="amqConnectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
        <property name="brokerURL" value="tcp://172.18.2.100:8080"/>
    </bean>

    <bean id="clientCachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
        <property name="targetConnectionFactory" ref="amqConnectionFactory"/>
        <property name="sessionCacheSize" value="20"/>
        <property name="cacheProducers" value="true"/>
    </bean>

    <bean id="clientContainerListener" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="connectionFactory" ref="clientCachingConnectionFactory" />
        <property name="destinationName" value="test.load.outside.multispeak.ch.queue" />
    </bean>   

    <jaxws:client 
        id="load-test-multispeak-ch-client"
        xmlns:ns="http://www.multispeak.org/Version_4.1_Release"
        serviceClass="org.multispeak.version_4_1_6.CH.CHServerSoap"
        serviceName="ns:CH_Server"
        endpointName="ns:CH_ServerSoap"
        address="jms://"
        wsdlLocation="classpath:CH_Server.wsdl">
        <jaxws:features>
            <bean class="org.apache.cxf.transport.jms.ConnectionFactoryFeature">
                <constructor-arg index="0" ref="clientCachingConnectionFactory"/>
            </bean>
        </jaxws:features>
    </jaxws:client>

    <bean id="serverCachingConnectionFactory" class="org.springframework.jms.connection.CachingConnectionFactory">
        <property name="targetConnectionFactory" ref="amqConnectionFactory"/>
        <property name="sessionCacheSize" value="20"/>
        <property name="cacheConsumers" value="true"/>
    </bean>

    <bean id="serverContainerListener" class="org.springframework.jms.listener.DefaultMessageListenerContainer">
        <property name="connectionFactory" ref="serverCachingConnectionFactory" />
        <property name="destinationName" value="test.load.outside.multispeak.ch.queue" />
        <property name="cacheLevel" value="3" />
        <property name="concurrentConsumers" value="10" />
        <property name="maxConcurrentConsumers" value="50" />
    </bean>   

    <jaxws:endpoint 
        id="load-test-multispeak-ch-server"
        xmlns:tns="http://www.multispeak.org/Version_4.1_Release"
        implementor="pt.fraunhofer.outside.multispeak.ch.server.CHServerSoapImpl"
        serviceName="tns:CH_Server" 
        endpointName="tns:CH_ServerSoap" 
        publish="false"
        address="jms://"
        wsdlLocation="classpath:CH_Server.wsdl">
        <jaxws:features>
            <bean class="org.apache.cxf.feature.LoggingFeature"/>
            <bean class="org.apache.cxf.transport.jms.ConnectionFactoryFeature">
                <constructor-arg index="0" ref="serverCachingConnectionFactory"/>
            </bean>
        </jaxws:features>
    </jaxws:endpoint>

According to CXF documentation, from 3.0, a ConnectionFactoryFeature should be used instead of a JMSConfigFeature , which is deprecated ( http://cxf.apache.org/docs/jms-transport.html ). 根据CXF文档,从3.0开始,应该使用ConnectionFactoryFeature而不是JMSConfigFeature (已弃用)( http://cxf.apache.org/docs/jms-transport.html )。 I was following the examples provided at http://cxf.apache.org/scalable-cxf-applications-using-jms-transport.html , but the documentation there seems to refer to CXF versions earlier than 3.0, because JMSConfiguration class in 3.0 does not have caching or concurrency capabilites (no setters/getters). 我正在遵循http://cxf.apache.org/scalable-cxf-applications-using-jms-transport.html上提供的示例,但是那里的文档似乎是指3.0之前的CXF版本,因为3.0中的JMSConfiguration类没有缓存或并发功能(无设置器/获取器)。 So, I was trying to use Spring to achieve the same result, but without success. 因此,我试图使用Spring获得相同的结果,但是没有成功。 The very same documentation refers to Spring DefaultMessageListenerContainer as a container for caching and concurrency configuration, but I was not able to find examples of this with CXF integration, only for pure JMS. 完全相同的文档将Spring DefaultMessageListenerContainer称为用于缓存和并发配置的容器,但是我无法通过CXF集成找到此示例,仅用于纯JMS。 Also, DefaultMessageListenerContainer has a setter to register a JMS MessageListener . 另外, DefaultMessageListenerContainer具有一个setter来注册JMS MessageListener In case of CXF, I found that that listener is created and managed by CXF runtime and is not provided provided by the application. 对于CXF,我发现该侦听器是由CXF运行时创建和管理的,而不是由应用程序提供的。

Any advice? 有什么建议吗?

Thanks! 谢谢!

Currently you can not set concurrent consumers for CXF 3. I did some performance tests with ActiveMQ and found the performance with CXF 3 is equal to CXF 2 or even better. 当前,您不能为CXF 3设置并发使用者。我对ActiveMQ进行了一些性能测试,发现CXF 3的性能等于CXF 2甚至更好。

The reason is that we now use a MessageListener approach instead of the polling that spring did. 原因是我们现在使用MessageListener方法,而不是春天进行的轮询。

See my website for the performance tests . 请访问我的网站进行性能测试

We need to be able to tune concurrent and maximum consumers so we can handle our message load. 我们需要能够调整并发和最大使用者,以便我们能够处理消息负载。 The constraint is in speed of message processing by our applications; 约束在于我们的应用程序处理消息的速度; CXF is not the bottleneck. CXF不是瓶颈。 Are there plans to re-introduce these parameters in CXF? 是否有计划在CXF中重新引入这些参数? Can we configure CXF to use a configured DefaultMessageListenerContainer? 我们可以配置CXF以使用配置的DefaultMessageListenerContainer吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM