Я новичок в интеграции Spring, и я не нашел ни одного подобного сообщения здесь. Прямо сейчас у меня есть одно сообщениеHandler, которое вызывает определенный URI и записывает на канал.Весна Интеграция несколько сообщенийHandlers
@Bean
@Scope("prototype")
public MessageHandler httpGateway() {
if (checkURLs()) {
LOG.error("REST URLS are not configured");
return null;
}
CredentialsProvider credsProvider = createCredentials();
CloseableHttpClient httpclient = createHttpClient(credsProvider);
HttpComponentsClientHttpRequestFactory httpRequestFactory = new HttpComponentsClientHttpRequestFactory(httpclient);
HttpRequestExecutingMessageHandler httpHandler = createHttpRequestHandler(httpRequestFactory, requestURL);
return httpHandler;
}
private HttpRequestExecutingMessageHandler createHttpRequestHandler(HttpComponentsClientHttpRequestFactory httpRequestFactory, String request) {
HttpRequestExecutingMessageHandler httpHandler = null;
try {
httpHandler = new HttpRequestExecutingMessageHandler(new URI(request));
} catch (URISyntaxException e) {
LOG.error(e.toString(), e);
}
httpHandler.setExpectedResponseType(String.class);
httpHandler.setRequestFactory(httpRequestFactory);
httpHandler.setHttpMethod(HttpMethod.GET);
return httpHandler;
}
и IntegrationFlows
@Bean
public IntegrationFlow esbFlow(MessageHandler httpGateway) {
if (checkURLs()) {
LOG.error("REST URLS are not configured create flow without fetching");
return null;
}
return IntegrationFlows
.from(integerMessageSource(), c -> c.poller(Pollers.cron(pollerCron)))
.channel(TRIGGER_CHANNEL)
.handle(httpGateway)
.filter(p -> p instanceof String, f -> f.discardChannel(ESB_JSON_ERROR_CHANNEL))
.channel(ESB_JSON_PARSING_CHANNEL)
.get();
}
Теперь я должен расширенному эту функцию, так что одна дополнительная URL будет называться. Насколько я понимаю, MessageHandler всегда может вызывать только один URL-адрес и обрабатывать функцию в IntegrationFlow только для одного MessageHandler.