int jpid;                              //JMS Pool Id
int jcid;                              //JMS Connection Id
char error_msg[1024 + 1];              // Error string. Must be 1024 size
int ret;                               // Error code
char *msg = "message";            // Message to be produced
int msg_len = strlen(msg);             // Message Length

// Initialize Tibco producer with given parameters and connection pool of pool_size
// It returns JMS Pool ID which need to be passed for getting connection from the pool
// In case of error, error code of value < 0 is returned and error_msg (max 1014) is set with error message
// (int ns_tibco_init_producer(tibco_hostname, tibco_port, tibco_topic_or_queue, topic_or_queue_name, tibco_userId, tibco_password, max_pool_size, error_msg))
if((jpid = ns_tibco_init_producer("ssl://127.0.0.1", 7222, 1, "Topic", "username", "password", 1, error_msg)) < 0)
{
fprintf(stderr, "Error in initializing Tibco producer. Error code = %d, Error Msg = %s", jpid, error_msg);
return;
}

//This api will initialize tibco ssl ciphers
//ns_tibco_set_ssl_ciphers(jcid, ciphers, error_msg)
if((ret = ns_tibco_set_ssl_ciphers(jcid, "cipher", error_msg)) < 0)
{
fprintf(stderr, "Error in setting tibco ssl ciphers. Error code = %d, Error Msg = %s", ret, error_msg);
return;
}

//This api will initialize tibco ssl pvtKey File path
//(ns_tibco_set_ssl_pvt_key_file(jcid, pvtKeyFilePath, error_msg)
if((ret = ns_tibco_set_ssl_pvt_key_file(jcid, "/home/keyfile", error_msg)) < 0)
{
fprintf(stderr, "Error in setting tibco ssl pvt key. Error code = %d, Error Msg = %s", ret, error_msg);
return;
}

//This api will initialize tibco ssl trustedCA certificate file path
//(ns_tibco_set_ssl_trusted_ca(jcid, trustedCACertFilePath, error_msg)
if((ret = ns_tibco_set_ssl_trusted_ca(jcid, "/home/trustedca", error_msg)) < 0)
{
fprintf(stderr, "Error in setting tibco ssl trustedCA. Error code = %d, Error Msg = %s", ret, error_msg);
return;
}

//This api will initialize tibco ssl issuer certificatefile path
//ns_tibco_set_ssl_issuer(jpid, issuerCertFilePath, error_msg)
if((jcid = ns_tibco_set_ssl_issuer(jpid, "/home/issuer", error_msg)) < 0)
{
fprintf(stderr, "Error in setting tibco ssl issuer. Error code = %d, Error Msg = %s", ret, error_msg);
return;
}

//This api will initialize tibco ssl identity file path and password
//(ns_tibco_set_ssl_identity(jcid, identityFilePath, ssl_pwd, error_msg)
if((ns_tibco_set_ssl_identity(jcid, "/home/identity", "password", error_msg)) < 0)
{
fprintf(stderr, "Error in setting tibco ssl identity. Error code = %d, Error Msg = %s", ret, error_msg);
return;
}

// Get connection from the connection pool.
// This method will return connection is free or make new connection and return it.
// In case of error, error code of value < 0 is returned and error_msg (max 1014) is set with error message
// Few possible errors are:
// All connections are busy
// Error in making connection
// If actual connection is made, then transaction is started with name passed if it is not NULL or empty
// If connection fails, then transaction is ended with <TxName>Error<JMSErrorCode>. For example, TIBCOProducerConnectError2012

if((jcid = ns_tibco_get_connection(jpid, "TIBCOProducerSSLConnect", error_msg)) < 0)
{
fprintf(stderr, "Error in getting Tibco connention. Error code = %d, Error Msg = %s", jcid, error_msg);
return;
}

//This api will set any custom header in message
//ns_tibco_set_custom_header(jcid, error_msg, header_name, value_type, header_value);
// Put message in the JMS queue/topic using connection taken using get connection API
// In case of error, error code of value < 0 is returned and error_msg (max 1014) is set with error message
// Few possible errors are:
// Connection closed by JMS server
// Invalid connection ID passed
// Transaction is started with name passed if it is not NULL or empty
// If put fails, then transaction is ended with <TxName>Error<JMSErrorCode>. For example, TIBCOPutMsgError2012
if((ret = ns_tibco_put_msg(jcid, msg, msg_len, "TIBCOPutMsg", error_msg)) < 0)
{
fprintf(stderr, "Error in putting message using Tibco connention. Error code = %d, Error Msg = %s", ret, error_msg);
}

//This api will release the  connection from connection pool and it should be called every time so that another user can reuse it.
if((ret = ns_tibco_release_connection(jcid, error_msg)) < 0)
{
fprintf(stderr, "Error in releasing Tibco connection.Error code = %d, Error Msg = %s", ret, error_msg);
return;
}

/*
//This api will close connection with Tibco server and it should not be called every time as it will impact performance. It should be called at the end of test.
if((ret = ns_tibco_close_connection(jcid, "TIBCOProducerSSLClose" , error_msg)) < 0)
{
fprintf(stderr, "Error in closing Tibco  connection %d", ret);
return;
}

*/
// Page think time in case of adding delay for next session
ns_page_think_time(0.0);
