/*
 * Commit the current unit of work for this QueueManager instance
 *
 * Note:
 * * commit will have no effect if all put and get operations were performed
 *   without specifying :sync => true
 *
 * Returns:
 * * true : On Success
 * * false: On Failure
 *
 *   comp_code and reason_code are also updated.
 *   reason will return a text description of the reason_code
 *
 * Throws:
 * * WMQ::WMQException if comp_code != MQCC_OK
 * * Except if :exception_on_error => false was supplied as a parameter
 *   to QueueManager.new
 */
VALUE QueueManager_commit(VALUE self)
{
    PQUEUE_MANAGER pqm;
    Data_Get_Struct(self, QUEUE_MANAGER, pqm);

    if(pqm->trace_level) printf ("WMQ::QueueManager#commit() Queue Manager Handle:%ld\n", pqm->hcon);

    pqm->MQCMIT(pqm->hcon, &pqm->comp_code, &pqm->reason_code);

    if(pqm->trace_level) printf("WMQ::QueueManager#commit() MQCMIT completed with reason:%s\n", wmq_reason(pqm->reason_code));

    if (pqm->comp_code != MQCC_OK)
    {
        if (pqm->exception_on_error)
        {
            VALUE name = rb_iv_get(self,"@name");
            name = StringValue(name);

            rb_raise(wmq_exception,
                     "WMQ::QueueManager#commit(). Error commiting changes to Queue Manager:%s, reason:%s",
                     RSTRING(name)->ptr,
                     wmq_reason(pqm->reason_code));
        }
        return Qfalse;
    }

    return Qtrue;
}