Possible to store workflow/activity data in another database(own database)

Having few questions

  1. If we wants to capture the workflow/activity data in our own database along with Temporal database then is it possible?

  2. Is temporal exposing any API where we can fetch data from temporal and store in our own database ?

  3. I have configured postgres and just saw that 29 tables are there but didn’t able to see history of workflow and activities there.

  1. It depends on the use case. The default approach is to have an activity that updates your own DB when needed by the business logic.

  2. There is no direct API, but there are many options to solve a problem depending on the use case.

  3. We don’t recommend looking into these tables directly unless you want to understand the internals of Temporal.

Just to add, another options is to keep your workflow histories and visibility info after the set retention period via archival. It’s still experimental feature tho so be ware of possible issues (search the forum here if you decide to use it first to find a number of posts on setting it up).

1) It depends on the use case. The default approach is to have an activity that updates your own DB when needed by the business logic.
Que - when you say “activity that updates your own DB” means whenever any activities happened we need to store that activity id and details in our own database, is it you are saying ?

2)There is no direct API, but there are many options to solve a problem depending on the use case.
Que - Can you suggest other way, our requirements is we wanted to store some useful and high level data at our own database so anytime temporal DB went down we can fetch some important things from our database.

  1. No. You implement “SaveToDB” activity that is called from a workflow to update your external database.

  2. Not sure if such complexity makes sense for theoretical “when temporal DB is down”.

Is it default method of temporal ? Can you please just show me any demo or any code about “SaveToDB” activity like how it is being called from workfow? Thank you so much in advance

It would be an activity you define and register with your worker.
You can invoke it sync like shown in this sample, or async like in this one.

Your activity code would do your logic to store whatever it needs to your db.

Ok thanks, understood :slight_smile: