# Maintaining transaction offsets across service re-runs

**URL:** <https://forum.canton.network/t/maintaining-transaction-offsets-across-service-re-runs/5056>\
**Category:** App Development\
**Tags:** ledger-api, daml-sdk\
**Created:** [August 9, 2022, 2:17pm UTC](https://forum.canton.network/t/maintaining-transaction-offsets-across-service-re-runs/5056 "2022-08-09T14:17:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![YazanDianieh](https://avatars.discourse-cdn.com/v4/letter/y/bcef8e/32.png) [@YazanDianieh](https://forum.canton.network/u/YazanDianieh)\
**Post date:** [August 9, 2022, 2:17pm UTC](https://forum.canton.network/t/maintaining-transaction-offsets-across-service-re-runs/5056/1 "2022-08-09T14:17:18Z")

</div>

I use the TransactionsClient from the ledger API to listen to newly created transactions, and I specify a LedgerOffset begin value to identify the offset from which to start listening to transactions.

As I create and process transactions, I do maintain the latest TX offset value, but I do not persist it (yet). I need to persist the offset so that the next time I restart my service, I pick up where I left.

Are there any DAML-esque ways of persisting this offset value?

---

<div class="post-metadata">

**Author:** ![stefanobaghino-da](https://yyz2.discourse-cdn.com/flex034/user_avatar/forum.canton.network/stefanobaghino-da/32/7057_2.png) [@stefanobaghino-da](https://forum.canton.network/u/stefanobaghino-da)\
**Post date:** [August 10, 2022, 8:30am UTC](https://forum.canton.network/t/maintaining-transaction-offsets-across-service-re-runs/5056/2 "2022-08-10T08:30:15Z")

</div>

Can you clarify for me what you mean by “Daml-esque”? In general, the offset can be persisted in any way it suits your specific application, including “just” writing it to a file. If your application is backed by a transactional data store (like a relational database), piggy-backing on your store’s transactionality to process the events and storing the offset as part of a single transaction is probably a very nice property you want to use. Otherwise you’ll need to consider what happens if you only processed parts of a transaction as a failure happens and take steps to deal with that (processing events in an idempotent fashion might help, as well as keeping track of the event ID within a transaction, but the details depend heavily on your application’s logic and the transactional properties of your application’s secondary data store).

---

<div class="post-metadata">

**Author:** ![YazanDianieh](https://avatars.discourse-cdn.com/v4/letter/y/bcef8e/32.png) [@YazanDianieh](https://forum.canton.network/u/YazanDianieh)\
**Post date:** [August 10, 2022, 9:53am UTC](https://forum.canton.network/t/maintaining-transaction-offsets-across-service-re-runs/5056/3 "2022-08-10T09:53:55Z")

</div>

In addition to the standard persistence stores (files, dbs, etc) that you mentioned, I just wanted to know (since I’m fairly new to this) if there were other well-defined patterns. All clear. Thank you Stefano.
