Reputation: 1
I'm trying to create an implementation of the IntegrationFlowAdapter class that would allow me to take a push notification, copy it for each device token, split the push notification list and have it routed to the correct handler based on the platform, then take the results to process them (log them or possibly create business logic). The flow stops after handling by the subflow, how can I continue the flow?
This is my code:
public class PushSendFlowAdapter extends IntegrationFlowAdapter {
private final String inputChannel;
DeviceTokenManagerService<?> deviceTokenManagerService;
private final FirebaseSender firebaseSender;
private final ApnsSender apnsSender;
private final HuaweiSender huaweiSender;
@Override
protected IntegrationFlowDefinition<?> buildFlow() {
return IntegrationFlows.from(this.inputChannel)
.handle((pushNotification, headers) -> deviceTokenManagerService.clonePushNotificationForEachDeviceToken((PushNotification) pushNotification))
.split()
.enrichHeaders(headerEnricherSpec -> headerEnricherSpec.headerExpression(TracingConstants.PLATFORM, "payload.getDeviceToken().getPlatform()"))
.enrichHeaders(headerEnricherSpec -> headerEnricherSpec.header(TracingConstants.CORRELATION_ID, UUID.randomUUID()))
.route(Message.class, h -> h.getHeaders().get(TracingConstants.PLATFORM, Platform.class),
routerSpec -> routerSpec
.subFlowMapping(Platform.ANDROID, androidFlow -> androidFlow.handle(PushNotification.class, firebaseSender::sendPush))
.subFlowMapping(Platform.IOS, iosFlow -> iosFlow.handle(PushNotification.class, apnsSender::sendPush))
.subFlowMapping(Platform.HUAWEI, huaweiFlow -> huaweiFlow.handle(PushNotification.class, huaweiSender::sendPush))
)
.aggregate(aggregatorSpec -> aggregatorSpec.correlationStrategy(message -> message.getHeaders().get(TracingConstants.CORRELATION_ID)))
.handle((p,h) -> {
log.info("log: {}", p);
//handling logic
return null;
});
}
}
Upvotes: 0
Views: 23
Reputation: 121542
It is not clear what Spring Integration version you use, but try to add .defaultOutputToParentFlow()
to that routerSpec
configuration.
Also would be great to know a signature of your sendPush
and if it really returns something what should go down to the aggregate
.
Upvotes: 0