Reputation: 109
I am trying to create a integration flow for JMS OutboundAdapter through which I need to send message to the ActiveMQTopic. But I really stuck when I am trying to convert the the xml tag to dsl specific code, not able to convert some xml tag to required DSL. Can any ony one please provide any pointer to it as I am not able to proceed.
This is my Connection factory and Active MQTopic bean
@Bean
public ActiveMQConnectionFactory ConnectionFactory() {
ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory();
factory.setBrokerURL(brokerUrl);
return factory;
}
@Bean
public ActiveMQTopic mqTopic() {
return new ActiveMQTopic(jmstopic);
}
This is my QueueChannel and integration flow that I have made...........
@Bean
public QueueChannel jmsOutChannel(){
return new QueueChannel();
}
@Bean
public IntegrationFlow jmsOutboundFlow() {
return IntegrationFlows.from(jmsOutChannel())
.handle(Jms.outboundAdapter(ConnectionFactory())
.destination(mqTopic()))
.get();
}
But I need to convert these below xml into required DSL. Not able to add a poller in my flow.
<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>
Upvotes: 2
Views: 2534
Reputation: 121590
I've edited a bit your question, especially in the last code snippet to figure out what you really need to convert.
First of all pay attention, please, that you don't specify capacity="10"
for the jmsOutChannel()
@Bean
. It is very easy - ctor argument. So, please, try to follow with your code yourself: we can't do all the work for you.
Now regarding the <poller>
and DSL. As you see in the XML configuration variant the <poller>
is as a part of <int-jms:outbound-channel-adapter>
configuration, the Java DSL doesn't invent anything new on the matter and PollerMetadata
is tied with the Endpoint
configuration there, too:
@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();
}
Something like that.
Upvotes: 2