0

I was trying to understand the actual flow of flow-logic and sessions.

Consider a scenario in which there are 3 party nodes  A, B and C. At the very onset, A initiates a transaction with B, but B was down at that time. So as far as I understand, it will keep on retrying until B comes back.

  • Whether it is possible for A to initiate another transaction with C at this point of time?

  • I read that open source Corda is single threaded whereas enterprise is multi-threaded, So does this, make a change in the outcome of above scenario?

I have gone through some hints of explicitly making the flow and thread sleep as well. Please shed some light over here!

Benjamin
  • 105
  • 10

1 Answers1

1

Corda Open Source:

  • When a flow is suspended (when it calls send(), receive(), sendAndReceive(), or sleep()), the single thread is freed and another flow can be started.
  • When a flow calls an external operation (e.g. HTTP calls, DB calls), that call is blocking; meaning the thread remains locked by the flow until the external call completes and the flow returns. In this case you can't start another flow.
  • Starting Corda 4.4, you can define asynchronous flow operations (read about it here), this puts those long running operations in a separate thread and suspends the flow; making the flow thread available for other flows to start.

Corda Enterprise:

  • As you mentioned, it has multiple flow threads. So the same points above apply, but you have more room to start other flows depending on how many flow threads are available.
Adel Rustum
  • 2,518
  • 2
  • 7
  • 15
  • Among send() Receive() & sendAndReceive(). Isnt only sendAndReceive has suspendable feature? https://api.corda.net/api/corda-enterprise/4.3.1/html/api/kotlin/corda/net.corda.core.flows/-flow-logic/send.html Because I read here that send does not suspend! Just clarifying. – Benjamin Oct 01 '20 at 15:01
  • 1
    See answer [here](https://stackoverflow.com/a/51187548/11809424). – Adel Rustum Oct 01 '20 at 15:22
  • Oh... Then, May I know, what does it meant by saying for Flowlogic.send in above link : "Queues the given payload for sending to the otherParty and continues without suspending. Note that the other party may receive the message at some arbitrary later point or not at all: if otherParty is offline then message delivery will be retried until it comes back or until the message is older than the network's event horizon time." Documentation is saying it will not suspends but other post you shared is saying it will e suspended!! – Benjamin Oct 05 '20 at 05:59
  • 1
    @BEN I think you are right and there is contradiction in the official documentation, for instance [here](https://docs.corda.net/docs/corda-os/4.5/flow-state-machines.html#suspendable-functions) it mentions that all three functions (`send()`, `receive()`, and `sendAndReceive()`) cause a flow to suspend. But I think the documentation of `send()` method that you shared is the correct one. Meaning suspend only happens when a flow is waiting on something (i.e. calls `receive()` or `sendAndReceive()`). I will get in touch with R3 for clarification and post an update. – Adel Rustum Oct 05 '20 at 06:07
  • 1
    According to a reply from R3, `send()` causes a suspend just to create a checkpoint, but it proceeds immediately. – Adel Rustum Oct 05 '20 at 15:01