Skip to main content

Messaging-related APIs

Constellation DX components support reactivity through the use of client-side and server-side messaging functionality.

Note: To complete the knowledge check and module quiz, you must go through the links mentioned in this topic.

Constellation DX components support two types of messaging:

  • client-side component-to-component messaging through the PubSubUtils class that wraps the client-side publish-subscribe event bus.
  • server-to-client communication through the MessagingServiceManager class that provides access to the external Constellation Messaging Service web socket server.

The messaging APIs can be used to subscribe to and publish custom and Pega-provided event types.

Common PubSubUtils APIs

The Constellation PubSubUtils class contains a set of APIs that can be used by Constellation DX components to publish and subscribe to events regardless of where they are in the component hierarchy. 

If a Constellation DX component needs to respond to an event, it must subscribe to the appropriate message type listed here. You can create your own event type in addition to the default event types. You can also publish custom events and attach your event payload, which will notify the subscribers to your custom event who can use the custom payload. You can also subscribe to custom event types through Constellation DX components that you have created.

You can use the PubSubUtils class to subscribe to the various create, update, and delete-related events to refresh a utility widget. If your component creates, updates, or deletes data instances, it is best practice to publish the appropriate event type to inform other components in your current session about the changes to the data.

Class API Description
PubSubUtils publish

Invokes all items subscribed to a specific type of event and passes the specified payload to the subscribed items.

PubSubUtils subscribe Notifies a subscription item whenever an event occurs in a specific context.
PubSubUtils unsubscribe Unsubscribes a subscription item belonging to a specific type of event.

Messaging Service APIs

The Constellation MessagingServiceManager class contains a set of APIs that can be used by Constellation DX components to subscribe to events published by the Pega Infinity™ Server to the Constellation Messaging Service.

Class API Description
MessagingServiceManager subscribe

Subscribes to the messaging service and forwards messages to subscribers based on a specified filter criteria.

MessagingServiceManager unsubscribe

Removes the handler from its subscriptions and disconnects the web socket from the messaging service.

  • For more information on the architecture of the Constellation Messaging Service, see Architectural overview.
  • For information about developing your custom message schema, see Message schema.

The following code shows an example of a simple message schema that would be used in the the subject which is the parameter of the PCore.getMessagingServiceManager().subscribe API:

const ratingSubObject = {
  matcher: 'SL_DXEXTENSIONS_STARRATINGWIDGET',
  criteria: {
    ID: customerId ?? ''
  }
};

For more information about server-side publishing, see Server-side publishing.

The message schema that describes the message subject is shared between the subscriber and the publisher. Any changes to the message schema must reflect on the server and the client.

In the following example, the pxC11nPublishCaseCreation activity wraps the pxC11nPublishMessage activity and shows how the message payload is created that is then used in the pxC11nPublishMessage activity:

A screen shot depicting the pxC11nPublishCaseCreation activity wraps the pxC11nPublishMessage activity and shows how the message payload is created that is then used in the pxC11nPublishMessage activity.

Check your knowledge with the following interaction:


This Topic is available in the following Module:

If you are having problems with your training, please review the Pega Academy Support FAQs.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice