Push, Pull, and Customer Topic delivery¶
All job responses are delivered through Google Cloud Pub/Sub to your application. Depending on your infrastructure and architectural preferences, you can configure response delivery on a per-job-type basis using one of four delivery modes:
- pull: Modigie provisions a Cloud Pub/Sub pull subscription in the tenant project where your application actively pulls messages.
- push: Modigie provisions a Cloud Pub/Sub push subscription that delivers messages directly to an HTTPS webhook endpoint hosted by your application.
- both: Modigie provisions both pull and push subscriptions simultaneously.
- topic: Direct cross-project delivery to a customer-owned Cloud Pub/Sub topic hosted in your own Google Cloud project. See Customer-Owned Google Cloud Resources.
For each push subscription, you provide Modigie with the HTTPS endpoint URL where your application receives messages. For each pull subscription, Modigie provides the Google Cloud project ID and subscription ID where your application pulls messages. For topic delivery, you provide your Google Cloud project ID and topic ID.
Choose the optimal delivery mode¶
Review the comparison below to choose the best option for your use-case:
| Pull Subscription | Push Subscription | Customer-Owned Topic | |
|---|---|---|---|
| Use case | |||
| Hosting Project | Modigie tenant GCP project | Modigie tenant GCP project | Customer GCP project |
| Endpoints | Any authorized client calling Pub/Sub API. | HTTPS server with valid non-self-signed certificate. | Customer-managed pull/push subscriptions or event sinks. |
| Load balancing | Multiple subscribers share the same subscription. | Push endpoints can be load balancers. | Fully controlled by customer subscription topology. |
| Configuration | Handled by Modigie tenant-infra. | Provide endpoint URL in pushConfig. |
Provide projectId & topicId in responseTopic. |
| Flow control | Client controls rate of delivery via pull leasing and ack deadlines. | Pub/Sub automatically implements push flow control. | Configured by customer on their own subscriptions. |
| Modigie Tenant Subs | Provisioned automatically. | Provisioned automatically. | None (existing Modigie topics/subs destroyed). |
| Required IAM | Modigie Application Account | Modigie Application Account (JWT validation) | Grant roles/pubsub.publisher to Modigie Application Account |
Resources¶
- https://cloud.google.com/pubsub/docs/subscribe-best-practices
- https://cloud.google.com/pubsub/docs/subscriber
Push subscription¶
A Pub/Sub push subscription delivers messages to a specific HTTPS endpoint hosted by your application.
Modigie tenant push subscription delivers job responses to your application endpoint
Cloud Pub/Sub push subscription created in customer project attached to customer-owned response topic
- In Modigie-managed push mode, Cloud Pub/Sub signs all HTTPS requests to your endpoint with a JWT of the Application Account.
- Your application receives a request with the message payload and validates the JWT.
- Once your application processes the message, it returns an HTTP
200or204to acknowledge the message.
Authorization of push messages¶
Push subscriptions use authentication to protect your subscriber endpoint from unauthorized requests. The Pub/Sub service signs a JSON Web Token (JWT) and sends it in the Authorization header of the push request.
Your application is responsible for verifying that the JWT is signed by the expected service account:
- For Modigie-managed push subscriptions, verify the token is signed by your repository's Application Account.
- For push subscriptions on customer-owned topics, verify the token is signed by your own push service account.
Learn more:
- https://cloud.google.com/pubsub/docs/push
- https://cloud.google.com/pubsub/docs/authenticate-push-subscriptions
Push back-off¶
If a push subscriber sends too many negative acknowledgments (non-2xx responses), Pub/Sub starts delivering messages using a push back-off. During a push back-off, delivery pauses for between 100 milliseconds and 60 seconds before resuming.
https://cloud.google.com/pubsub/docs/push#push_backoff
Pull subscription¶
In pull mode, your application actively retrieves messages with job results from a Cloud Pub/Sub pull subscription:
Your application authenticates with the Modigie Application Account to pull job responses
Your application authenticates with its own service account to pull messages from your customer-owned topic
- For Modigie-managed subscriptions, your application's client library authenticates using the Application Account (via downloaded credentials or Workload Identity).
- For customer-owned topics, your application authenticates using your own Google Cloud service account with standard Application Default Credentials (ADC).
- Your application pulls a single message or batch of messages, processes the results, and acknowledges the message.
https://cloud.google.com/pubsub/docs/pull
Customer-Owned Topic delivery (mode: topic)¶
Enterprise customers can route job responses directly to a Cloud Pub/Sub topic in their own GCP project:
- Direct Cross-Project Delivery: Modigie publishes job responses directly to
projects/{projectId}/topics/{topicId}using the repository's dedicated Application Account. - Prerequisite IAM Role: You must grant
roles/pubsub.publisheron your topic to the Modigie Application Account (inpubsub-app-{REPO_SHORT_HASH}@{TENANT_PROJECT_ID}.iam.gserviceaccount.com). - Tenant Infrastructure Lifecycle: For job types using
mode: topic, Modigie tenant-infra does not create a response topic or subscriptions. Any existing Modigie-provisioned response topics and subscriptions for that job type will be destroyed. - Reversibility: You can revert to Modigie-managed pull or push subscriptions at any time by updating your repository's
ownerConfig.
For complete architectural details, IAM commands, and configuration examples, see Customer-Owned Google Cloud Resources.
Acknowledgment¶
It is critical that your subscriber acknowledges a message after its content has been processed and stored persistently. If your subscriber fails to acknowledge a message before the acknowledgment deadline expires, Pub/Sub will redeliver the message.
If you have high-latency subscribers, you might need to configure custom values for flow control and lease management. Please refer to https://cloud.google.com/pubsub/docs/flow-control and https://cloud.google.com/pubsub/docs/lease-management.
Info
A custom acknowledgement deadline can be configured between 10 seconds and 600 seconds.
Idempotency¶
It is critical that your subscriber is implemented with idempotent behavior. Every message is guaranteed to be delivered at least once to your subscriber. However, this also means that the same message can be delivered more than once, and your implementation must not produce undesirable side effects. A common strategy is to record the modigieJobRequestId of a message once processed, acknowledge the message, and on any duplicate delivery immediately acknowledge without re-processing.
No ordering¶
Your client must not make any assumptions about the ordering of job results. Each job request is handled independently. While job requests are enqueued in the order of creation, processing turnaround times vary significantly across individual jobs, and results may be delivered in a different order.
The diagram below illustrates that publishing job requests and delivering job results operate concurrently and without guaranteed ordering:
Job requests and responses are concurrent and not ordered
Batching¶
Similar to the publishing of job requests, the Pub/Sub Integration does not support batching multiple job results into a single message payload. However, if your client uses a pull subscription, it can pull multiple distinct messages in a single batch request to maximize network efficiency.