1
저는 Spring Integration을 처음 접했고 비슷한 게시물을 찾을 수 없었습니다. 지금은 특정 URI를 호출하고 채널에 쓰는 하나의 messageHandler가 있습니다.Spring 통합 여러 messageHandler
@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에서만 함수를 처리 할 수 있습니다.