1

I would like to migrate a multi-threaded application in JSE to Spring Integration but I have to clarify some points before. First of all, the application will have the following Spring integration components:

  • JMS to Transformer to router to TCPOut
  • TcpIn (to router) to Transformer to JMS

In this context, I have to load all the TCP connections dynamically from a configuration file. I saw a couple of example of this here in StackOverflow (based in the FTP sample). These samples could be enough for the first part but I am looking for how to do that in Spring Boot and what is the best (and elegant) way to create this type of configuration.

Finally, I have to access to each different context (this is maybe the most important) from a type of Swing monitor to start/stop manually this TCP connections. Is this possible? What do you suggest me to do?

All my current components are java based configuration (not DSL).

crm86
  • 1,394
  • 1
  • 21
  • 44

1 Answers1

1

See my answers to this question and its follow-up for examples of how to dynamically create application contexts using Java Configuration.

Also, take a look at the new feature in the Java DSL for dynamically registering/removing integration flows with the context. The 1.2 version of the DSL, containing this feature, will be released shortly.

You can stop/start endpoints using JMX or a control bus, or programmatically.

Community
  • 1
  • 1
Gary Russell
  • 166,535
  • 14
  • 146
  • 179
  • Is Java DSL mandatory for dynamically registering elements or just an improvement?. I am not really familiarized with it and I prefer to keep the java configuration. I like the idea to manage the elements with a control bus. Any idea of how to start with this? – crm86 Aug 16 '16 at 17:48
  • Ok. I´ve got the idea of different contexts but I do not have a clear vision of how to access to see the status of each loaded component in each child. – crm86 Aug 22 '16 at 11:44
  • Use `context.getBean("someAdapter", SmartLifecycle.class);` to get a reference to the bean - `SmartLifecycle` has methods `isRunning()`, `start()`, `stop()`. To use a control bus, add one to each context and send messages to it (`context.getBean("controlBusChannel", MessageChannel.class);` – Gary Russell Aug 22 '16 at 12:50
  • Thank you Gary, I will try this soon. – crm86 Aug 23 '16 at 05:41
  • The problem that I am seeing is Spring Boot. It loads the environment from Main.class with the whole Configuration classes. This will raise an exception because the child Value annotation will not be created. – crm86 Aug 23 '16 at 09:11
  • I can't speculate what your issue is. You need to edit your question (or preferably ask another) showing an example of the code you are having trouble with. – Gary Russell Aug 23 '16 at 12:50
  • `IntegrationFlowContext` is the winner! I don't think it is appropriate to create many child contexts just to create several message sources based on config properties. It is an ugly hack imho. – Ruslan Stelmachenko Oct 24 '17 at 16:49