我正在为我们的某个应用程序开发消息传递接口.该应用程序是一种服务,旨在接受"作业",进行一些处理,并返回结果(实际上以文件的形式).
我们的想法是使用RabbitMQ作为消息传递基础架构,使用Spring AMQP来处理协议特定的细节.
我不希望从我的代码到Spring AMQP紧密耦合,所以我想使用Spring Integration来隐藏消息api.基本上我想要这个:
消息发送到RabbitMQ ====> Spring AMQP ====> Spring Integration ====> MyService ====>回复一直回到RabbitMQ
我正在尝试计算将这些连接在一起所需的XML配置,但我遇到了多层抽象和不同术语的问题.找到一个在Spring AMQP/RabbitMQ之上演示Spring Integration的工作示例已经证明是非常困难的,尽管这种设置对我来说是非常"最佳实践".
1)那么......有些聪明的灵魂可以快速看一下这个并且可能会让我朝着正确的方向前进吗?我需要什么,不需要什么?:-)
2)理想情况下,队列应该是多线程的,这意味着taskExecutor应该将多条消息传递给我的jobService以进行并行处理.需要什么配置?
<?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:util="http://www.springframework.org/schema/util"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xmlns:int="http://www.springframework.org/schema/integration"
xmlns:int-amqp="http://www.springframework.org/schema/integration/amqp"
xmlns:int-stream="http://www.springframework.org/schema/integration/stream"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/rabbit http://www.springframework.org/schema/rabbit/spring-rabbit.xsd
http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/amqp http://www.springframework.org/schema/integration/amqp/spring-integration-amqp.xsd
http://www.springframework.org/schema/integration/stream http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
">
<context:component-scan base-package="com.myprogram.etc" />
<!-- Messaging infrastructure: RabbitMQ -->
<bean id="connectionFactory" class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
<constructor-arg value="${ei.messaging.amqp.servername}" />
<property name="username" value="${ei.messaging.amqp.username}" />
<property name="password" value="${ei.messaging.amqp.password}" />
</bean>
<rabbit:connection-factory id="connectionFactory" />
<rabbit:admin connection-factory="connectionFactory"/>
<!-- From RabbitMQ …Run Code Online (Sandbox Code Playgroud)