Skip to content

Commit

Permalink
JDBC - Advance Queuing update
Browse files Browse the repository at this point in the history
  • Loading branch information
nidhibhammar committed Sep 6, 2024
1 parent 0920771 commit e960e75
Showing 1 changed file with 19 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: "Using advanced queueing"
---

!!! Tip "New Feature "
!!! Tip "New Feature"
Advanced queueing is available in JDBC 42.3.2.1 and later.

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, and a collection of queues is stored in a queue table. You must first create a queue table before creating a queue that depends on it.
Expand All @@ -17,7 +17,13 @@ For more information about using EDB Postgres Advanced Server's advanced queuein

## Server-side setup

To use advanced queueing functionality on your JMS-based Java application, first create a user-defined type, queue table, and queue. Then start the queue on the database server. You can use either EDB-PSQL or EDB-JDBC JMS API in the Java application.
To use advanced queueing functionality on your JMS-based Java application perform following steps in EDB-PSQL or EDB-JDBC:

1. Create a user-defined message type, which may be one of the standard JMS message types. However, EDB JDBC also supports any user-defined types. These types will be covered in detail in the upcoming sections.
2. Create a queue table specifying the payload type. This type will typically be the one created in step 1.
3. Create a queue using the queue table created in the previous step.
4. Start the queue on the database server.
5. You have the option to use either EDB-PSQL or EDB-JDBC JMS API in your Java application.

### Using EDB-PSQL

Expand All @@ -28,7 +34,7 @@ Invoke EDB-PSQL and connect to the EDB Postgres Advanced Server host database. U
To specify a RAW data type, create a user-defined type. This example creates a user-defined type named as `mytype`.

```sql
CREATE TYPE mytype AS (code int, project TEXT);
CREATE OR REPLACE TYPE mytype AS (code INT, project TEXT, manager VARCHAR(10));
```

**Create the queue table**
Expand All @@ -48,7 +54,10 @@ END;
This example creates a queue named `MSG_QUEUE` in the table `MSG_QUEUE_TABLE`.

```sql
EXEC DBMS_AQADM.CREATE_QUEUE ( queue_name => 'MSG_QUEUE', queue_table => 'MSG_QUEUE_TABLE', comment => 'This queue contains pending messages.');
EXEC DBMS_AQADM.CREATE_QUEUE
(queue_name => 'MSG_QUEUE',
queue_table => 'MSG_QUEUE_TABLE',
comment => 'This queue contains pending messages.');
```

**Start the queue**
Expand All @@ -59,8 +68,13 @@ Once the queue is created, invoke the following SPL code at the command line to
EXEC DBMS_AQADM.START_QUEUE(queue_name => 'MSG_QUEUE');
commit;
```

### Using EDB-JDBC JMS API

!!!note "Tip"
The following sequence of steps is required only if you want to create message types, queue table and queue programmatically. If the message types, queue table, and queue are created using EDB-PSQL then you can use the standard JMS API.
!!!

The following JMS API calls perform the same steps performed using EDB-PSQL to:
- Connect to the EDB Postgres Advanced Server database
- Create the user-defined type
Expand All @@ -74,7 +88,7 @@ conn = (EDBJmsQueueConnection) edbJmsFact.createQueueConnection();

session = (EDBJmsQueueSession) conn.createQueueSession(true, Session.CLIENT_ACKNOWLEDGE);

String sql = "CREATE TYPE mytype AS (code int, project TEXT);";
String sql = "CREATE OR REPLACE TYPE mytype AS (code int, project TEXT);";
UDTType udtType = new UDTType(conn.getConn(), sql, "mytype");
Operation operation = new UDTTypeOperation(udtType);
operation.execute();
Expand Down

0 comments on commit e960e75

Please sign in to comment.