1

私は Spring Integration を初めて使用し、同様の投稿をここで見つけることができませんでした。現在、特定の URI を呼び出してチャネルに書き込む messageHandler が 1 つあります。

@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;
    }

および統合フロー

@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 が 1 つ呼び出されるように、この関数を拡張する必要があります。私が理解している限り、MessageHandler は常に 1 つの URL を呼び出すことができ、IntegrationFlow で関数を処理できるのは 1 つの MessageHandler だけです。

4

1 に答える 1

0

パブリッシュ サブスクライブ チャネルを使用し、それに 2 つのサブフローをサブスクライブします。DSL リファレンスを参照してください。

ところで、Spring@Scope("prototype")統合 Bean には適用されません。

于 2017-01-04T14:06:13.577 に答える