Qore oracle Module  3.3
Qore::Oracle::AQQueue Class Reference

Implementation of AQ Queue. More...

Public Member Functions

bool commit ()
 Commit the transaction. More...
 
 constructor (string queueName, string typeName, string desc)
 Construct a queue object for posting/getting messages from a datasource description string. More...
 
 constructor (string queueName, string typeName, hash opts)
 Construct a queue object for posting/getting messages. More...
 
 copy ()
 Copying objects of this class is not supported, an exception will be thrown. More...
 
 destructor ()
 stops any active subscriptions and destroys the object
 
*AQMessage getMessage (softint timeout=0)
 Get message from queue. More...
 
nothing onAsyncMessage ()
 Automatically called when a new message is received on the queue when there is an active subscription. More...
 
nothing onSubscriptionLost ()
 Automatically called when the connection is externally disconnected. More...
 
nothing post (AQMessage msg)
 Post the AQMessage into the queue. More...
 
nothing post (hash msg)
 Post the plain Oracle object hash into the queue. More...
 
bool rollback ()
 Rollback the transaction. More...
 
nothing startSubscription (int port=0, int timeout=0)
 Subscribe for asynchronous messages notifications. More...
 
nothing stopSubscription ()
 Unsubscribe for asynchronous messages notifications. More...
 

Detailed Description

Implementation of AQ Queue.

Restrictions:
Qore::PO_NO_DATABASE

AQ messages notification with Oracle Client 10gR2 or above

Member Function Documentation

◆ commit()

bool Qore::Oracle::AQQueue::commit ( )

Commit the transaction.

Confirm all posted or fetched messages.

◆ constructor() [1/2]

Qore::Oracle::AQQueue::constructor ( string  queueName,
string  typeName,
string  desc 
)

Construct a queue object for posting/getting messages from a datasource description string.

Parameters
queueNamea mandatory name of the queue in the database
typeNamea mandatory name of the type for this queue in the DB
desca datasource description string in the format that can be parsed by parse_datasource()
Exceptions
AQQUEUE-CONSTRUCTOR-ERRORinvalid arguments to constructor
DBI-OPTION-ERRORunknown or unsupported option passed to the Oracle driver

◆ constructor() [2/2]

Qore::Oracle::AQQueue::constructor ( string  queueName,
string  typeName,
hash  opts 
)

Construct a queue object for posting/getting messages.

Parameters
queueNamea mandatory name of the queue in the database
typeNamea mandatory name of the type for this queue in the DB
optsa hash giving parameters for the new dedicated connection to the Oracle database server with the following possible keys (the "type" key is optional, but if present, must be "oracle"):
  • type: (*string) The name of the database driver to use; this key is optional, but if present must be "oracle" or an exception will be raised
  • user: (string) The user name for the new connection
  • pass: (string) The password for the new connection
  • db: (string) The database name for the new connection
  • charset: (*string) The Oracle-specific name of the character encoding to use for the new connection. If no value is passed for this parameter, then the Oracle character encoding corresponding to the default character encoding for the Qore process will be used instead.
  • host: (*string) The host name for the new connection
  • port: (softint) The port number for the new connection. If this key is present and is 0 then an exception will be raised.
  • options: (*hash) Any options for the new connection
Exceptions
AQQUEUE-CONSTRUCTOR-ERRORinvalid arguments to constructor
DBI-OPTION-ERRORunknown or unsupported option passed to the Oracle driver

◆ copy()

Qore::Oracle::AQQueue::copy ( )

Copying objects of this class is not supported, an exception will be thrown.

Exceptions
AQQUEUE-COPY-ERRORcopying AQQueue objects is not yet supported

◆ getMessage()

*AQMessage Qore::Oracle::AQQueue::getMessage ( softint  timeout = 0)

Get message from queue.

Parameters
timeoutthe timeout in seconds; 0 = no timeout
Return values
AQMessageor NOTHING if no message was available in the timeout period

◆ onAsyncMessage()

nothing Qore::Oracle::AQQueue::onAsyncMessage ( )

Automatically called when a new message is received on the queue when there is an active subscription.

A method which is called when there is a new message in the queue.

The default implementation throws an exception; this method must be overridden in subclasses to receive messages; use the AQQueue::getMessage() method to receive the message

Exceptions
AQQUEUE-ONASYNCMESSAGE-ERRORabstract implementation of AQQueue::onAsyncMessage called

◆ onSubscriptionLost()

nothing Qore::Oracle::AQQueue::onSubscriptionLost ( )

Automatically called when the connection is externally disconnected.

A method which is called when there is a subscription but the periodical check for a live connection fails.

The default implementation throws an exception; this method must be overridden in subclasses to receive messages; use the AQQueue::startSubscription() method to restore the subscription for example

Exceptions
AQQUEUE-ONSUBSCRIPTIONLOST-ERRORabstract implementation of AQQueue::onSubscriptionLost called

◆ post() [1/2]

nothing Qore::Oracle::AQQueue::post ( AQMessage  msg)

Post the AQMessage into the queue.

Parameters
msga AQMessage instance

◆ post() [2/2]

nothing Qore::Oracle::AQQueue::post ( hash  msg)

Post the plain Oracle object hash into the queue.

Parameters
msga qore hash (Oracle object)

The hash/object will use default message properties. Use post() with an AQMessage instance if you need to modify the message defaults.

◆ rollback()

bool Qore::Oracle::AQQueue::rollback ( )

Rollback the transaction.

Rollback all posted or fetched messages.

◆ startSubscription()

nothing Qore::Oracle::AQQueue::startSubscription ( int  port = 0,
int  timeout = 0 
)

Subscribe for asynchronous messages notifications.

Parameters
portan optional non-negative port number (0 = use the default port)
timeoutan optional timeout value in seconds; any positive value in seconds is valid. The value 0 is accepted and means that it does not wait for messages and returns immediately if no messages are available. The value -1 is accepted and means it waits for ever (until a message is available in the queue)
Exceptions
AQQUEUE-ERRORport or timeout value invalid; subscription already active for this object

◆ stopSubscription()

nothing Qore::Oracle::AQQueue::stopSubscription ( )

Unsubscribe for asynchronous messages notifications.

If no subscription is active, no action is taken

Exceptions
AQQUEUE-ERRORoracle error stopping the subscription

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