Search code examples
siddhiwso2-streaming-integrator

How get source message from http-request (sink) response?


I do http request ({f_id:1001}) to http service. Service return me only true/false in result without source f_id.

And want to select response of it with source F_ID:

@sink(type='http-request', publisher.url='http://127.0.0.1:3020/', 
    method="POST", sink.id='download-sink', @map(type='json'))
define stream OutputToNodejs(f_id long);

@source(type='http-response' , sink.id='download-sink', 
    http.status.code='200',
    @map(type='json', @attributes('result'))) 
define stream responseStream2xx(result bool);

@info(name = 'SimpleLogTrigger')
from responseStream2xx 
    select result as text, f_id_from_request /* HOW GET F_ID from source request HERE */
    insert into OutputStream2;

And I want to use source request message in select from source response. But how I can get source message here? If I cannot - may be I can forward some id of it from request to response?


Solution

  • There is no out of the box way to do this currently. There are two workarounds to get this done.

    1. Make your service return f_id too in the response and get it inside the response stream
    2. Add an improvement to HTTP request sink and HTTP response source so that source can access sink's stream variables. But this will be a major development effort. So I think number one is the better option given that you have governance over HTTP service.