Subscribing and Consuming Events

Scenario: A hotel chain wants to integrate its property management system (PMS) with a customer relationship management (CRM) platform to ensure that any updates to reservations or guest profiles in OPERA Cloud are immediately reflected in the CRM.

Conceptual Flow:

  1. Subscription Initiation: The CRM system establishes a WebSocket connection to the OHIP Streaming API and subscribes to relevant business events, such as Update Reservation and Update Profile events to monitor updates to reservations and guest profiles.
  2. Event Emission: When a reservation is created, modified, or canceled in OPERA Cloud, or a profile is updated, the Streaming API emits the corresponding event.
  3. Event Consumption: The CRM system receives the event in real-time and updates its records accordingly, ensuring data consistency across platforms. delta filtering and GET orchestration patterns are available.

Figure 4-1 Flow Diagram

This image shows the flow diagram for a hotel chain subscribing and consuming events with a customer relationship management (CRM).

In summary:

  • Connect to the following: wss://gateway/subscriptions?key=SHA256(app_key)
  • Set Sec-WebSocket-Protocol: graphql-transport-ws.
  • Send connection_init with OAuth Bearer token in payload.
  • After connection_ack, send subscribe.
  • Consumption occurs via next messages with offset included for ordering.
  • Consumption stops after the server sends the last messages in response to the client sending the complete message.

Quick Smoke Test (UAT or sandbox):

  • Ensure your application is subscribed and approved for "New Profile" and/or "Update Profile."
  • Start your consumer, wait for connection_ack, and then send subscribe.
  • From Postman (see Postman collections), perform a simple REST write that emits a Business Event (for example, create a new profile).
  • Confirm a next message arrives with eventName "NEW PROFILE" (or "UPDATE PROFILE") and a primaryKey. Optionally, orchestrate a GET using primaryKey to verify the current state.