Преглед изворни кода

feat: attempt to automatically decode `payload` similar to key and message templates

Thales Macedo Garitezi пре 1 година
родитељ
комит
693d5dd394

+ 1 - 1
apps/emqx_bridge_kafka/src/emqx_bridge_kafka_impl_producer.erl

@@ -469,7 +469,7 @@ render_topic({fixed, KafkaTopic}, _Message) ->
     KafkaTopic;
 render_topic({dynamic, Template}, Message) ->
     try
-        iolist_to_binary(emqx_template:render_strict(Template, Message))
+        iolist_to_binary(emqx_template:render_strict(Template, {emqx_jsonish, Message}))
     catch
         error:_Errors ->
             throw(bad_topic)

+ 1 - 6
apps/emqx_bridge_kafka/test/emqx_bridge_v2_kafka_producer_SUITE.erl

@@ -967,12 +967,7 @@ t_dynamic_topics(Config) ->
                 RuleTopic,
                 [
                     {bridge_name, ActionName}
-                ],
-                #{
-                    sql =>
-                        <<"select *, json_decode(payload) as payload from \"", RuleTopic/binary,
-                            "\" ">>
-                }
+                ]
             ),
             ?assertStatusAPI(Type, ActionName, <<"connected">>),