Step 5: Subscribe to Change Events

Use the example to subscribe to change events and perform bitmap field expansion. expands the bitmap fields in change events, such as the changedFields field, into its component fields.


  1. In your pub-sub-api folder, navigate to java/src/main/resources and open thearguments.yaml file. Provide the change event channel as the TOPIC argument.

    1. TOPIC: /data/OpportunityChangeEvent
  2. In a Terminal window, navigate to the java folder.

  3. To run the example, from the top-level java folder, enter: ./ processchangeeventheader.ProcessChangeEventHeader

    1. The example subscribes to the /data/OpportunityChangeEvent channel and captures any new or changed Opportunity records.
  4. The example prints out logging information similar to:

  5. In Salesforce, create an opportunity record. The change event is received and printed. For example:

  6. Update the opportunity record. For example, select a Type of New Customer. The change event for the update is received and printed. The output includes the Changed Fields section, which contains the fields that were expanded from the changedFields bitmap field. It lists the two fields that were changed: the Type field that you changed, and the LastModifiedDate field that the system changed. For example: