Step 5: Subscribe to Change Events

Even though you can use the Subscribe.java example in genericpubsub to subscribe to change events, this client doesn't expand the bitmap fields in change events, such as the changedFields field. Use the ProcessChangeEventHeader.java example to subscribe to change events and perform bitmap field expansion.

Prerequisites

  1. In a Terminal window, navigate to the java folder.

  2. To run the example, enter: ./run.sh processchangeeventheader.ProcessChangeEventHeader

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

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

  5. Update the opportunity record. For example, add a value for Description: "My sample opportunity." 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 Description field that you changed, and the LastModifiedDate field that the system changed. For example: