如何使用spring集成写入MongoDB
我正在阅读RabbitMQ,并使用SpringIntegrationsXML编写MongoDB。 我能够读取Rabbit MQ,但无法写入MongoDB。请帮我解决这个问题,因为我还不熟悉spring与MongoDB的集成 我的集成图如下所示:如何使用spring集成写入MongoDB,spring,spring-integration,Spring,Spring Integration,我正在阅读RabbitMQ,并使用SpringIntegrationsXML编写MongoDB。 我能够读取Rabbit MQ,但无法写入MongoDB。请帮我解决这个问题,因为我还不熟悉spring与MongoDB的集成 我的集成图如下所示: <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://ww
<?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:int="http://www.springframework.org/schema/integration"
xmlns:int-amqp="http://www.springframework.org/schema/integration/amqp"
xmlns:rabbit="http://www.springframework.org/schema/rabbit"
xmlns:int-stream="http://www.springframework.org/schema/integration/stream"
xmlns:int-mongodb="http://www.springframework.org/schema/integration/mongodb"
xmlns:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/integration/amqp
http://www.springframework.org/schema/integration/amqp/spring-integration-amqp.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration.xsd
http://www.springframework.org/schema/integration/stream
http://www.springframework.org/schema/integration/stream/spring-integration-stream.xsd
http://www.springframework.org/schema/rabbit
http://www.springframework.org/schema/rabbit/spring-rabbit.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<bean id="connectionFactory"
class="org.springframework.amqp.rabbit.connection.CachingConnectionFactory">
<constructor-arg value="localhost"/>
<property name="username" value="guest"/>
<property name="password" value="guest"/>
</bean>
<int-amqp:inbound-channel-adapter channel="fromRabbit"
queue-names="promo-queue" connection-factory="connectionFactory" />
<int:object-to-string-transformer input-channel="fromRabbit"
output-channel="mychanneloutput" charset="UTF-8">
</int:object-to-string-transformer>
<int:channel id = "mychanneloutput"/>
<int:channel id="fromRabbit">
<int:interceptors>
<int:wire-tap channel="loggingChannel" />
</int:interceptors>
</int:channel>
<int:logging-channel-adapter id="loggingChannel" log-full-message="true" level="INFO" />
<rabbit:template id="amqpTemplate" connection-factory="connectionFactory" mandatory="true" /> <!-- for nacks -->
<rabbit:admin connection-factory="connectionFactory" />
<rabbit:queue name="promo-queue" />
<rabbit:direct-exchange name="prmo-exchange">
<rabbit:bindings>
<rabbit:binding queue="promo-queue" key="promo-queue" />
</rabbit:bindings>
</rabbit:direct-exchange>
<mongo:db-factory id="mongoDbFactory" dbname="test" />
<int-mongodb:outbound-channel-adapter id="mongoAdapter" />
我的问题如下:
1.如何使用主机、端口和其他连接详细信息初始化mongoDBFactory。
2.如何使用XML使用出站通道适配器将数据写入MongoDB。您可以在此repo中找到MongoDB示例: 连接工厂的主机、端口和其他选项是所提到的
组件的属性。请参阅文档中的更多信息: