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 have default values, so 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
For the optional parameters, don’t provide any values so that the default values are used. Here’s a description of the optional parameters.
- TOPIC: This parameter is the topic for publishing and subscription. The default value is
/event/CarMaintenance__e
. - NUMBER_OF_EVENTS_TO_PUBLISH: This parameter is the number of events to publish while using the Publish or PublishStream RPC. The default value is 5.
- 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.