0

Is it right to use "wiretap" as a second line logic channel?

Or I should use another methods? I not found anything appropriate (pubSubChannel?)

For example:

    @Bean
HttpRequestHandlingMessagingGateway srvPutVers() {
    return Http.inboundGateway("/srvPutVers")
            .requestChannel("callLogicAndReply.input")
            .requestPayloadType(SomeRq.class)
            .get();
}

@Bean
IntegrationFlow callLogicAndReply() {
    return f -> f
            .wireTap("logicHard.input")
            .transform(p -> "{\"status\": \"Ok\"}");
}

@Bean
IntegrationFlow logicHard() {
    return f -> f
            .log("hard logic");
}
Shakirov Ramil
  • 1,381
  • 9
  • 13

1 Answers1

0

If you want that wireTap("logicHard.input") to be async, you need to start your logicHard flow from the ExecutorChannel with respective Executor injected. Or QueueChannel. See IntegrationFlows factory and its:

/**
 * Populate the {@link MessageChannel} object to the
 * {@link IntegrationFlowBuilder} chain using the fluent API from {@link MessageChannelSpec}.
 * The {@link org.springframework.integration.dsl.IntegrationFlow} {@code inputChannel}.
 * @param messageChannelSpec the MessageChannelSpec to populate {@link MessageChannel} instance.
 * @return new {@link IntegrationFlowBuilder}.
 * @see org.springframework.integration.dsl.MessageChannels
 */
public static IntegrationFlowBuilder from(MessageChannelSpec<?, ?> messageChannelSpec) {

See that MessageChannels factory.

On the other hand if you talk about a parallel logic, then it is indeed better to take a look into the PublishSubscribeChannel with an Executor option. Your logicHard flow logic might remain. Only what you need to have a global PublishSubscribeChannel bean and start that flow from this channel. In the main flow instead of .wireTap("logicHard.input") you need to use a plain channel(myPublishSubscribeChannel()) to refer to the same bean.

Artem Bilan
  • 113,505
  • 11
  • 91
  • 118
  • say another way. What if I wand do some logic and continue old flow after channel wich I call by wireTap? I thought Wiretap is like pubSucChannel, after reading https://www.enterpriseintegrationpatterns.com/patterns/messaging/WireTap.html because it's send same message in 2 channels – Shakirov Ramil Dec 10 '20 at 08:49
  • Your logic is OK and I still think my answer with an `ExecutorChannel` fits your expectations. Not sure what is your current struggle... – Artem Bilan Dec 10 '20 at 13:22