galovics commented on code in PR #2526: URL: https://github.com/apache/fineract/pull/2526#discussion_r951203424
########## fineract-provider/src/main/java/org/apache/fineract/cob/messagehandler/COBJmsWorkerConfig.java: ########## @@ -0,0 +1,71 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.cob.messagehandler; + +import javax.jms.ConnectionFactory; +import org.apache.fineract.cob.messagehandler.conditions.JmsWorkerCondition; +import org.apache.fineract.infrastructure.core.config.FineractProperties; +import org.springframework.batch.integration.config.annotation.EnableBatchIntegration; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.integration.channel.DirectChannel; +import org.springframework.integration.channel.QueueChannel; +import org.springframework.integration.dsl.IntegrationFlow; +import org.springframework.integration.dsl.IntegrationFlows; +import org.springframework.integration.handler.LoggingHandler; +import org.springframework.integration.jms.dsl.Jms; + +@Configuration +@EnableBatchIntegration +@Conditional(JmsWorkerCondition.class) +public class COBJmsWorkerConfig { + + @Autowired + private ConnectionFactory connectionFactory; + @Autowired + private QueueChannel inboundRequests; + @Autowired + private FineractProperties fineractProperties; + + @Bean + public IntegrationFlow inboundFlow() { + return IntegrationFlows.from(Jms.messageDrivenChannelAdapter(connectionFactory) // + .configureListenerContainer(c -> c.subscriptionDurable(false)) // + .destination(fineractProperties.getRemoteJobMessageHandler().getJms().getRequestQueueName())) // + .channel(inboundRequests) // + .log(LoggingHandler.Level.DEBUG) // + .get(); + } + + @Bean + public DirectChannel outboundStaging() { + return new DirectChannel(); + } + + @Bean + public IntegrationFlow outboundStagingFlow() { Review Comment: I don't think we'll need an outbound flow, do we? ########## fineract-provider/src/main/java/org/apache/fineract/cob/messagehandler/COBJmsManagerConfig.java: ########## @@ -0,0 +1,74 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.cob.messagehandler; + +import javax.jms.ConnectionFactory; +import org.apache.fineract.cob.COBOutputChannelInterceptor; +import org.apache.fineract.cob.messagehandler.conditions.JmsManagerCondition; +import org.apache.fineract.infrastructure.core.config.FineractProperties; +import org.springframework.batch.integration.config.annotation.EnableBatchIntegration; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.integration.channel.DirectChannel; +import org.springframework.integration.dsl.IntegrationFlow; +import org.springframework.integration.dsl.IntegrationFlows; +import org.springframework.integration.handler.LoggingHandler; +import org.springframework.integration.jms.dsl.Jms; + +@Configuration +@EnableBatchIntegration +@Conditional(JmsManagerCondition.class) +public class COBJmsManagerConfig { + + @Autowired + private DirectChannel outboundRequests; + @Autowired + private COBOutputChannelInterceptor outputInterceptor; + @Autowired + private ConnectionFactory connectionFactory; + @Autowired + private FineractProperties fineractProperties; + + @Bean + public IntegrationFlow outboundFlow() { + return IntegrationFlows.from(outboundRequests) // + .intercept(outputInterceptor) // + .log(LoggingHandler.Level.DEBUG) // + .handle(Jms.outboundGateway(connectionFactory) + .requestDestination(fineractProperties.getRemoteJobMessageHandler().getJms().getRequestQueueName())) + .get(); + } + + @Bean + public DirectChannel inboundStaging() { + return new DirectChannel(); + } + + @Bean + public IntegrationFlow inboundStagingFlow() { + return IntegrationFlows.from(Jms.messageDrivenChannelAdapter(connectionFactory) // + .configureListenerContainer(c -> c.subscriptionDurable(false)) // Review Comment: I think we'll need a durable subscription (true instead of the false value) to make sure while a subscriber is down, when it comes back online it'll receive the messages properly. Thoughts? ########## fineract-provider/src/main/java/org/apache/fineract/cob/messagehandler/COBJmsWorkerConfig.java: ########## @@ -0,0 +1,71 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.cob.messagehandler; + +import javax.jms.ConnectionFactory; +import org.apache.fineract.cob.messagehandler.conditions.JmsWorkerCondition; +import org.apache.fineract.infrastructure.core.config.FineractProperties; +import org.springframework.batch.integration.config.annotation.EnableBatchIntegration; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.integration.channel.DirectChannel; +import org.springframework.integration.channel.QueueChannel; +import org.springframework.integration.dsl.IntegrationFlow; +import org.springframework.integration.dsl.IntegrationFlows; +import org.springframework.integration.handler.LoggingHandler; +import org.springframework.integration.jms.dsl.Jms; + +@Configuration +@EnableBatchIntegration +@Conditional(JmsWorkerCondition.class) +public class COBJmsWorkerConfig { + + @Autowired + private ConnectionFactory connectionFactory; + @Autowired + private QueueChannel inboundRequests; + @Autowired + private FineractProperties fineractProperties; + + @Bean + public IntegrationFlow inboundFlow() { + return IntegrationFlows.from(Jms.messageDrivenChannelAdapter(connectionFactory) // + .configureListenerContainer(c -> c.subscriptionDurable(false)) // Review Comment: Durable subscription. ########## fineract-provider/src/main/java/org/apache/fineract/cob/messagehandler/COBJmsManagerConfig.java: ########## @@ -0,0 +1,74 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.fineract.cob.messagehandler; + +import javax.jms.ConnectionFactory; +import org.apache.fineract.cob.COBOutputChannelInterceptor; +import org.apache.fineract.cob.messagehandler.conditions.JmsManagerCondition; +import org.apache.fineract.infrastructure.core.config.FineractProperties; +import org.springframework.batch.integration.config.annotation.EnableBatchIntegration; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Conditional; +import org.springframework.context.annotation.Configuration; +import org.springframework.integration.channel.DirectChannel; +import org.springframework.integration.dsl.IntegrationFlow; +import org.springframework.integration.dsl.IntegrationFlows; +import org.springframework.integration.handler.LoggingHandler; +import org.springframework.integration.jms.dsl.Jms; + +@Configuration +@EnableBatchIntegration +@Conditional(JmsManagerCondition.class) +public class COBJmsManagerConfig { + + @Autowired + private DirectChannel outboundRequests; + @Autowired + private COBOutputChannelInterceptor outputInterceptor; + @Autowired + private ConnectionFactory connectionFactory; + @Autowired + private FineractProperties fineractProperties; + + @Bean + public IntegrationFlow outboundFlow() { + return IntegrationFlows.from(outboundRequests) // + .intercept(outputInterceptor) // + .log(LoggingHandler.Level.DEBUG) // + .handle(Jms.outboundGateway(connectionFactory) + .requestDestination(fineractProperties.getRemoteJobMessageHandler().getJms().getRequestQueueName())) + .get(); + } + + @Bean + public DirectChannel inboundStaging() { + return new DirectChannel(); + } + + @Bean + public IntegrationFlow inboundStagingFlow() { Review Comment: Giving it another thought, do we even need an inbound flow here? I don't think so since the manager will only send messages. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
