Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions site/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Dependencies
/node_modules

# Production
/build

# Generated files
.docusaurus
.cache-loader

# Misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
5 changes: 5 additions & 0 deletions site/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.PHONY: docs-build
docs:
rm -rf ../docs
npm run build
cp -r build ../docs
38 changes: 38 additions & 0 deletions site/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Website

This website is built using [Docusaurus](https://docusaurus.io/), a modern static website generator.

The `content` directory contains the built, static site.

Requirements:
- latest version of Node.js

## Installation

```bash
npm
```

## Local Development

```bash
npm start
```

This command starts a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

## Build

```bash
npm run build
```

## Versioning

```bash
npm run docusaurus docs:version 1.1.0
```

Then, add the version to the `docusaurus.config.ts` versions navbar.

This command generates static content into the `build` directory and can be served using any static contents hosting service.
8 changes: 8 additions & 0 deletions site/docs/database/_category_.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"label": "Oracle AI Database Starters",
"position": 2,
"link": {
"type": "generated-index",
"description": "Spring Boot starters for Oracle AI Database connections, messaging, JSON features, and Kafka-compatible TxEventQ access."
}
}
131 changes: 131 additions & 0 deletions site/docs/database/aq-jms.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
---
title: AQ/JMS
sidebar_position: 3
---

# Spring JMS with TxEventQ

The AQ/JMS starter provides Spring Boot support for Oracle Transactional Event Queues (TxEventQ) as a [Spring JMS provider](https://spring.io/guides/gs/messaging-jms).

## Dependency Coordinates

To use Oracle AI Database for JMS, include the oracle-spring-boot-starter-aqjms and spring-boot-starter-jdbc dependencies in your project:

```xml
<dependency>
<groupId>com.oracle.database.spring</groupId>
<artifactId>oracle-spring-boot-starter-aqjms</artifactId>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
```

## Database Permissions

The database JMS user should have at least the following permissions to produce and consume messages with Oracle AI Database:

```sql
grant aq_user_role to testuser;
grant execute on dbms_aq to testuser;
grant execute on dbms_aqadm to testuser;
grant execute ON dbms_aqin TO testuser;
grant execute ON dbms_aqjms TO testuser;
```

## Create a JMS Queue or Topic

JMS applications must have an existing queue or topic. You may create this from your application code, or do so with a PL/SQL statement. The following snippet creates a JMS queue named `MY_JMS_QUEUE` in the `TESTUSER` schema:

```sql
begin
dbms_aqadm.create_transactional_event_queue(
queue_name => 'TESTUSER.MY_JMS_QUEUE',
-- False -> JMS Queue. True -> JMS Topic
multiple_consumers => false
);

-- start the TEQ
dbms_aqadm.start_queue(
queue_name => 'TESTUSER.MY_JMS_QUEUE'
);
end;
/
```

## Database Connection

JMS uses a standard Spring Boot datasource JDBC connection. Oracle AI Database JMS producers and consumers will use autowired Spring JDBC datasource:

```yaml
spring:
datasource:
username: ${USERNAME}
password: ${PASSWORD}
url: ${JDBC_URL}
driver-class-name: oracle.jdbc.OracleDriver
type: oracle.ucp.jdbc.PoolDataSourceImpl
oracleucp:
initial-pool-size: 1
min-pool-size: 1
max-pool-size: 30
connection-pool-name: TxEventQSample
connection-factory-class-name: oracle.jdbc.pool.OracleDataSource
```

## Produce and consume messages

You can use Spring JMS abstractions like `JMSTemplate`, `JMSListener`, and `JMSClient` in your Spring Boot applications with Oracle AI Database.

### Producer Example with `JMSTemplate`

```java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.jms.core.JmsTemplate;

@Service
public class Producer {

private static final Logger log = LoggerFactory.getLogger(Producer.class);

JmsTemplate jmsTemplate;

@Value("${txeventq.topic.name}")
private String topic;

public Producer(JmsTemplate jmsTemplate) {
this.jmsTemplate = jmsTemplate;
}

public void sendMessageToTopic(String message)
{
jmsTemplate.convertAndSend(topic,message);
log.info("Sending message: {} to topic {}", message, topic);
}
}
```

### Consumer Example with `@JMSListener`

```java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Service;

@Service
public class Consumer {

private static final Logger log = LoggerFactory.getLogger(Consumer.class);

@JmsListener(destination = "${txeventq.topic.name}")
public void receiveMessage(String message) {
log.info("Received message: {}", message);
}
}
```
95 changes: 95 additions & 0 deletions site/docs/database/json-collections.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: JSON Collections and Duality Views
sidebar_position: 4
---

# JSON Collections and Duality Views

The JSON starter provides dependencies and utilities for working with Oracle AI Database JSON data, including the JSON data type, JSON Relational Duality Views, and [Oracle's efficient serialized JSON format, OSON](https://medium.com/db-one/a-deep-dive-into-binary-json-formats-oson-e3190e5e9eb0).

## Dependency Coordinates

```xml
<dependency>
<groupId>com.oracle.database.spring</groupId>
<artifactId>oracle-spring-boot-starter-json-collections</artifactId>
</dependency>
```

## JSONB Conversion

The `JSONB` bean converts Java objects to and from OSON using `fromOSON` and `toOSON`. `InputStream`, `JsonParser`, `ByteBuffer`, and `byte[]` are supported as OSON input types.

```java
@Autowired
JSONB jsonb;

// byte[], JsonParser, and ByteBuffer also supported as input types
Student student = jsonb.fromOSON(inputStream, Student.class);
byte[] bytes = jsonb.toOSON(student);
```

## Mapping OSON Rows

`JSONBRowMapper` converts OSON database columns to Java objects:

```java
RowMapper<Student> rowMapper = new JSONBRowMapper<>(this.jsonb, Student.class);

List<Student> students = jdbcTemplate.query(con -> {
PreparedStatement ps = con.prepareStatement("""
select * from students_dv v
where v.data.first_name = ?
and v.data.last_name = ?
""");
ps.setString(1, firstName);
ps.setString(2, lastName);
return ps;
}, rowMapper);
```

By default, the first column is selected as the JSON column. You may customize this when instantiating the `JSONBRowMapper`:

```java
RowMapper<Student> rowMapper = new JSONBRowMapper<>(
this.jsonb,
Student.class,
2 // column number of OSON data
);
```

## OSON Kafka Serializers

Spring Boot applications that mix OKafka APIs with OSON data may benefit from using OSON as the message serialization format. This is particularly useful when you're already using OSON as the storage format - messages sent as OSON may be inserted into a table using Oracle's JSON type without any further serialization.

The `OSONKafkaSerializationFactory` bean provides factory methods for kafka-java serializers and deserializers that allow you to send events in OSON format.

### Consumer Deserializer

```java
@Autowired
private OSONKafkaSerializationFactory osonKafkaSerializationFactory;

Deserializer<String> keyDeserializer = new StringDeserializer();
Deserializer<Sensor> valueDeserializer = osonKafkaSerializationFactory.createDeserializer(Sensor.class);
return new KafkaConsumer<>(props, keyDeserializer, valueDeserializer);
```

### Producer Serializer

```java
@Autowired
private OSONKafkaSerializationFactory osonKafkaSerializationFactory;


Serializer<String> keySerializer = new StringSerializer();
Serializer<Sensor> valueSerializer = osonKafkaSerializationFactory.createSerializer();
return new KafkaProducer<>(props, keySerializer, valueSerializer);
```

The Kafka/OSON classes will only be autowired if `kafka-clients` is on the classpath.

## Learn by example

- [Spring JDBC with JSON Relational Duality Views](https://github.com/oracle/spring-cloud-oracle/tree/main/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-duality)
- [JSON Event Streaming](https://github.com/oracle/spring-cloud-oracle/tree/main/database/starters/oracle-spring-boot-starter-samples/oracle-spring-boot-sample-json-events)
Loading
Loading