使用 Java DSL 设置发布-子域
setting pub-sub-domain using Java DSL
我正在尝试将以下内容转换为 spring-集成 java dsl。
<int:channel id="partsSubscriberChannel" />
<int-jms:message-driven-channel-adapter
id="jmsPartsInbound"
acknowledge="transacted"
destination-name="parts.topic"
channel="partsSubscriberChannel"
pub-sub-domain="true"
connection-factory="jmsConnectionFactory"/>
这就是我要做的事情:
@Bean
public MessageChannel partsErrorChannel() {
return new DirectChannel();
}
@Bean
public MessageChannel partsSubscriberChannel() {
return new DirectChannel();
}
@Bean
public IntegrationFlow partsSubscription(ConnectionFactory connectionFactory) {
return IntegrationFlows
.from(Jms.messageDriverChannelAdapter(connectionFactory)
.id("partsJmsSubscriber")
.destination(Topic.PARTS.getName())
.outputChannel(partsSubscriberChannel())
.errorChannel(partsErrorChannel()))
.get();
}
如何设置 pub-sub-domain
和 acknowledge
xml 属性?
目前无法直接使用 DSL,但您可以使用 属性 设置连接到侦听器容器...
@Bean
public IntegrationFlow jmsMessageDriverFlowWithContainer() {
return IntegrationFlows
.from(Jms.messageDriverChannelAdapter(container())
.id("foo"))
.errorChannel(errorChannel()))
.channel(outputChannel()
.get();
}
@Bean
public AbstractMessageListenerContainer container() {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setSessionTransacted(true);
container.setDestinationName(Topic.PARTS.getName());
container.setPubSubDomain(true);
return container;
}
我正在尝试将以下内容转换为 spring-集成 java dsl。
<int:channel id="partsSubscriberChannel" />
<int-jms:message-driven-channel-adapter
id="jmsPartsInbound"
acknowledge="transacted"
destination-name="parts.topic"
channel="partsSubscriberChannel"
pub-sub-domain="true"
connection-factory="jmsConnectionFactory"/>
这就是我要做的事情:
@Bean
public MessageChannel partsErrorChannel() {
return new DirectChannel();
}
@Bean
public MessageChannel partsSubscriberChannel() {
return new DirectChannel();
}
@Bean
public IntegrationFlow partsSubscription(ConnectionFactory connectionFactory) {
return IntegrationFlows
.from(Jms.messageDriverChannelAdapter(connectionFactory)
.id("partsJmsSubscriber")
.destination(Topic.PARTS.getName())
.outputChannel(partsSubscriberChannel())
.errorChannel(partsErrorChannel()))
.get();
}
如何设置 pub-sub-domain
和 acknowledge
xml 属性?
目前无法直接使用 DSL,但您可以使用 属性 设置连接到侦听器容器...
@Bean
public IntegrationFlow jmsMessageDriverFlowWithContainer() {
return IntegrationFlows
.from(Jms.messageDriverChannelAdapter(container())
.id("foo"))
.errorChannel(errorChannel()))
.channel(outputChannel()
.get();
}
@Bean
public AbstractMessageListenerContainer container() {
DefaultMessageListenerContainer container = new DefaultMessageListenerContainer();
container.setSessionTransacted(true);
container.setDestinationName(Topic.PARTS.getName());
container.setPubSubDomain(true);
return container;
}