Route_to_stream not working

Hi,

So I have 2 pipelines, one that checks if the message is supposed to go in a “company stream” (stream related to a specific client) and one that checks if the message is supposed to go in “system logs”. The criteria is simple: if the message has a stream_id field, it is routed to the company stream with id stream_id. If there is no stream_id field, message goes into system_logs.

My first pipeline, “handle_company_logs” has only one stage and one rule:

rule "route_to_company_stream"
when
    has_field("stream_id")
then
    route_to_stream(id: to_string($message.stream_id), remove_from_default: true);
end

This one works without any problem

My second pipeline, “handle_system_logs” also only have one stage and one rule:

rule "route_to_system_stream"
when
    NOT has_field("stream_id")
then
    route_to_stream(name: "system_logs", remove_from_default: true);
end

And this one does not work. I know it still goes through this pipeline because if I add set_field("WHAT_THE_HELL",666); in the then clause before route_to_stream, my messages without the field stream_id have a new WHAT_THE_HELL field to value 666, but they still end up in the All messages stream.

I also tried routing using the stream id with:

    route_to_stream(id: "5cdfe3d8ef7fba001faa83ba", remove_from_default: true);

which is the id of the stream system_logs but it didn’t change anything.

is the stage of your second rule on the same stage number than as the first rule? Means both in stage 0?

You should have that in order as all stage 0 rules run at the same time - so if you depend on something that is in stage 0 (in any pipeline) you need to make that dependency in stage 1 (on any pipeline).

Both rules are on stage 0. I deleted and recreated the rule that was not working and now it’s ok. They are still both in Stage 0 and as you can see in these rules, they are not co dependent since the condition on one is the exact opposite of the other.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.