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 your Event Streams UI.
  3. Click the Generate a starter application tile, or click the Toolbox tab, and go to the Starter application section and click Generate application.
  4. Provide a name for the application.
  5. Decide whether you want the application to produce or consume messages, or both.
  6. Specify a target topic for the messages from the application.
  7. Click Generate. The application is created.
  8. Download the compressed file and extract the file to a preferred location.
  9. Navigate to the extracted file, and run the following command to build and deploy the application:
    mvn install liberty:run-server
  10. Access the successfully deployed sample application using the following URL: http://localhost:9080/<your_application_name>
  11. Click Close and go to topics to see your topic and check the messages generated by the application.

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.