Using advanced queueing v8.0.5.1
EDB Postgres Advanced Server advanced queueing provides message queueing and message processing for the EDB Postgres Advanced Server database. User-defined messages are stored in a queue. A collection of queues is stored in a queue table. Create a queue table before creating a queue that depends on it.
On the server side, procedures in the DBMS_AQADM
package create and manage message queues and queue tables. Use the DBMS_AQ
package to add messages to or remove messages from a queue or register or unregister a PL/SQL callback procedure. For more information about DBMS_AQ
and DBMS_AQADM
, see DBMS_AQ.
On the client side, the application uses the EDB.NET driver to enqueue and dequeue messages.
Enqueueing or dequeueing a message
For more information about using EDB Postgres Advanced Server's advanced queueing functionality, see Built-in packages.
Server-side setup
To use advanced queueing functionality on your .NET application, you must first create a user-defined type, queue table, and queue, and then start the queue on the database server. Invoke EDB-PSQL and connect to the EDB Postgres Advanced Server host database. Use the following SPL commands at the command line.
Creating a user-defined type
To specify a RAW data type, create a user-defined type. This example shows creating a user-defined type named myxml
:
Creating the queue table
A queue table can hold multiple queues with the same payload type. This example shows creating a table named MSG_QUEUE_TABLE
:
Creating the queue
This example shows creating a queue named MSG_QUEUE
in the table MSG_QUEUE_TABLE
:
Starting the queue
Once the queue is created, invoke the following SPL code at the command line to start a queue in the EDB database:
Client-side example
Once you've created a user-defined type, the queue table, and the queue, start the queue. Then, you can enqueue or dequeue a message using EDB .Net drivers.
Enqueue a message
To enqueue a message on your .NET application, you must:
- Import the
EnterpriseDB.EDBClient
namespace. - Pass the name of the queue and create the instance of the
EDBAQQueue
. - Create the enqueue message and define a payload.
- Call the
queue.Enqueue
method.
The following code shows using the queue.Enqueue
method.
Note
This code creates the message and serializes it. This is example code and doesn't compile if copied as it is. You must serialize the message as XML.
Dequeueing a message
To dequeue a message on your .NET application, you must:
- Import the
EnterpriseDB.EDBClient
namespace. - Pass the name of the queue and create the instance of the
EDBAQQueue
. - Call the
queue.Dequeue
method.
Note
The following code creates the message and serializes it. This is example code and doesn't compile if copied as it is. You must serialize the message as XML.
EDBAQ classes
The following EDBAQ classes are used in this application.
EDBAQDequeueMode
The EDBAQDequeueMode
class lists all the dequeuer modes available.
Value | Description |
---|---|
Browse | Reads the message without locking. |
Locked | Reads and gets a write lock on the message. |
Remove | Deletes the message after reading. This is the default value. |
Remove_NoData | Confirms receipt of the message. |
EDBAQDequeueOptions
The EDBAQDequeueOptions
class lists the options available when dequeuing a message.
Property | Description |
---|---|
ConsumerName | The name of the consumer for which to dequeue the message. |
DequeueMode | Set from EDBAQDequeueMode . It represents the locking behavior linked with the dequeue option. |
Navigation | Set from EDBAQNavigationMode . It represents the position of the message to fetch. |
Visibility | Set from EDBAQVisibility . It represents whether the new message is dequeued as part of the current transaction. |
Wait | The wait time for a message as per the search criteria. |
Msgid | The message identifier. |
Correlation | The correlation identifier. |
DeqCondition | The dequeuer condition. It's a Boolean expression. |
Transformation | The transformation to apply before dequeuing the message. |
DeliveryMode | The delivery mode of the dequeued message. |
EDBAQEnqueueOptions
The EDBAQEnqueueOptions
class lists the options available when enqueuing a message.
Property | Description |
---|---|
Visibility | Set from EDBAQVisibility . It represents whether the new message is enqueued as part of the current transaction. |
RelativeMsgid | The relative message identifier. |
SequenceDeviation | The sequence when to dequeue the message. |
Transformation | The transformation to apply before enqueuing the message. |
DeliveryMode | The delivery mode of the enqueued message. |
EDBAQMessage
The EDBAQMessage
class lists a message to enqueue/dequeue.
Property | Description |
---|---|
Payload | The actual message to queue. |
MessageId | The ID of the queued message. |
EDBAQMessageProperties
The EDBAQMessageProperties
lists the message properties available.
Property | Description |
---|---|
Priority | The priority of the message. |
Delay | The duration after which the message is available for dequeuing, in seconds. |
Expiration | The duration for which the message is available for dequeuing, in seconds. |
Correlation | The correlation identifier. |
Attempts | The number of attempts taken to dequeue the message. |
RecipientList | The recipients list that overthrows the default queue subscribers. |
ExceptionQueue | The name of the queue to move the unprocessed messages to. |
EnqueueTime | The time when the message was enqueued. |
State | The state of the message while dequeued. |
OriginalMsgid | The message identifier in the last queue. |
TransactionGroup | The transaction group for the dequeued messages. |
DeliveryMode | The delivery mode of the dequeued message. |
EDBAQMessageState
The EDBAQMessageState
class represents the state of the message during dequeue.
Value | Description |
---|---|
Expired | The message is moved to the exception queue. |
Processed | The message is processed and kept. |
Ready | The message is ready to be processed. |
Waiting | The message is in waiting state. The delay isn't reached. |
EDBAQMessageType
The EDBAQMessageType
class represents the types for payload.
Value | Description |
---|---|
Raw | The raw message type. Note: Currently, this payload type isn't supported. |
UDT | The user-defined type message. |
XML | The XML type message. Note: Currently, this payload type isn't supported. |
EDBAQNavigationMode
The EDBAQNavigationMode
class represents the different types of navigation modes available.
Value | Description |
---|---|
First_Message | Returns the first available message that matches the search terms. |
Next_Message | Returns the next available message that matches the search items. |
Next_Transaction | Returns the first message of next transaction group. |
EDBAQQueue
The EDBAQQueue
class represents a SQL statement to execute DMBS_AQ
functionality on a PostgreSQL database.
Property | Description |
---|---|
Connection | The connection to use. |
Name | The name of the queue. |
MessageType | The message type that's enqueued/dequeued from this queue, for example EDBAQMessageType.Udt . |
UdtTypeName | The user-defined type name of the message type. |
EnqueueOptions | The enqueue options to use. |
DequeuOptions | The dequeue options to use. |
MessageProperties | The message properties to use. |
EDBAQVisibility
The EDBAQVisibility
class represents the visibility options available.
Value | Description |
---|---|
Immediate | The enqueue/dequeue isn't part of the ongoing transaction. |
On_Commit | The enqueue/dequeue is part of the current transaction. |
Note
- To review the default options for these parameters, see DBMS_AQ.
- EDB advanced queueing functionality uses user-defined types for calling enqueue/dequeue operations.
Server Compatibility Mode=NoTypeLoading
can't be used with advanced queueing becauseNoTypeLoading
doesn't load any user-defined types.
- On this page
- Enqueueing or dequeueing a message
- EDBAQ classes