Pub/Sub Input

REST API service that receives ERP data and publishes messages to Google Cloud Pub/Sub topics.

Purpose

  • Receives ERP data via REST endpoints

  • Validates incoming data

  • Publishes messages to Pub/Sub topics with metadata attributes

  • Provides cloud-native messaging integration

Prerequisites

This application requires an existing Google Cloud Platform project with Pub/Sub. It does not include GCP project setup or topic creation.

Ensure:

  • GCP project with Pub/Sub API enabled

  • Service account with roles/pubsub.publisher role

  • Required topics are created

  • Service account JSON key available

Configuration

Application Settings

See [application.yml](src/main/resources/application.yml) for full configuration.

Key settings: - GCP Project ID: Target GCP project - Main topic: Target topic for publishing messages - Credentials file: Path to service account key - Server configuration: Server port and context path - Actuator endpoints: Swagger UI, metrics and health

Spring Property Environment var Default value

erp-to-czz.project-id

ERP_TO_CZZ_PROJECT_ID

erp-to-czz

erp-to-czz.main-topic

ERP_TO_CZZ_MAIN_TOPIC

erp-to-czz-input

erp-to-czz.credentials-file

ERP_TO_CZZ_CREDENTIALS_FILE

classpath:credentials/erp-to-czz-publish-key.json

Important Notes

  • Credentials file paths must include a resource prefix (file: or classpath:)

Message Publishing Flow

flowchart TD
    A[ERP System]
    B[REST API POST]
    C{JSON Valid?}
    D[Add Attributes]
    E[Pub/Sub Publisher<br/>Sync + Timeout 30s]
    F[Pub/Sub Topic]
    G[Error Response]

    A --> B
    B --> C
    C -->|Yes| D
    C -->|No| G
    D --> E
    E --> F
    E -->|Failed| G

    style A fill:none,stroke:#666,stroke-width:3px
    style B fill:none,stroke:#666,stroke-width:3px
    style C fill:none,stroke:#666,stroke-width:3px
    style D fill:none,stroke:#666,stroke-width:3px
    style E fill:none,stroke:#666,stroke-width:3px
    style F fill:none,stroke:#666,stroke-width:3px
    style G fill:none,stroke:#666,stroke-width:3px