通过spring集成将Rabbitmq连接到IBM MQ

时间:2017-11-06 13:24:53

标签: rabbitmq spring-integration

我们正在尝试将RabbitMQ与我们的系统应用程序(实际上是MQSeries)集成。 某些应用程序不会升级代理(MQSeries => RabbitMQ),因此我们必须将消息从RMQ传输到MQSeries

使用配置文件(入站amqp RMQ =>出站jms MQ)消息:150条消息/秒。 在两个mq服务器之间有一个mq通道(MQ => MQ),大约是12500 msg /秒。

两个问题:

  • 您是否有建议优化转移?出站通道上的配置(比如在MQ上打开会话)?
  • 在pom.xml中使用哪个版本以及配置文件中的xsd使用最新版本的组件(例如spring-amqp 2.0.0没有冲突)?

感谢您的帮助

此致

埃里克

配置文件

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:int-amqp="http://www.springframework.org/schema/integration/amqp"
    xmlns:rabbit="http://www.springframework.org/schema/rabbit"
    xmlns:int-jms="http://www.springframework.org/schema/integration/jms"
    xmlns:int="http://www.springframework.org/schema/integration"
    xsi:schemaLocation="http://www.springframework.org/schema/integration/amqp http://www.springframework.org/schema/integration/amqp/spring-integration-amqp-4.3.xsd
        http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration-4.3.xsd
        http://www.springframework.org/schema/integration/jms http://www.springframework.org/schema/integration/jms/spring-integration-jms-4.3.xsd
        http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit-1.7.xsd
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">


<!-- Channel Definition  -->
<int:channel id="myChannel" />

<!-- Source RabbitMQ -->
<rabbit:connection-factory id="connectionFactory" username="guest" password="guest" addresses="adresse_ip:5672"/>
<int-amqp:inbound-channel-adapter channel="myChannel" queue-names="myqueue" connection-factory="connectionFactory"  auto-startup="true" id="inboundChannelAdapter" />

<!-- Destination MQSeries  -->
<bean id="jmsConnectionFactory" class="com.ibm.mq.jms.MQConnectionFactory" >
    <property name="queueManager" value="queue_manager_name" />
    <property name="hostName" value="hostname" />
    <property name="port" value="1414" />
    <property name="channel" value="SYSTEM.DEF.SVRCONN" />
    <property name="transportType" value="1" />
</bean>
<bean id="jmsQueue" class="com.ibm.mq.jms.MQQueue" depends-on="jmsConnectionFactory">
    <property name="baseQueueManagerName" value="queue_manager_name" />
    <property name="baseQueueName" value="queue_name" />
    <property name="targetClient" value="1" />
</bean> 

<int-jms:outbound-channel-adapter id="jmsOut" destination="jmsQueue" connection-factory="jmsConnectionFactory" channel="myChannel"/>

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <properties>
       <jms.version>2.0.1</jms.version>
       <mqseries.version>8.0.0.3</mqseries.version>
       <spring.amqp.version>1.7.4.RELEASE</spring.amqp.version>
       <spring.version>4.3.12.RELEASE</spring.version>
  </properties>

       <dependencies>

             <dependency>
                    <groupId>javax.jms</groupId>
                    <artifactId>jms</artifactId>
                    <version>1.1</version>
             </dependency>
             <dependency>
                    <groupId>javax.jms</groupId>
                    <artifactId>javax.jms-api</artifactId>
                    <version>${jms.version}</version>
             </dependency> 

             <!-- ******* -->
             <!--   mq    -->
             <!-- ******* -->
             <dependency>
                    <groupId>com.ibm</groupId> 
                    <artifactId>com.ibm.mq.allclient</artifactId> 
                    <version>${mqseries.version}</version> 
             </dependency>


             <!-- ******************* -->
             <!-- Spring dependencies -->
             <!-- ******************* -->
             <dependency>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-orm</artifactId>
                    <version>${spring.version}</version>
             </dependency>
             <dependency>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context</artifactId>
                    <version>${spring.version}</version>
             </dependency>
             <dependency>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-aop</artifactId>
                    <version>${spring.version}</version>
             </dependency>
             <dependency>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-tx</artifactId>
                    <version>${spring.version}</version>
             </dependency>
             <dependency>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-beans</artifactId>
                    <version>${spring.version}</version>
             </dependency>

             <!-- but exclude commons-logging as we're using jcl-over-slf4j -->
             <dependency>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-core</artifactId>
                    <version>${spring.version}</version>
                    <exclusions>
                           <exclusion>
                                  <groupId>commons-logging</groupId>
                                  <artifactId>commons-logging</artifactId>
                           </exclusion>
                    </exclusions>
             </dependency>


             <!-- Integration avec MqSeries -->
             <dependency>
                    <groupId>org.springframework.integration</groupId>
                    <artifactId>spring-integration-core</artifactId>
                    <version>${spring.version}</version>
             </dependency>
             <dependency>
                    <groupId>org.springframework.integration</groupId>
                    <artifactId>spring-integration-file</artifactId>
                    <version>${spring.version}</version>
             </dependency>
             <dependency>
                    <groupId>org.springframework.integration</groupId>
                    <artifactId>spring-integration-amqp</artifactId>
                    <version>${spring.version}</version>
             </dependency>
             <dependency>
                    <groupId>org.springframework.integration</groupId>
                    <artifactId>spring-integration-jms</artifactId>
                    <version>${spring.version}</version>
             </dependency>

             <!-- AMQP spring dependencies -->
             <dependency>
                    <groupId>org.springframework.amqp</groupId>
                    <artifactId>spring-amqp</artifactId>
                    <version>${spring.amqp.version}</version>

             </dependency>
             <dependency>
                    <groupId>org.springframework.amqp</groupId>
                    <artifactId>spring-rabbit</artifactId>
                    <version>${spring.amqp.version}</version>
             </dependency>
       </dependencies>  
</project>

1 个答案:

答案 0 :(得分:1)

您应该将MQConnectionFactory包装在CachingConnectionFactory中,以避免为每个发送操作创建新的连接和会话。

Spring AMQP 2.0.0需要Spring Framework 5.0.0或更高版本(当前为5.0.1)。