# How to use maapi\_request\_action\_th

**URL:** <https://dmap-community.ductus.global/t/how-to-use-maapi-request-action-th/4300>\
**Category:** CDB and CDB API\
**Created:** [December 28, 2022, 2:31pm UTC](https://dmap-community.ductus.global/t/how-to-use-maapi-request-action-th/4300 "2022-12-28T14:31:23Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anup](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Anup](https://dmap-community.ductus.global/u/Anup)\
**Post date:** [December 28, 2022, 2:31pm UTC](https://dmap-community.ductus.global/t/how-to-use-maapi-request-action-th/4300/1 "2022-12-28T14:31:23Z")

</div>

Hi,

Can anyone please tell me how can we use below function to use transaction in action callpoint.

int maapi\_request\_action\_th(int sock, int thandle, confd\_tag\_value\_t  
\*params, int nparams, confd\_tag\_value\_t \*\*values, int \*nvalues, const  
char \*fmt, …);

Regards,  
Anup Agrawal

---

<div class="post-metadata">

**Author:** ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)\
**Post date:** [January 5, 2023, 10:42am UTC](https://dmap-community.ductus.global/t/how-to-use-maapi-request-action-th/4300/2 "2023-01-05T10:42:02Z")

</div>

Hi,

`maapi_request_action_th()` is used to invoke an action. It is not normally used from an action callpoint that was called because an action was invoked.

See the confd\_lib\_dp(3) man page for details.

---

<div class="post-metadata">

**Author:** ![Anup](https://avatars.discourse-cdn.com/v4/letter/a/4491bb/32.png) [@Anup](https://dmap-community.ductus.global/u/Anup)\
**Post date:** [January 8, 2023, 6:28am UTC](https://dmap-community.ductus.global/t/how-to-use-maapi-request-action-th/4300/3 "2023-01-08T06:28:06Z")

</div>

Hi cohult,

thanks for the response.  
If i want to start the write transaction from action callpoint which steps i need to follow. Because, when i am trying to start normal CDB\_RUNNING session, Confd getting stuck on apply\_transaction function.

Below process i followed to start transaction from action callpoint,  
/\* Session creation \*/  
CDA\_CONFD\_FATAL(CDA\_maapi\_start(CDB\_RUNNING, &th, IMMEDIATE));  
CDA\_maapi\_set\_namespace(th, core\_model\_\_ns);

```
     maapi_ret = CDA_maapi_exists(th, CORE_MODEL_FD_FC, vlanFd_uuid, vlanFc_uuid);

     if(CONFD_TRUE != maapi_ret)
     {
         CDA_CONFD_FATAL(CDA_maapi_create(th, CORE_MODEL_FD_FC, vlanFd_uuid, vlanFc_uuid));
         CDA_CONFD_FATAL(CDA_maapi_cd(th, CORE_MODEL_FD_FC, vlanFd_uuid, vlanFc_uuid));

         /* set the vlan-fc local id */
         CDA_SET_STR(&vt, vlanFc_localId);
         CDA_CONFD_FATAL(CDA_maapi_set_elem(th, &vt, CORE_MODEL_LOCAL_ID_ENT));

     }
     else
     {
         printf("RPC instance for given vlan ID already exists");
     }

     CDA_CONFD_FATAL(CDA_maapi_apply_trans(th));
     CDA_CONFD_FATAL(CDA_maapi_end(th));

```

Regards,  
Anup

---

<div class="post-metadata">

**Author:** ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)\
**Post date:** [January 8, 2023, 9:21pm UTC](https://dmap-community.ductus.global/t/how-to-use-maapi-request-action-th/4300/4 "2023-01-08T21:21:56Z")

</div>

Hi,

Start a separate thread/process that perform the transaction if your action handler thread also handle subscriptions or other callpoints triggered by the commit (apply).

Regards

---

<div class="post-metadata">

**Author:** ![schandrakanth](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@schandrakanth](https://dmap-community.ductus.global/u/schandrakanth)\
**Post date:** [February 28, 2023, 9:12am UTC](https://dmap-community.ductus.global/t/how-to-use-maapi-request-action-th/4300/5 "2023-02-28T09:12:08Z")

</div>

Hi Cohult,

What if the action handler is expected to reply a value based on DB commit success.

As pee the above suggestion , it is expected to open a separate thread to perform commit (the configuration)

Please share further inputs.

Regards,  
Chandra

---

<div class="post-metadata">

**Author:** ![schandrakanth](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@schandrakanth](https://dmap-community.ductus.global/u/schandrakanth)\
**Post date:** [March 29, 2023, 10:21am UTC](https://dmap-community.ductus.global/t/how-to-use-maapi-request-action-th/4300/6 "2023-03-29T10:21:10Z")

</div>

hi All,

Can anyone help on the above query?

I tried to use confd\_cmd tool from action handler (as it will work like a new process), again it halts at MAAPI\_APPLY\_TRANS

Below are confd\_cmd trace logs  
TRACE Connected (maapi) to ConfD  
TRACE MAAPI\_START\_USER\_SESSION → CONFD\_OK  
TRACE MAAPI\_START\_TRANS → CONFD\_OK  
TRACE MAAPI\_CREATE /temp/container-1/list{60} → CONFD\_OK  
TRACE MAAPI\_SET\_ELEM2 /temp/container-1/list{60}/Rowstatus → CONFD\_OK  
TRACE MAAPI\_APPLY\_TRANS

Regards,  
Chandrakanth S.

---

<div class="post-metadata">

**Author:** ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)\
**Post date:** [March 29, 2023, 12:38pm UTC](https://dmap-community.ductus.global/t/how-to-use-maapi-request-action-th/4300/7 "2023-03-29T12:38:13Z")

</div>

There is likely a deadlock. ConfD is waiting for your thread to reply to for example a transaction subscription notification or some other callback invocation inside the transaction lock, while you are starting a transaction that will wait for that transaction to finish before continuing.

---

<div class="post-metadata">

**Author:** ![schandrakanth](https://avatars.discourse-cdn.com/v4/letter/s/ecb155/32.png) [@schandrakanth](https://dmap-community.ductus.global/u/schandrakanth)\
**Post date:** [March 29, 2023, 4:00pm UTC](https://dmap-community.ductus.global/t/how-to-use-maapi-request-action-th/4300/8 "2023-03-29T16:00:23Z")

</div>

hi Cohult,

Thanks for the reply  
Can you please help on comment 4/7 ?

Regards,  
Chandrakanth S.

---

<div class="post-metadata">

**Author:** ![cohult](https://yyz2.discourse-cdn.com/flex010/user_avatar/dmap-community.ductus.global/cohult/32/221_2.png) [@cohult](https://dmap-community.ductus.global/u/cohult)\
**Post date:** [March 29, 2023, 5:29pm UTC](https://dmap-community.ductus.global/t/how-to-use-maapi-request-action-th/4300/9 "2023-03-29T17:29:52Z")

</div>

I suggest looking into the ConfD developer log (log level trace) which will tell what the ConfD transaction manager is doing at the time of the MAAPI apply.
