Qorus Integration Engine®  4.0.3_git
OMQ::DbRemote Class Reference

A high level API for remote system.sqlutil service calls. More...

Public Member Methods

 constructor (string remote, string dsname, *hash opts)
 constructor taking a string giving the name of the remote connection for the remote server More...
 
 constructor (QorusSystemRestHelper remote, string dsname, *hash opts)
 constructor taking an OMQ::QorusSystemRestHelper object for the remote connection More...
 
 destructor ()
 Just check if the transaction finished correctly.
 
 beginTransaction ()
 starts or continues a remote transaction More...
 
string datasourceName ()
 returns the remote datasource name specified in constructor
 
OMQ::StreamConfig config ()
 returns the configuration object
 
 commit ()
 commits a remote transaction
 
 rollback (bool action=AbstractParallelStream::DO_DISCONNECT)
 Rollback remote transaction. More...
 
 disconnect ()
 Disconnects the connection.
 

Detailed Description

A high level API for remote system.sqlutil service calls.

DbRemote provides a high level API for the system.sqlutil service in remote Qorus instances. Use it for single updates, deletes, inserts, and/or schema management.

DbRemote wraps all available system.sqlutil service methods with the following changes in service methods API:

  • datasource argument is passed to OMQ::DbRemote::constructor() and it's not used in method calls
  • the transaction is started when the DbRemote object is constructed and must be committed or rolled back explicitly.
Warning
Use OMQ::DbRemoteSend and OMQ::DbRemoteReceive for inserting and fetching large amount of data. These classes are optimized for high volume data. Any use of e.g. DbRemote::select() will store all resulting data in the memory and it will be transferred in a single call.

DbRemote API calls

This class does not have any of its own methods; all method calls are redirected to system.sqlutil transparently.

In case of e.g. system.sqlutil.update with prototype:

int sqlutil.update(string ds, string table, hash set, *hash cond)

DbRemote::update alternative looks like this:

int DbRemote::update(string table, hash set, *hash cond)
Example of usage
QorusClient::init2();
DbRemote db("msepl-it", "omquser");
on_success db.commit();
on_error db.rollback();
any r = db.select("H3G_IT_SHIPPED_ITEMS");
printf("%N\n", r);
r = db.list_tables();
printf("%N\n", r);
r = db.insert("op_in_test", ("id" : 11));
printf("%N\n", r);

Member Function Documentation

◆ beginTransaction()

OMQ::DbRemote::beginTransaction ( )

starts or continues a remote transaction

This method is called from the constructor() automatically

◆ constructor() [1/2]

OMQ::DbRemote::constructor ( string  remote,
string  dsname,
*hash  opts 
)

constructor taking a string giving the name of the remote connection for the remote server

Parameters
remotea string giving the name of the remote connection for the remote server
dsnamea string with name of the remote datasource to use
optsoptional Streaming API Constructor Options as follows:
  • "timeout": an HTTP socket timeout value in milliseconds; used locally and in the remote for socket I/O and queue operations; default value: 5m
  • "loglevel": a default log level option for logging; see Log Levels for valid value
  • "no_remote_timeout": if True the "timeout" option will not be sent to the remote
Note
the explicit or default timeout value here overrides any socket I/O timeout set for the remote connection object

◆ constructor() [2/2]

OMQ::DbRemote::constructor ( QorusSystemRestHelper  remote,
string  dsname,
*hash  opts 
)

constructor taking an OMQ::QorusSystemRestHelper object for the remote connection

Parameters
remotean OMQ::QorusSystemRestHelper object
dsnamea string with name of the remote datasource to use
optsoptional Streaming API Constructor Options as follows:
  • "timeout": an HTTP socket timeout value in milliseconds; used locally and in the remote for socket I/O and queue operations; default value: 5m
  • "loglevel": a default log level option for logging; see Log Levels for valid value
  • "no_remote_timeout": if True the "timeout" option will not be sent to the remote
Note
the explicit or default timeout value here overrides any socket I/O timeout set for the remote connection object

◆ rollback()

OMQ::DbRemote::rollback ( bool  action = AbstractParallelStream::DO_DISCONNECT)

Rollback remote transaction.

Note
it's normally better to disconnect the connection if an error occurs rather than call rollback() when streaming because if a chunked transfer is interrupted, then HTTP calls will fail anyway, and the remote end will rollback the transaction in any case unless an explicit commit is executed
Parameters
actionan optional bool value to keep connection open or close the connection. Connection closing is the default
See also
DO_DISCONNECT
DONT_DISCONNECT
disconnect()

The documentation for this class was generated from the following file: