Maka
Maka

Reputation: 357

Direct accessing network APIs in Flows

I know that it's an old question, but I haven't reached to a concise conclusion until now.

I've already made this kind a question before:

https://discourse.corda.net/t/direct-accessing-network-apis-in-flows/915.

So, at this moment, if I wanted to make an HTTP request inside a flow, can I just make it? Or it's restricted in some way?

In case not, how would be a better approach to interact with a legacy system, for example?

Upvotes: 0

Views: 53

Answers (1)

Joel
Joel

Reputation: 23140

It is fine to make HTTP calls from a flow. However, note that as of Corda 3.1, support for HTTP requests in flows is limited:

  • The request must be executed in a blocking way. Flows don't currently support suspending to await an HTTP call's response. This means that the flow worker is blocked until the HTTP call returns
  • The request must be idempotent. If the flow fails and has to restart from a checkpoint, the HTTP request will be replayed

You can see an example of making an HTTP request in a flow in the Flow HTTP sample here.

An alternative is to query the legacy system outside of the flow, and pass the result of the query in as a flow argument.

Upvotes: 0

Related Questions