- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想合并来自 3 个不同来源的数据(来自 HTTP msg.payload)。
但是,这些 HTTP 请求可能会被多次调用,因此可以多次接收来自同一源的数据。
[{"id":"7ed13b41.131b14","type":"join","z":"246eac57.42ec74","name":"","mode":"auto","build":"string","property":"payload","propertyType":"msg","key":"index","joiner":"","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1370,"y":1160,"wires":[["d941ca6e.0e1aa8"]]},{"id":"d941ca6e.0e1aa8","type":"debug","z":"246eac57.42ec74","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1490,"y":1120,"wires":[]},{"id":"b04a312.d6c40d","type":"function","z":"246eac57.42ec74","name":"part 1","func":"msg.parts = {};\nmsg.parts.id = 12345;\nmsg.parts.index = 0;\nmsg.parts.count = 3;\nreturn msg;","outputs":1,"noerr":0,"x":1210,"y":1120,"wires":[["7ed13b41.131b14"]]},{"id":"30cec12.e2fc13e","type":"function","z":"246eac57.42ec74","name":"part 2","func":"msg.parts = {};\nmsg.parts.id = 12345;\nmsg.parts.index = 1;\nmsg.parts.count = 3;\nreturn msg;","outputs":1,"noerr":0,"x":1210,"y":1160,"wires":[["7ed13b41.131b14"]]},{"id":"8902f2d5.ea688","type":"function","z":"246eac57.42ec74","name":"part 3","func":"msg.parts = {};\nmsg.parts.id = 12345;\nmsg.parts.index = 2;\nmsg.parts.count = 3;\nreturn msg;","outputs":1,"noerr":0,"x":1210,"y":1200,"wires":[["7ed13b41.131b14"]]},{"id":"814f25b6.dd3958","type":"http in","z":"246eac57.42ec74","name":"source 1","url":"/source1","method":"get","upload":false,"swaggerDoc":"","x":1060,"y":1120,"wires":[["b04a312.d6c40d"]]},{"id":"cab634ac.5d9df8","type":"http in","z":"246eac57.42ec74","name":"source 2","url":"/source 2","method":"get","upload":false,"swaggerDoc":"","x":1060,"y":1160,"wires":[["30cec12.e2fc13e"]]},{"id":"98f89b04.9b5bb8","type":"http in","z":"246eac57.42ec74","name":"source 3","url":"/source3","method":"get","upload":false,"swaggerDoc":"","x":1060,"y":1200,"wires":[["8902f2d5.ea688"]]}]
此流程中发生的情况是,当加入节点从源 1 接收到 3 条消息时,它认为 msg.parts
已完成。我想要实现的行为是,只有当收到来自 3 个源的数据时,流程才会继续。而如果从同一源接收到数据,则只会覆盖之前的数据。
有没有办法在 Node-RED 中实现这一目标?
最佳答案
一种方法是为每个源使用不同的 msg.topic
,并设置 join
节点以手动将所有输入合并到一个以该主题为键的对象中:
[{"id":"7f9b1fbb.58ff","type":"join","z":"f9a2eec9.c2e26","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"","joinerType":"str","accumulate":true,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":770,"y":2040,"wires":[["42ac1f9e.eac62"]]},{"id":"42ac1f9e.eac62","type":"debug","z":"f9a2eec9.c2e26","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":930,"y":2040,"wires":[]},{"id":"37be742c.72a96c","type":"http in","z":"f9a2eec9.c2e26","name":"source 1","url":"/source1/:value","method":"get","upload":false,"swaggerDoc":"","x":180,"y":2020,"wires":[["8ca164f9.828898"]]},{"id":"51684d03.091ea4","type":"http in","z":"f9a2eec9.c2e26","name":"source 2","url":"/source2/:value","method":"get","upload":false,"swaggerDoc":"","x":180,"y":2060,"wires":[["2bb81dc1.351562"]]},{"id":"1a7ad806.dbb598","type":"http in","z":"f9a2eec9.c2e26","name":"source 3","url":"/source3/:value","method":"get","upload":false,"swaggerDoc":"","x":180,"y":2100,"wires":[["c7da5f3a.95b71"]]},{"id":"9a85c694.2a37a8","type":"http response","z":"f9a2eec9.c2e26","name":"","statusCode":"204","headers":{},"x":780,"y":2080,"wires":[]},{"id":"2a0579a6.612c66","type":"change","z":"f9a2eec9.c2e26","name":"set payload value","rules":[{"t":"set","p":"payload","pt":"msg","to":"req.params.value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":570,"y":2060,"wires":[["9a85c694.2a37a8","7f9b1fbb.58ff"]]},{"id":"8ca164f9.828898","type":"change","z":"f9a2eec9.c2e26","name":"set topic 1","rules":[{"t":"set","p":"topic","pt":"msg","to":"source1","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":2020,"wires":[["2a0579a6.612c66"]]},{"id":"2bb81dc1.351562","type":"change","z":"f9a2eec9.c2e26","name":"set topic 2","rules":[{"t":"set","p":"topic","pt":"msg","to":"source2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":2060,"wires":[["2a0579a6.612c66"]]},{"id":"c7da5f3a.95b71","type":"change","z":"f9a2eec9.c2e26","name":"set topic 3","rules":[{"t":"set","p":"topic","pt":"msg","to":"source3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":2100,"wires":[["2a0579a6.612c66"]]}]
正如评论中提到的,您需要从所有以 http in
节点开始的流中返回某些内容...通常,我喜欢使用 http POST端点(用于接收输入值)并返回状态代码 204(无内容),让调用者知道该值已被接受。由于您的原始流程使用 GET 节点,因此我参数化了 URL(例如 /source1/:value
)并使用 change
节点将值复制到负载。 您的里程可能会有所不同...
请注意,我将“消息部分的数量”设置为 3,这意味着在 join
节点接收到 3 个不同主题值之前,您不会从该节点获得任何输出。之后,每个输入消息将输出最新的组合消息对象(因为“每个后续消息”复选框)。通过调整这两个选项,您可以获得所需的任何行为。
关于node-red - 如何在 Node-RED 中合并来自多个有效负载的数据?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52162066/
在我输入的 javascript 控制台中/(red|green)/g.exec('红绿红绿') 它返回一个包含两个结果的数组:[“红色”,“红色”] 它不应该返回一个包含 4 个结果的数组吗?如:[
所以我目前正在将一个下降大小的程序从 Rebol 3 迁移到 Red。所述程序依赖于与 C 库 (clang) 的大型绑定(bind)。我已经重写了 Red/System 中的绑定(bind)部分,并
是否可以在节点集群上水平扩展 Node-RED? 找不到任何文档。我的场景是每秒处理数百万个事件并使用 Node-RED 实时处理它们。 最佳答案 我在 Google Groups Node-RED
因此,在尝试在 Red 和 Red/System 之间来回编码值时出现了问题。我想访问传递给例程的对象的内脏。 我注意到 Red Runtime 中有一些函数可以在对象上下文中处理诸如此类、get-v
假设我正在使用 MQTT 协议(protocol)从许多设备接收信息,下图是一个设备 block 的简化版本: 因此,我们还假设所有其他设备具有完全相同的图表,除了将更改为 device2 的主题名称
想象一下我已经连接了一个流程,如下所示: 现在希望重新连接到: 看来我的选择是删除现有的电线,然后重新连接它们。我的问题是: 问题 是否可以将连线从一个节点移动到另一个节点,而不是删除和重新创建? 最
有没有办法将现有的 Node-RED 流文件 myflow.json 部署到运行 Node-RED 的远程计算机? 经过多次谷歌搜索,我偶然发现了this discussion在相关的Google群组
我想了解下例中WPF是如何将字符串值(Red)转换成对应的SolidColorBrush的? 我们如何对自定义 DependencyProperty 做同样的事情? 最佳答案 从字符串到 Brush
我想了解下例中WPF是如何将字符串值(Red)转换成对应的SolidColorBrush的? 我们如何对自定义 DependencyProperty 做同样的事情? 最佳答案 从字符串到 Brush
我想合并来自 3 个不同来源的数据(来自 HTTP msg.payload)。 但是,这些 HTTP 请求可能会被多次调用,因此可以多次接收来自同一源的数据。 [{"id":"7ed13b41.131
我需要 Accel 对象作为有效负载对象的一部分: msg.payload.Accel.x : 1 msg.payload.Accel.y : 2 msg.payload.Accel.z : 3 如何
我正在尝试在 Node-RED 中执行简单的 http get 请求。根据在线文档,我必须传递函数中的参数作为 http 请求节点的输入。我的函数如下所示; msg.url = "https://ap
我有一个简单的 php 页面,它输出一个表(已动态创建)。 页面上的文本都是红色标记的,除非你专门放置一个font color元素并强制它变成黑色。 我使用的是 FF 并安装了 Firebug,所以我
setXxx(Color.red) 和 setXxx(Color.RED) 的定义之间的真正区别是什么? 我在网上找到了以下解释。都是关于命名约定的吗? Java originally defined
我正在使用具有以下内容的 Dockerfile,我在树莓派上使用 resin.io 进行部署。 FROM nodered/node-red-docker:rpi-v8 USER root RUN su
这个问题已经有答案了: Difference between Color.red and Color.RED (3 个回答) 已关闭 9 年前。 Color.RED 之间有什么区别吗?变量和 Colo
我可能是盲人,但我找不到我在许多节点实现中看到的功能的文档,因为有: RED.nodes.createNode() RED.nodes.getNode() RED.nodes.eachNode() R
$('#toggle-linecolor').click(function () { chart.yAxis[0].update({ lineColor: li
我用了this GitHub 存储库,用于使用 Electron 创建 Node-Red 桌面应用程序。 现在我想使用 node-red-admin 向这个应用程序添加身份验证。我怎样才能做到这一点?
两种方法都有效吗?两者都一样。 border:2px solid red; 和 border:2px red solid; 最佳答案 W3.org (官方规范)说 border 简写属性的值是这样的:
我是一名优秀的程序员,十分优秀!