Reputation: 831
I have the below xml configuration in my application and I would like to convert it to the Java DSL.
So in this reference I'm explicitly defining the name for the error channel. Mostly for example reason. With this reference what I'm expecting to happen is when a downstream process throws and exception that it should route the payload back through the error channel. What would the Java code look like?
<int-jms:message-driven-channel-adapter
id="notification"
connection-factory="connectionFactory"
destination="otificationQueue"
channel="notificationChannel"
error-channel="error"
/>
<int:chain id="chainError" input-channel="error">
<int:transformer id="transformerError" ref="errorTransformer" />
<int-jms:outbound-channel-adapter
id="error"
connection-factory="connectionFactory"
destination="errorQueue" />
</int:chain>
Upvotes: 3
Views: 1272
Reputation: 174729
@Bean
public IntegrationFlow jmsMessageDrivenFlow() {
return IntegrationFlows
.from(Jms.messageDriverChannelAdapter(this.jmsConnectionFactory)
.id("notification")
.destination(this.notificationQueue)
.errorChannel(this.errorChannel))
...
.get();
}
@Bean
public IntegrationFlow ErrorFlow() {
return IntegrationFlows
.from(this.errorChannel)
.transform(errorTransformer())
.handle(Jms.outboundAdapter(this.jmsConnectionFactory)
.destination(this.errorQueue), e -> e.id("error"))
.get();
}
EDIT:
@Bean
public MessageChannel errorChannel() {
return new DirectChannel();
}
and autowire it, or reference it as
.errorChannel(errorChannel())
Upvotes: 6