# Dp Transaction callback invoked for all other transactions too

**URL:** <https://dmap-community.ductus.global/t/dp-transaction-callback-invoked-for-all-other-transactions-too/1205>\
**Category:** Core Engine and APIs\
**Created:** [May 9, 2017, 10:58pm UTC](https://dmap-community.ductus.global/t/dp-transaction-callback-invoked-for-all-other-transactions-too/1205 "2017-05-09T22:58:09Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Srijit](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Srijit](https://dmap-community.ductus.global/u/Srijit)\
**Post date:** [May 9, 2017, 10:58pm UTC](https://dmap-community.ductus.global/t/dp-transaction-callback-invoked-for-all-other-transactions-too/1205/1 "2017-05-09T22:58:09Z")

</div>

My application has mulitple dps with its own transaction cb registered . I see tcbs are being invoked for all transactions .

I had put some print statement in init(), commit(), abort() in my tcb implementation, and it is getting printed even when the transactions are happening for other dps. It doesn’t cause any error.

so If there are 3 tcbs each registered as part of 3 dps. would all three of them get called everytime there is any transaction ?

---

<div class="post-metadata">

**Author:** ![waitai](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/waitai/32/436_2.png) [@waitai](https://dmap-community.ductus.global/u/waitai)\
**Post date:** [May 10, 2017, 3:46am UTC](https://dmap-community.ductus.global/t/dp-transaction-callback-invoked-for-all-other-transactions-too/1205/2 "2017-05-10T03:46:48Z")

</div>

Within the same client application process (or the same thread), there is only one set of transaction callbacks that can be registered with a given daemon context and they will be shared by all your data provider callpoints that are registered with the same daemon context.

If you would like to have different transaction callbacks for each of your data provider callpoints, you will need to write separate applications (or multiple threads) for each of them.

---

<div class="post-metadata">

**Author:** ![Srijit](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Srijit](https://dmap-community.ductus.global/u/Srijit)\
**Post date:** [May 10, 2017, 10:30am UTC](https://dmap-community.ductus.global/t/dp-transaction-callback-invoked-for-all-other-transactions-too/1205/3 "2017-05-10T10:30:39Z")

</div>

when the tcbs are registered in different threads, would tcbs in all threads be invoked for any transaction ?

---

<div class="post-metadata">

**Author:** ![waitai](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/waitai/32/436_2.png) [@waitai](https://dmap-community.ductus.global/u/waitai)\
**Post date:** [May 10, 2017, 4:22pm UTC](https://dmap-community.ductus.global/t/dp-transaction-callback-invoked-for-all-other-transactions-too/1205/4 "2017-05-10T16:22:40Z")

</div>

No, only the transaction callbacks associated with the data provider callbacks through the same daemon context for that transaction.

---

<div class="post-metadata">

**Author:** ![Srijit](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Srijit](https://dmap-community.ductus.global/u/Srijit)\
**Post date:** [May 10, 2017, 6:04pm UTC](https://dmap-community.ductus.global/t/dp-transaction-callback-invoked-for-all-other-transactions-too/1205/5 "2017-05-10T18:04:54Z")

</div>

Sorry I was not clear while asking the question :

This is my tcb  
class TransCbs(object):  
‘’’  
Transaction callback needed by confd  
‘’’

```
def __init__ (self, workersocket,maapisocket):
    self._workersocket = workersocket
    self._maapisocket = maapisocket
    print(" TRANS CALLBACK CLASS INSTANCE CREATED")

def cb_init(self, tctx):
    try:
        maapi.attach(self._maapisocket, 0, tctx)
        dp.trans_set_fd(tctx, self._workersocket)
        print(" TRANS CALLBACK INIT DONE")
        print("Transaction handle is %s" %(tctx.th))
        return _confd.CONFD_OK
    except:
        traceback.print_excl()

def cb_finish(self, tctx):
    maapi.detach(self._maapisocket, tctx)
    print(" TRANS CALLBACK DONE")
    return _confd.CONFD_OK

def cb_abort(self, tctx):
  print "Transaction is being aborted"
  return _confd.CONFD_OK

def cb_commit(self, tctx):
   print "Transaction is being committed"
   return _confd.CONFD_OK

```

So all the above print statements are getting printed for any transaction that happed. The data callbacks are invoked correctly.  
So do the tcb methods get invoked for any transaction, or is it a bug in my code ?

---

<div class="post-metadata">

**Author:** ![waitai](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/waitai/32/436_2.png) [@waitai](https://dmap-community.ductus.global/u/waitai)\
**Post date:** [May 10, 2017, 9:18pm UTC](https://dmap-community.ductus.global/t/dp-transaction-callback-invoked-for-all-other-transactions-too/1205/6 "2017-05-10T21:18:11Z")

</div>

> [@Srijit](#):
>
> So do the tcb methods get invoked for any transaction, or is it a bug in my code ?

Yes, all of the transaction callbacks for configuration data will always be invoked for all transactions. This isn’t a bug in your code.

The intention with the transaction callback is that it allows you to orchestrate transactions with multiple sources of data (external data i.e not CDB), ConfD implements a two-phase commit protocol towards all data sources that participate in a transaction. Thus so you have the possibility e.g from a prepare callback abort the transaction.

---

<div class="post-metadata">

**Author:** ![Srijit](https://avatars.discourse-cdn.com/v4/letter/s/977dab/32.png) [@Srijit](https://dmap-community.ductus.global/u/Srijit)\
**Post date:** [May 11, 2017, 6:45pm UTC](https://dmap-community.ductus.global/t/dp-transaction-callback-invoked-for-all-other-transactions-too/1205/7 "2017-05-11T18:45:15Z")

</div>

Thank you Waitai for answering my queries.
