Article 09 – Application Integration: Event-Driven Architectures and Messaging

The Unified Pub/Sub vs. Specialized Service Paradigm

In Google Cloud, Cloud Pub/Sub is the default messaging engine. It is a highly scalable, unified service that handles both real-time stream processing (ordered, log-based ingestion) and simple point-to-point application integration (pull-based queue work). Whether you are ingestion-heavy clickstream logging or trying to decouple two microservices, you default to Pub/Sub.

Oracle Cloud Infrastructure (OCI) splits these use cases into specialized services.

Instead of a single, catch-all messaging service, OCI offers distinct services optimized for stream processing, queueing, notifications, and event routing. This allows architects to select the exact tooling required, optimizing both cost and operational complexity.

OCI Messaging and Eventing Portfolio

OCI’s application integration portfolio is categorized into four primary services:

1. OCI Streaming (Kafka-Compatible)

A high-throughput, log-based, partitioned messaging service designed for real-time ingestion of continuous streams of data.
* API Compatibility: OCI Streaming is fully compatible with the Apache Kafka API, allowing you to use existing Kafka SDKs, connectors, and tools (like Kafka Connect) without rewriting your application code.
* Use Case: Ingesting high-volume log files, web clickstreams, or IoT sensor data.
* GCP Equivalent: GCP Pub/Sub (specifically for ordered, replayable stream ingestion) or managed Kafka.

2. OCI Queue (Decoupling Services)

A managed message queue service designed for point-to-point microservice communication.
* State Management: Unlike OCI Streaming—where consumers manage their own offsets—OCI Queue manages message states directly. It supports message locking, visibility timeouts (temporarily hiding a message while a worker processes it), and Dead Letter Queues (DLQs) for handling failed messages.
* Use Case: Decoupling transactional microservices (e.g., sending an order request to a fulfillment worker).
* GCP Equivalent: GCP Pub/Sub (with pull subscriptions) or Cloud Tasks.

3. OCI Notifications (ONS)

A highly available, low-latency publish/subscribe broadcast service using a push model.
* Delivery Channels: You publish a message to an ONS Topic, and the service pushes it to subscribers via email, SMS, PagerDuty, Slack, or HTTP/HTTPS webhooks (to trigger external APIs).
* Use Case: Broadcasting system alerts, notifying mobile clients, or triggering external webhooks.
* GCP Equivalent: GCP Pub/Sub (with push subscriptions).

4. OCI Events

A serverless event routing service that monitors changes in your OCI resources.
* CloudEvents Standard: OCI Events complies with the CloudEvents standard managed by the Cloud Native Computing Foundation (CNCF).
* Trigger and Action: When a resource state changes (e.g., a file is uploaded to Object Storage, or an Autonomous Database backup completes), OCI Events evaluates the resource metadata against a rule and routes the event payload to a target (like OCI Functions, OCI Streaming, or ONS).
* GCP Equivalent: GCP Eventarc.

The integration flow of these services is illustrated below, showing how events trigger streaming, notifications, or queue-based workloads:

OCI Application Integration and Eventing Architecture

Designing an Event-Driven Flow

To illustrate how these services collaborate, imagine an application that processes raw video uploads:
1. A user uploads a video file to an OCI Object Storage bucket.
2. The upload triggers an OCI Event matching the rule: Object - Create.
3. The Event service routes the JSON payload to OCI Notifications (ONS).
4. ONS sends an SMS alert to administrators and pushes the payload to an OCI Function via an HTTPS webhook.
5. The OCI Function starts a transcoding process and pushes progress logs to OCI Streaming for real-time dashboard analytics.

Declarative Provisioning via Terraform

Instead of writing manual CLI commands, you configure OCI application integration and messaging services using Terraform. The following configuration defines an OCI Stream (Kafka-compatible), an ONS Notification Topic, and an email Subscription:

# 1. Define the OCI Stream
resource "oci_streaming_stream" "clickstream_log" {
  compartment_id     = "ocid1.compartment.oc1..aaaaaaaadevvv..."
  name               = "Clickstream-Log"
  partitions         = 2
  retention_in_hours = 24
}

# 2. Define the ONS Notification Topic
resource "oci_ons_notification_topic" "system_alerts" {
  compartment_id = "ocid1.compartment.oc1..aaaaaaaadevvv..."
  name           = "SystemAlerts"
}

# 3. Define the ONS Subscription (EMAIL endpoint)
resource "oci_ons_subscription" "admin_email_sub" {
  compartment_id = "ocid1.compartment.oc1..aaaaaaaadevvv..."
  topic_id       = oci_ons_notification_topic.system_alerts.id
  protocol       = "EMAIL"
  endpoint       = "[email protected]"
}

By separating messaging workloads into specialized streaming, queueing, and notification layers and declaring these configurations using Terraform, you can build highly optimized, decoupled architectures that handle massive scale without paying for unused capabilities.