Integration flow accessing a paged http resource -
i'm trying consume entirely paged resource follow, aproach raising stackoverflowexception. clue abount this? or different aproach?
example: https://gist.github.com/daniel-frank/a88fa4553ed34c348528f51d33c3733b
ok. see now. let me simplify recursive code show problem:
private integrationflow getpageflow() { return f -> f .publishsubscribechannel(ps -> ps .subscribe(this.nextpageflow()) ); } private integrationflow nextpageflow() { return f -> f .publishsubscribechannel(ps -> ps .subscribe(this.getpageflow()) ); } so, technically have structure in memory:
getpageflow nextpageflow getpageflow nextpageflow getpageflow and on.
another problem here each .subscribe(this.nextpageflow()) creates new instance of integrationflow meanwhile logically expect one.
i understand can't declare beans in integrationflowadapter impl, won't have stackoverflowexception anyway.
what see problem in approach lack of messagechannel abstraction.
you use publishsubscribechannel everywhere, meanwhile distinguish logic explicit channel definition in flow.
to break recursion , keep code closer solution possible i'd make this:
private integrationflow getpageflow() { return f -> f .channel("pageservicechannel") .handle(http .outboundgateway("https://jobs.github.com/positions.json?description={description}&page={page}") ... private integrationflow nextpageflow() { return f -> f .filter("!payload.isempty()") .enrichheaders(e -> e.headerexpression("page", "headers.getordefault('page', 0) + 1", true)) .channel("pageservicechannel"); } of course still have recursion, @ run time, logical.
Comments
Post a Comment