Article
· Aug 31 4m read

How to Integrate Google Cloud Pub/Sub with InterSystems IRIS: A Practical Guide

InterSystems IRIS is a powerful data platform, especially when it comes to healthcare (IRIS for Health, HealthShare), finance, and real-time applications. While it comes with a rich set of inbound/outbound adapters (Kafka, REST, HL7, JDBC, FTP, etc.), one common question is:

How do we integrate InterSystems IRIS with Google Cloud Pub/Sub?

As of today, IRIS doesn’t provide a native Pub/Sub adapter out of the box. But that doesn’t mean integration isn’t possible. In fact, with a little creativity, you can connect IRIS to Pub/Sub quite effectively. In this article, I’ll walk you through three practical approaches — with examples and trade-offs.

🔑 Why Pub/Sub with IRIS?

Google Cloud Pub/Sub is a global, real-time messaging service designed to handle event-driven data pipelines at scale. Think of it like Kafka-as-a-Service, but fully managed by Google.

Integrating it with IRIS means:

  • IRIS can consume real-time events from applications, IoT devices, or cloud services.
  • IRIS can publish updates (HL7/FHIR messages, financial transactions, IoMT data) back into Pub/Sub topics for further processing.
  • It enables hybrid-cloud interoperability without replacing your existing IRIS production architecture.

🛠️ Integration Methods

1. REST API + IRIS REST Adapter

Pub/Sub provides a full REST API. IRIS provides a REST Inbound and Outbound Adapter, which means you can:

  • Subscribe to messages by pulling from Pub/Sub using IRIS’s EnsLib.REST.Service.
  • Publish messages from IRIS to Pub/Sub using EnsLib.REST.Operation.

Example (simplified ObjectScript outbound call):

ClassMethod PublishToPubSub(topic As %String, message As %String) As %Status
{
    Set url="https://pubsub.googleapis.com/v1/projects/my-project/topics/" _ topic _ ":publish"
    Set payload = {
        "messages":[
            {"data":$zconvert($zconvert(message,"O","UTF8"),"O","BASE64")}
        ]
    }.%ToJSON()

    Set httprequest = ##class(%Net.HttpRequest).%New()
    Set httprequest.Https=1
    Do httprequest.SetHeader("Content-Type","application/json")
    Do httprequest.SetHeader("Authorization","Bearer " _ ##class(Utils.Auth).GetAccessToken())
    Do httprequest.EntityBody.Write(payload)
    Set sc = httprequest.Post(url)
    Quit sc
}

👉 Here, Utils.Auth.GetAccessToken() is a helper method to retrieve a Google OAuth token (required for Pub/Sub).


2. Bridge via Kafka or Cloud Run

Since IRIS has a Kafka adapter out of the box, one workaround is:

  • Pub/Sub → Kafka → IRIS: Use a lightweight connector (e.g., Confluent’s GCP Pub/Sub Kafka Connector).
  • This lets you leverage IRIS’s native Kafka support without custom code.

Another option is Google Cloud Run or Cloud Functions: deploy a small service that forwards Pub/Sub messages to IRIS over REST or TCP.


3. Native gRPC / Python Integration

Pub/Sub also provides gRPC and Python client libraries. IRIS supports embedded Python, so you can:

  • Write a Python class in IRIS that imports Google’s Pub/Sub library (google-cloud-pubsub).
  • Call publish/subscribe methods directly from ObjectScript.

Example (Embedded Python):

Class PubSub.Utils Extends %RegisteredObject
{
ClassMethod Publish(message As %String) [ Language = python ]
{
    from google.cloud import pubsub_v1
    publisher = pubsub_v1.PublisherClient()
    topic_path = publisher.topic_path("my-project", "my-topic")
    publisher.publish(topic_path, message.encode("utf-8"))
}
}

👉 You can then call Do ##class(PubSub.Utils).Publish("Hello from IRIS!") in ObjectScript.


⚖️ Which Approach Should You Choose?

  • REST Adapter → Easiest, no extra dependencies, fully supported by IRIS. Best for lightweight use cases.
  • Kafka Bridge → Best if you already run Kafka or need high throughput.
  • Embedded Python → Flexible, powerful, leverages official GCP SDKs. Great for advanced integrations.

📊 Fact Check: Performance Considerations

  • Pub/Sub latency: Typically ~100 ms end-to-end.
  • IRIS REST Adapter throughput: Can handle thousands of requests/sec with proper pooling.
  • Embedded Python: Slight overhead but allows using official libraries (keeps future compatibility).

✅ Conclusion

While InterSystems IRIS doesn’t ship with a native Pub/Sub adapter, the platform’s flexibility makes integration straightforward. Whether you use REST, Kafka, or embedded Python, you can seamlessly connect IRIS to Google Cloud Pub/Sub and unlock real-time, cloud-native workflows.

If you’ve implemented this integration differently (e.g., via FHIR services in HealthShare or Cloud Functions triggers), I’d love to hear your experience in the comments.


Now your IRIS system can speak Pub/Sub fluently!

Discussion (0)1
Log in or sign up to continue