Spring 集成 DSL 在 java 1.7 中创建 JMS 出站适配器
Spring integration DSL creating JMS Outbound Adapter in java 1.7
我正在尝试为 JMS OutboundAdapter 创建一个集成流,我需要通过它向 ActiveMQTopic 发送消息。但我真的
当我尝试将 xml 标记转换为 dsl 特定代码时卡住了,无法将某些 xml 标记转换为所需的 DSL。任何人都可以提供
任何指向它的指针,因为我无法继续。
这是我的连接工厂和活动 MQTopic bean
@Bean
public ActiveMQConnectionFactory ConnectionFactory() {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
factory.setBrokerURL(brokerUrl);
return factory;
}
@Bean
public ActiveMQTopic mqTopic() {
return new ActiveMQTopic(jmstopic);
}
这是我制作的QueueChannel和集成流程......
@Bean
public QueueChannel jmsOutChannel(){
return new QueueChannel();
}
@Bean
public IntegrationFlow jmsOutboundFlow() {
return IntegrationFlows.from(jmsOutChannel())
.handle(Jms.outboundAdapter(ConnectionFactory())
.destination(mqTopic()))
.get();
}
但我需要将下面的这些 xml 转换为所需的 DSL。无法在我的流程中添加轮询器。
<int-jms:outbound-channel-adapter id="jmsOutbound" channel="jmsOutChannel" destination="jmsQueue"
connection-factory="connectionFactory" pub-sub-domain="true">
<int:poller fixed-delay="10000" receive-timeout="0"/>
</int-jms:outbound-channel-adapter>
<int:channel id="jmsOutChannel" >
<int:queue capacity="10"/>
</int:channel>
我对你的问题做了一些编辑,特别是在最后一个代码片段中,以确定你真正需要转换的内容。
首先请注意,您没有为 jmsOutChannel()
@Bean
指定 capacity="10"
。这很容易 - ctor 论证。因此,请尝试自己按照您的代码进行操作:我们无法为您完成所有工作。
现在关于 <poller>
和 DSL。正如您在 XML 配置变体中看到的那样,<poller>
是 <int-jms:outbound-channel-adapter>
配置的一部分,Java DSL 没有发明任何新的东西, PollerMetadata
也与那里的 Endpoint
配置相关:
@Bean
public IntegrationFlow jmsOutboundFlow() {
return IntegrationFlows.from(jmsOutChannel())
.handle(Jms.outboundAdapter(ConnectionFactory())
.destination(mqTopic()),
new Consumer<GenericEndpointSpec<JmsSendingMessageHandler>>() {
void accept(GenericEndpointSpec<JmsSendingMessageHandler> spec) {
spec.poller(Pollers.fixedDelay(10000)
.receiveTimeout(0));
}
})
.get();
}
类似的东西。
我正在尝试为 JMS OutboundAdapter 创建一个集成流,我需要通过它向 ActiveMQTopic 发送消息。但我真的 当我尝试将 xml 标记转换为 dsl 特定代码时卡住了,无法将某些 xml 标记转换为所需的 DSL。任何人都可以提供 任何指向它的指针,因为我无法继续。
这是我的连接工厂和活动 MQTopic bean
@Bean
public ActiveMQConnectionFactory ConnectionFactory() {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
factory.setBrokerURL(brokerUrl);
return factory;
}
@Bean
public ActiveMQTopic mqTopic() {
return new ActiveMQTopic(jmstopic);
}
这是我制作的QueueChannel和集成流程......
@Bean
public QueueChannel jmsOutChannel(){
return new QueueChannel();
}
@Bean
public IntegrationFlow jmsOutboundFlow() {
return IntegrationFlows.from(jmsOutChannel())
.handle(Jms.outboundAdapter(ConnectionFactory())
.destination(mqTopic()))
.get();
}
但我需要将下面的这些 xml 转换为所需的 DSL。无法在我的流程中添加轮询器。
<int-jms:outbound-channel-adapter id="jmsOutbound" channel="jmsOutChannel" destination="jmsQueue"
connection-factory="connectionFactory" pub-sub-domain="true">
<int:poller fixed-delay="10000" receive-timeout="0"/>
</int-jms:outbound-channel-adapter>
<int:channel id="jmsOutChannel" >
<int:queue capacity="10"/>
</int:channel>
我对你的问题做了一些编辑,特别是在最后一个代码片段中,以确定你真正需要转换的内容。
首先请注意,您没有为 jmsOutChannel()
@Bean
指定 capacity="10"
。这很容易 - ctor 论证。因此,请尝试自己按照您的代码进行操作:我们无法为您完成所有工作。
现在关于 <poller>
和 DSL。正如您在 XML 配置变体中看到的那样,<poller>
是 <int-jms:outbound-channel-adapter>
配置的一部分,Java DSL 没有发明任何新的东西, PollerMetadata
也与那里的 Endpoint
配置相关:
@Bean
public IntegrationFlow jmsOutboundFlow() {
return IntegrationFlows.from(jmsOutChannel())
.handle(Jms.outboundAdapter(ConnectionFactory())
.destination(mqTopic()),
new Consumer<GenericEndpointSpec<JmsSendingMessageHandler>>() {
void accept(GenericEndpointSpec<JmsSendingMessageHandler> spec) {
spec.poller(Pollers.fixedDelay(10000)
.receiveTimeout(0));
}
})
.get();
}
类似的东西。