8

I gave Node-Red a short test-run this week. It is not clear to me whether it supports flows that encompass more than one request. Does Node-Red have a request-per-flow or a session-per-flow model?

Having worked with data-flow based programming tools for Business Process Modeling (webMethods and Tibco), I see one of their key features is the ability to model sessions and workflows. These tools are, however, rather large for the purposes of most IoT projects so it would be great if something similar could be accomplished with Node-Red.

A follow-up question, in case Node-Red does not support this, is whether there are some simple tools that do support graphical modeling of session flows?

  • Im not sure if this helps; groups.google.com/forum/#!topic/node-red/Fv37YHVXQxw – MatsK Sep 18 '17 at 4:21
  • 1
    @MatsK Not sure. If you follow this link you will see a, somewhat contrived, example flow from a BPM tool. Looking at the "Pizza vendor" part of the flow you see three input events/requests: the order received, a status request (where is my pizza?) and payment. The requests serve to advance the flow which has a life-cycle that is independent of any single request. – Chris Steinbach Sep 18 '17 at 8:39
  • 1
    @MatsK An example more relevant to IoT would be, say, a smoke detector that begins a flow when smoke is detected. The first action (node) in the flow would be to sound an audible alarm, but after that the flow can go a few different ways. If a user-request is received within a given time to cancel the alarm, the audible alarm is stopped and the flow ends. If no cancel request is received, or another smoke-detector triggers, then further actions is taken (e.g. SMS owner, call emergency services). – Chris Steinbach Sep 18 '17 at 8:56
3

The answer is no and yes.

Flows in node-red are pretty static, there is no notion of instantiating a flow when the first requests comes in such that you might have an instance of a flow per request.

There is also no built-in notion of a session that would allow you to associate messages flowing through flows with a session.

However, you can relatively easily construct these things yourself. Node-red provides a notion of flow and global state, which is accessed using the flow and global objects, see https://nodered.org/docs/writing-functions#storing-data. What you would do is send a cookie to clients and then explicitly associate an incoming request with saved global or flow state. You can then write code that is "session aware" based on the saved session state. This works well in function nodes, but you will hit some issues with the built-in nodes that do things like rate limit or split & merge messages because these are not generally aware of the session notion.

In the pizza example you would maintain the state of an order in the flow or global context and you would access the appropriate order's state based on the cookie value.

5

Short answer is yes, at least according this feature request:

Define convention for 'stateful' sessions #63

This request is closed with a commit stating that a web socket node is added, which is based on a session token.

  • This is a useful feature, and relevant to what I'm concerned with to some extent, but not exactly the same. What I mean by session is really a started instance of a defined flow, (or model in the BPM world). The lifetime of this instantiated flow is not linked to any single request or transport session. Think of it like a state-transition diagram if you will, although less formalised in the implementations I've seen. – Chris Steinbach Sep 19 '17 at 18:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.