I'm build an application that need to be even running (never shutdown).
All the process start from a channel (rootChannel) where right now i start this sending a message.
Looking the example on github repository of Spring Integration i've used the same structure but after sent the message (marked below with // HERE) the application go forward on context.close() (this is correct because i'm not "blocking it")
My question is: how can I do to make sure that application never stop ? (Or stop only when i kill them)
I need this because my app is a monitor and so need to be even running:
MainClass.java
public class Application {
public static void main(String[] args) throws Exception {
AbstractApplicationContext context = new ClassPathXmlApplicationContext("/META-INF/spring/applicationContext.xml", Application.class);
MessageChannel messageChannel = (MessageChannel) context.getBean("rootChannel");
GenericMessage<Document> message = createXmlMessageFromResource("/META-INF/spring/source-file-to-parse.xml");
boolean b = message.send(probeMessage); // HERE I START
context.close();
}
private static GenericMessage<Document> createXmlMessageFromResource(String path) throws Exception {
Resource res = new ClassPathResource(path);
DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance();
builderFactory.setNamespaceAware(false);
DocumentBuilder builder = builderFactory.newDocumentBuilder();
Document doc = builder.parse(res.getInputStream());
return new GenericMessage<Document>(doc);
}
}