2017-01-04 6 views
1

私は春の統合の新しいですし、私はここに同様の投稿を見つけることができませんでした。 今、私は特定のURIを呼び出してチャネルに書き込む1つの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は常に1つのURLだけを呼び出して、IntegrationFlowで1つのMessageHandlerで関数を処理できます。

答えて

0

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

BTW、@Scope("prototype")は、スプリング統合Beanには適用されません。

関連する問題