{
  "synLogic": "int $ret \u003d $api($1, $2, $3);",
  "help": "This api terminates the connection with the Kafka server and it should not be called every time as it will impact performance. The connection can be terminated for various reasons such as: Once you have finished sending and receiving messages, then you can close the server or it might get closed due to a connection error. It should be called at the end of test.",
  "notes": "",
  "returns": "This function in C returns an integer value, while in Java it returns a Boolean. In C, if the returned value is less than 0, it indicates that an error has occurred. In Java, if the returned value is false, it indicates that an error has occurred. Conversely, if the returned value is true, it signifies that the connection has been successfully closed.",
  "arguments": "\u003ctable class\u003d\"newGuiTable\" style\u003d\"width:100%\"\u003e \u003ctbody\u003e\u003ctr\u003e \u003cth\u003e Argument \u003c/th\u003e \u003cth\u003e Description \u003c/th\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003e JPCID \u003c/td\u003e \u003ctd\u003e It is the Connection ID for Java Messaging Service \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003e Transaction Name \u003c/td\u003e \u003ctd\u003e A custom transaction message to be logged when the connection is closed. \u003c/td\u003e \u003c/tr\u003e \u003ctr\u003e \u003ctd\u003e Error Message \u003c/td\u003e \u003ctd\u003e A string that will be used to store any error messages encountered during the process. \u003c/td\u003e \u003c/tr\u003e \u003c/tbody\u003e\u003c/table\u003e",
  "parameterization": "",
  "component": [
    {
      "id": "$1",
      "type": "TextField",
      "label": "JMS Pool Connection Id",
      "value": "",
      "css": "p-grid p-align-center w-100-p",
      "title": "First character must be Alpha.\r\nOther characters are Alpha, Numeric or Underscore",
      "placeHolder": "",
      "style": "",
      "isDisabled": "",
      "labelVarCheckbox": "If JMS Connection id is a program variable",
      "argIndex": 0,
      "validate": {
        "inputType": "Text",
        "disabled": false,
        "pattern": "^[a-zA-Z][a-zA-Z0-9_]{0,63}$",
        "required": false,
        "min": 0,
        "max": 0,
        "method": "isValidVar(arg)"
      },
      "quotes": false
    },
    {
      "id": "$2",
      "type": "TEXT_VAR",
      "label": "Transaction Name",
      "value": "",
      "css": "p-grid p-align-center w-100-p",
      "title": "Enter transaction name",
      "placeHolder": "",
      "style": "",
      "isDisabled": "",
      "labelVarCheckbox": "If transaction name is a program variable",
      "argIndex": 0,
      "validate": {
        "inputType": "Text",
        "disabled": false,
        "required": true,
        "min": 0,
        "max": 0
      },
      "quotes": true
    },
    {
      "id": "$3",
      "type": "TextField",
      "label": "Error Message Buffer Pointer",
      "value": "",
      "css": "p-grid p-align-center w-100-p",
      "title": "Enter error message",
      "placeHolder": "",
      "style": "",
      "isDisabled": "",
      "labelVarCheckbox": "",
      "argIndex": 0,
      "validate": {
        "inputType": "Text",
        "disabled": false,
        "required": true,
        "min": 0,
        "max": 0
      },
      "quotes": false
    },
    {
      "id": "$ret",
      "type": "TextField",
      "label": "Return Variable",
      "value": "",
      "css": "p-grid p-align-center w-100-p",
      "title": "First character must be Alpha.\r\nOther characters are Alpha, Numeric or Underscore",
      "placeHolder": "",
      "style": "",
      "isDisabled": "",
      "labelVarCheckbox": "",
      "argIndex": 0,
      "validate": {
        "inputType": "Text",
        "disabled": false,
        "pattern": "^[a-zA-Z][a-zA-Z0-9_]{0,63}$",
        "required": false,
        "min": 0,
        "max": 0,
        "method": "isValidVar(arg)"
      },
      "quotes": true
    }
  ],
  "name": "ns_kafka_close_connection",
  "syntax": "int ns_kakfa_close_connection(int jpcid, char *transaction_name, char *error_msg);",
  "javaSyntax": "boolean ns_kafka_close_connection(JMSKey key, String txName);",
  "cEx": "flow()\n{\n  int jpid;        //JMS Pool Id\n  int jcid;        //JMS Connection Id\n  char error_msg[1024 + 1];        // Error string. Must be 1024 size\n  int ret;        // Error code\n  char *msg \u003d \"Message will goes here\";        // Message to be produced\n  int msg_len \u003d strlen(msg);        // Message Length\n  char *key \u003d \"message_key\";        // Message Key\n  int key_length \u003d strlen(key);        // Message Length\n\n  if((jpid \u003d ns_kafka_init_producer(\"127.0.0.1\", 9092, \"topic\", 1, error_msg)) \u003c 0)\n  {\n    fprintf(stderr, \"Error in initializing Kafka producer. Error code \u003d %d, Error Msg \u003d %s\", jpid, error_msg);\n    return;\n  }\n\n  if((jcid \u003d ns_kafka_get_connection(jpid, \"KAFKAProducerSSLConnect\", error_msg)) \u003c 0)\n  {\n    fprintf(stderr, \"Error in getting Kafka connention. Error code \u003d %d, Error Msg \u003d %s\", jcid, error_msg);\n    return;\n  }\n  if((ret \u003d ns_kakfa_close_connection(jcid, \"KAFKAProducerSSLClose\" ,error_msg)) \u003c 0 )\n  {\n    fprintf(stderr, \"Error in closing Kafka connection %d\",ret);\n    return;\n  }\n}",
  "javaEx": "public class flow implements NsFlow\n{\n  public int execute(NSApi nsApi) throws Exception \n  {\n    int status \u003d 0;\n    NSApi.JMSKey key \u003d null;// initialize key using ns_kafka_init_producer or consumer api\n    String msg\u003dnull;\n    /*\n     * close connection when VUser is ramped down as per scenario configuration. \n     * connections should not be closed when VUser is in duration phase for better utilization of connections.\n     */\n    if (nsApi.ns_is_rampdown_user() \u003d\u003d 1)\n    { \n      boolean closeStatus \u003d nsApi.ns_kafka_close_connection(key, \"KAFKAConsumerClose\")\n      if (!closeStatus)\n      {\n        System.out.println(\"Error in closing kafka connection. Key \u003d \" + key.getKeyMain() + \" - \" + key.getIdPool());\n        return 0;\n      }\n    }\n    return status;\n  }\n}",
  "insertStrC": "ns_kakfa_close_connection(int jpcid, char *transaction_name, char *error_msg);",
  "insertStrJava": "ns_kafka_close_connection(JMSKey key, String txName);",
  "description": "This api terminates the connection with the Kafka server and it should not be called every time as it will impact performance. The connection can be terminated for various reasons such as: Once you have finished sending and receiving messages, then you can close the server or it might get closed due to a connection error. It should be called at the end of test."
}