Class: OracleDB::Queue

Inherits:
Object
  • Object
show all
Defined in:
ext/oracledb/rboradb_aq.c

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Object



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
# File 'ext/oracledb/rboradb_aq.c', line 416

static VALUE queue_initialize(int argc, VALUE *argv, VALUE self)
{
    Queue_t *queue = To_Queue(self);
    VALUE conn, name, payload_type;
    rbOraDBConn *dconn;
    dpiObjectType *objtype = NULL;

    rb_scan_args(argc, argv, "21", &conn, &name, &payload_type);
    dconn = rboradb_get_dconn(conn);
    ExportString(name);
    if (!NIL_P(payload_type)) {
        objtype = rboradb_to_dpiObjectType(payload_type);
    }
    RBORADB_INIT(queue, dconn);
    queue->payload_objtype = objtype;
    if (queue->payload_objtype) {
        dpiObjectType_addRef(queue->payload_objtype);
    }
    if (dpiConn_newQueue(dconn->handle, RSTRING_PTR(name), RSTRING_LEN(name), objtype, &queue->handle) != DPI_SUCCESS) {
        rboradb_raise_error(dconn->ctxt);
    }
    return Qnil;
}

Instance Method Details

#deq_many(maxnum) ⇒ Object



454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
# File 'ext/oracledb/rboradb_aq.c', line 454

static VALUE queue_deq_many(VALUE self, VALUE maxnum)
{
    Queue_t *queue = To_Queue(self);
    uint32_t idx, num_props = NUM2UINT(maxnum);
    VALUE tmp_buf;
    dpiMsgProps **handles = RB_ALLOCV_N(dpiMsgProps *, tmp_buf, num_props);
    VALUE ary;

    if (rbOraDBQueue_deqMany(queue->dconn->handle, queue->handle, &num_props, handles) != DPI_SUCCESS) {
        RBORADB_RAISE_ERROR(queue);
    }
    ary = rb_ary_new_capa(num_props);
    for (idx = 0; idx < num_props; idx++) {
        rb_ary_push(ary, msg_props_new(handles[idx], queue->dconn, queue->payload_objtype));
    }
    RB_ALLOCV_END(tmp_buf);
    return ary;
}

#deq_oneObject



473
474
475
476
477
478
479
480
481
482
# File 'ext/oracledb/rboradb_aq.c', line 473

static VALUE queue_deq_one(VALUE self)
{
    Queue_t *queue = To_Queue(self);
    dpiMsgProps *handle;

    if (rbOraDBQueue_deqOne(queue->dconn->handle, queue->handle, &handle) != DPI_SUCCESS) {
        RBORADB_RAISE_ERROR(queue);
    }
    return msg_props_new(handle, queue->dconn, queue->payload_objtype);
}

#deq_optionsObject



524
525
526
527
528
529
530
531
532
533
# File 'ext/oracledb/rboradb_aq.c', line 524

static VALUE queue_deq_options(VALUE self)
{
    Queue_t *queue = To_Queue(self);
    dpiDeqOptions *handle;

    if (dpiQueue_getDeqOptions(queue->handle, &handle) != DPI_SUCCESS) {
        RBORADB_RAISE_ERROR(queue);
    }
    return deqopts_new(handle, queue->dconn);
}

#enq_many(props) ⇒ Object



484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
# File 'ext/oracledb/rboradb_aq.c', line 484

static VALUE queue_enq_many(VALUE self, VALUE props)
{
    Queue_t *queue = To_Queue(self);
    uint32_t idx, num_props;
    VALUE tmp_buf;
    dpiMsgProps **handles;

    Check_Type(props, T_ARRAY);
    num_props = RARRAY_LEN(props);
    handles = RB_ALLOCV_N(dpiMsgProps *, tmp_buf, num_props);
    for (idx = 0; idx < num_props; idx++) {
        handles[idx] = To_MsgProps(props)->handle;
    }
    if (rbOraDBQueue_enqMany(queue->dconn->handle, queue->handle, num_props, handles) != DPI_SUCCESS) {
        RBORADB_RAISE_ERROR(queue);
    }
    RB_ALLOCV_END(tmp_buf);
    return Qnil;
}

#enq_one(props) ⇒ Object



504
505
506
507
508
509
510
511
512
513
# File 'ext/oracledb/rboradb_aq.c', line 504

static VALUE queue_enq_one(VALUE self, VALUE props)
{
    Queue_t *queue = To_Queue(self);
    MsgProps_t *mp = To_MsgProps(props);

    if (rbOraDBQueue_enqOne(queue->dconn->handle, queue->handle, mp->handle) != DPI_SUCCESS) {
        RBORADB_RAISE_ERROR(queue);
    }
    return Qnil;
}

#enq_optionsObject



544
545
546
547
548
549
550
551
552
553
# File 'ext/oracledb/rboradb_aq.c', line 544

static VALUE queue_enq_options(VALUE self)
{
    Queue_t *queue = To_Queue(self);
    dpiEnqOptions *handle;

    if (dpiQueue_getEnqOptions(queue->handle, &handle) != DPI_SUCCESS) {
        RBORADB_RAISE_ERROR(queue);
    }
    return enq_options_new(handle, queue->dconn);
}