代替アプリケーション コンテキストを使用したビジネストランザクションの作成

appd_bt_begin_with_app_context()appd_bt_end() コールと コールを使用すると、代替アプリケーション コンテキストでビジネストランザクションを作成できます。appd_bt_begin() に渡されるパラメータに加えて、appd_bt_begin_with_app_context() は、appd_context_config_init() へのコールで定義されたアプリケーション コンテキスト名の文字列も引数として受け取ります。

appd_bt_begin_with_app_context() は、そのビジネストランザクションに影響する後続のルーチンで使用するハンドルを返します。

次の例は、代替アプリケーション コンテキストでビジネストランザクションを設定する方法を示しています。

// create the alternate application context
appd_context_config* cfg2 = appd_context_config_init("My_Context");
...
// add additional setter commands to initialize the alternate application context
appd_context_config_set_controller_account(cfg2, ac.second.ac_account_get().c_str());
appd_context_config_set_controller_access_key(cfg2, ac.second.ac_access_key_get().c_str());
appd_context_config_set_controller_host(cfg2, ac.second.ac_host_get().c_str());
appd_context_config_set_controller_port(cfg, ac.second.ac_port_get());
appd_context_config_set_controller_use_ssl(cfg2, ac.second.ac_use_ssl_get() ? 1 : 0);
appd_context_config_set_app_name(cfg2, ac.second.ac_app_get().c_str());
appd_context_config_set_tier_name(cfg2, ac.second.ac_tier_get().c_str());
appd_context_config_set_node_name(cfg2, ac.second.ac_node_get().c_str());
// initialize the alternate application context
appd_sdk_add_app_context(cfg2);
// start the "Checkout" transaction with the alternate application context
appd_bt_handle btHandle = appd_bt_begin_with_app_context("My_Context", "Checkout", NULL);
// end the transaction
appd_bt_end(btHandle);

appd_bt_end() へのコールによってビジネストランザクションが終了すると、エージェントはビジネストランザクションのメトリックの報告を停止します。トランザクションの開始と終了の間に、ビジネストランザクションへのエラーの追加、トランザクション スナップショット属性の定義、バックエンドと exit コールの追加などの操作を実行できます。