Step 3: Configure Client Parameters
The Java client example contains parameters that are passed to the client. Enter values for the required parameters, such as the Pub/Sub API endpoint and your Salesforce login credentials. Optional parameters, such as the event topic, have default values. Provide values only if you want to change the defaults.
- In your cloned repo, navigate to
src/main/resources
and open thearguments.yaml
file. - Enter the required parameters that are used to establish the streaming connection.
- PUBSUB_HOST: Specify the Pub/Sub API endpoint
api.pubsub.salesforce.com
. - PUBSUB_PORT: Specify the Pub/Sub API port to be used,
7443
or443
. - LOGIN_URL: Specify the login URL of the Salesforce org to use to run the examples, starting with
https://
. For login URL formats, see My Domain URL Formats in Salesforce Help. - Provide values for either USERNAME and PASSWORD or ACCESS_TOKEN and TENANT_ID.
- USERNAME and PASSWORD: To authenticate via username and password, specify the Salesforce username and password.
- ACCESS_TOKEN and TENANT_ID: To authenticate via a session token, specify the sessionToken and tenant ID of the Salesforce org.
Optional Parameters
Change the optional parameters if you want to use values other than the defaults. Here’s a description of the optional parameters.
- TOPIC: This parameter is the topic for publishing and subscribing to platform events, and subscribing to change data capture events. The default value is
/event/Order_Event__e
. - NUMBER_OF_EVENTS_TO_PUBLISH: This parameter is the number of events to publish when using the PublishStream RPC. The default value is 5.
- SINGLE_PUBLISH_REQUEST: This parameter indicates whether to add events to a single PublishRequest (true) or in different PublishRequests (false). The default value is false.
- NUMBER_OF_EVENTS_IN_FETCHREQUEST: This parameter is the number of events that the Subscribe RPC requests from the server in each FetchRequest. The default value is 5. 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 each FetchRequest. For more information about requesting events, see Pull Subscription and Flow Control.
- REPLAY_PRESET: This parameter specifies where to start the subscription. To fetch past events that are stored in the event bus, use REPLAY_PRESET with REPLAY_ID. For more information, see the Readme page in the pub-sub-api GitHub repository and Replaying an Event Stream in the Pub/Sub API documentation.