Attention: This version of Event Streams has reached End of Support. For more information about supported versions, see the support matrix.

Generating a starter application

To learn more about how you can create applications that can take advantage of Event Streams capabilities, generate a starter application. The starter application can produce and consume messages, and you can specify the topic where you want to send messages to.

About the application

The starter application provides a demonstration of a Java application running on WebSphere Liberty that sends events, receives events, or both, by using Event Streams.

Project contents

The Java classes in the application.kafka package are designed to be independent of the specific use case for Kafka. The application.kafka sample code is used by the application.demo package and can also be used to understand the elements required to create your own Kafka application.

The src/main/java/application/demo folder contains the framework for running the sample in a user interface, providing an easy way to view message propagation.

Security

The starter application is generated with the correct security configurations to connect to Event Streams. These security configurations include a .jks file for the certificate and API keys for producing and consuming messages. For more information, see the instructions for connecting clients.

Note: The API keys generated for the starter application can only be used to connect to the topic selected during generation. In addition, the consumer API key can only be used to connect with a consumer group ID set to the name of the generated application.

Generating and running

To generate the application:

  1. Ensure you have Java version 8. Also, ensure you have Apache Maven installed on your system.
  2. Log in to the Event Streams UI from a supported web browser (see how to determine the login URL for your Event Streams UI).
  3. Click the Send and receive messages with a sample application tile, or click Toolbox in the primary navigation, go to the Generate starter application section, and click Find out more.
  4. Click Configure and generate application.
  5. Provide a name for the application.
  6. Decide whether you want the application to produce or consume messages, or both.
  7. Specify a target topic for the messages from the application.
  8. Click Generate starter application. The application is created.
  9. Download the compressed file and extract the file to a preferred location.
  10. Navigate to the extracted file, and run the following command to build and deploy the application:
    mvn install liberty:run-server
  11. Access the successfully deployed sample application using the following URL: http://localhost:9080/

Note: Some of these options depend on your access permissions. If you are not permitted to create topics, you will not be able to create a topic as part of building the starter application. If you are not permitted to write to topics, you will not be able to create a starter application that produces messages, only consumes them.