Compiling and Running HPE Ezmeral Data Fabric Streams Java Apps
For producer and consumer applications that use the HPE Ezmeral Data Fabric Streams Java API, use Maven to compile and determine the application dependencies. Then, when you run the application, specify those dependencies in the application classpath.
Compile and Determine Dependencies
For an example pom.xml
file, see HPE Ezmeral Data Fabric Streams Streams Sample
Programs on GitHub.
- Add the HPE Maven repository to your
pom.xml
file, if it is not already added:<repositories> <repository> <id>mapr-releases</id> <url>https://repository.mapr.com/nexus/content/repositories/releases</url> <snapshots><enabled>true</enabled></snapshots> <releases><enabled>true</enabled></releases> </repository> </repositories>
- Add a dependency to the Data Fabric Streams Java client
(kafka-clients) project:
<dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka-clients</artifactId> <version><version selected from the repository></version> </dependency>
NOTEThe kafka-clients version mentioned above is an example. The actual version that your application requires is based on the current EEP and Data Fabric core version that you are running. The versions are listed in the following locations: https://repository.mapr.com/nexus/content/groups/mapr-public/org/apache/kafka/kafka-clients/ - Add a dependency to the Data Fabric Streams
project:If you are using EEP version 9.1.2 and later:
<dependency> <groupId>org.apache.kafka</groupId> <artifactId>kafka-eventstreams</artifactId> <version><version selected from the repository></version> </dependency>
If you are using EEP version 8.1.0 through 9.1.1:<dependency> <groupId>com.mapr.kafka</groupId> <artifactId>mapr-streams</artifactId> <version><version selected from the repository></version> </dependency>
NOTEThe Data Fabric Streams project version mentioned above is an example. The actual version that your application requires is based on the current EEP and Data Fabric version that you are running. The versions are listed in the following locations:- For EEP version 9.1.2 and later: https://repository.mapr.com/nexus/content/groups/mapr-public/org/apache/kafka/kafka-eventstreams/
- For EEP version 8.1.0 through 9.1.1: https://repository.mapr.com/nexus/content/groups/mapr-public/com/mapr/kafka/kafka-eventstreams/
- Starting with EEP 8.1.0, this library is deprecated: https://repository.mapr.com/nexus/content/groups/mapr-public/com/mapr/streams/mapr-streams/
- Use Maven to compile the application and resolve dependencies. For example, you can run
mvn clean package
.
Run the Application
When you develop a Java application, you can use a dependency management
tool such as Maven to compile your application. However, it is recommended that you do the
following instead:
- Compile the Java application without including dependencies
- Specify the required classpath when you submit the application to the cluster
When the cluster is secure, the node must also have a Data Fabric ticket configured for the user that runs the application.
Use the following command to launch HPE Ezmeral Data Fabric Streams
applications:
java -cp <classpath>:. -Djava.library.path=/opt/mapr/lib <main class JAR> <command line arguments>