Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Subscribe and Managed Subscribe examples #60

Merged
merged 10 commits into from
Jul 31, 2024

Conversation

sidd0610
Copy link
Contributor

@sidd0610 sidd0610 commented Jul 30, 2024

This PR aims to remove the ProcessChangeEventHeader as a separate example and make the processing of ChangedFields flow a part of the Subscribe and ManagedSubscribe examples. It also introduces a new Optional Configuration called PROCESS_CHANGED_FIELDS which lets a customer enable/disable the flow.

java/README.md Outdated
@@ -47,6 +47,7 @@ In the `src/main` directory of the project, you will find several sub-directorie
* `NUMBER_OF_EVENTS_TO_PUBLISH`: Specify the number of events to publish while using the PublishStream RPC.
* `SINGLE_PUBLISH_REQUEST`: Specify if you want to publish the events in a single or multiple PublishRequests.
* `NUMBER_OF_EVENTS_IN_FETCHREQUEST`: Specify the number of events that the Subscribe RPC requests from the server in each FetchRequest. The example fetches at most 5 events in each Subscribe request. If you pass in more than 5, it sends multiple Subscribe requests with at most 5 events requested in FetchRequest each. For more information about requesting events, see [Pull Subscription and Flow Control](https://developer.salesforce.com/docs/platform/pub-sub-api/guide/flow-control.html) in the Pub/Sub API documentation.
* `PROCESS_CHANGED_FIELDS`: Specify whether the Subscribe or ManagedSubscribe client should process the [ChangedFields](https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_class_eventbus_ChangeEventHeader.htm#apex_eventbus_ChangeEventHeader_changedfields) header in ChangeDataCapture (CDC) events.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ChangeDataCapture -> Change Data Capture

@knhage thoughts about the wording here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sidd0610 This should be for all the bitmap fields in ChangeEventHeader:
changedFields, diffFields, and nulledFields
This is doc'd in Event Deserialization Considerations.

So I suggest rewording to:

  • PROCESS_CHANGE_EVENT_HEADER_FIELDS: Specify whether the Subscribe or ManagedSubscribe client process the change data capture event bitmap fields in ChangeEventHeader. See Event Deserialization Considerations.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sidd0610 I just realized that the client expands only the changedFields bitmap field. Maybe we can change the text to the following:

  • PROCESS_CHANGE_EVENT_HEADER_FIELDS: Specify whether the Subscribe or ManagedSubscribe client process the change data capture event bitmap fields in ChangeEventHeader. In this sample, only the changedFields field is expanded. To expand the diffFields and nulledFields header fields, modify the sample code. See Event Deserialization Considerations.

Copy link
Contributor

@knhage knhage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments.

@@ -265,6 +267,26 @@ public static GenericRecord deserialize(Schema schema, ByteString payload) throw
return reader.read(null, decoder);
}

public static void processAndPrintChangedFields(Schema writerSchema, GenericRecord record) throws IOException {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see that we print only the changed fields. Is it possible to add a comment similar to:

// This method expands the changedFields bitmap field in ChangeEventHeader. To expand the other bitmap fields, diffFields and nulledFields, modify this code.

@@ -43,6 +43,8 @@ NUMBER_OF_EVENTS_IN_FETCHREQUEST: null
REPLAY_PRESET: null
# Replay ID in ByteString
REPLAY_ID: null
# Flag to enable/disable ChangedFields processing in Subscribe and ManagedSubscribe examples for CDC events (default: false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a comment on another thread about this.

Copy link
Contributor

@knhage knhage left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added an edit in arguments.yaml

@@ -43,6 +43,8 @@ NUMBER_OF_EVENTS_IN_FETCHREQUEST: null
REPLAY_PRESET: null
# Replay ID in ByteString
REPLAY_ID: null
# Flag to enable/disable bitmap field processing in Subscribe and ManagedSubscribe examples for CDC events (default: false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit:
# Flag to enable/disable bitmap ChangeEventHeader field processing in Subscribe and ManagedSubscribe examples for change data capture events (default: false)

@sidd0610 sidd0610 merged commit 96ae4c1 into main Jul 31, 2024
1 check passed
@sidd0610 sidd0610 deleted the siddartha/update-subscribe-examples branch July 31, 2024 18:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants