Newer Version Available
Step 4: Use the Connector with Username and Password Login
Now that you’ve downloaded and built EMP Connector, use it to connect to CometD and
subscribe to the PushTopic.
Let’s run an example that uses username and password login.
-
In the
/src/main/java/com/salesforce/emp/connector/example
folder, open the LoginExample.java source
file.
-
Run the LoginExample class and provide arguments.
- In Package Explorer, navigate to the LoginExample.java file. Right-click the file, and select .
-
On the Arguments tab, add values for the following arguments, separated
by a space.
Argument Value username Username of the logged-in user password Password for the username (or logged-in user) channel The channel name for the event: /event/Low_Ink__e - Click Run.
The sample is now subscribed to the event channel and is listening to event notifications. As soon as an event notification is published and received, the tool prints it to the console.
The sample fetches the earliest saved events within the past 24 hours. Optionally, to receive different events, you can include a replay ID as the last argument. Valid values are:- –1—Get all new events sent after subscription.
- –2—Get all new events sent after subscription and all past events within the past 24 hours.
- Specific number—Get all events that occurred after the event with the specified replay ID.
- In a browser window, create or modify an invoice statement. After you create or change data that corresponds to the query in your PushTopic, the output looks similar to the following.