admin管理员组文章数量:1026989
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;
});
}
}
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;
});
}
}
Share
Improve this question
asked Nov 25, 2024 at 15:40
Simone FranchinaSimone Franchina
11 bronze badge
1 Answer
Reset to default 0It 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
.
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;
});
}
}
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;
});
}
}
Share
Improve this question
asked Nov 25, 2024 at 15:40
Simone FranchinaSimone Franchina
11 bronze badge
1 Answer
Reset to default 0It 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
.
本文标签: spring integrationSplitrouteaggregation logic doesn39t workStack Overflow
版权声明:本文标题:spring integration - Split, route, aggregation logic doesn't work - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1736238731a1397650.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论