Skip to content

HyperWorldly/pulsar-functions-java-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Pulsar Functions Java Starter

This repo houses some example Pulsar Functions written in Java. These functions can all be run either in local mode or in cluster mode.

Requirements

You'll need to have Maven installed.

Setup

Pulsar Functions written in Java need to be packaged as a "fat" jar. To create a fat jar:

$ mvn package

To deploy and run the functions in this repo, you'll need to navigate to the Pulsar repo and use the pulsar-admin executable in the bin folder. We recommend setting the path to the jar file created in this repo as an environment variable:

$ export PULSAR_FUNCTIONS_JAR=`pwd`/target/pulsar-functions-0.1.0-SNAPSHOT-jar-with-dependencies.jar
$ cd /path/to/incubator-pulsar

# Example create command
$ bin/pulsar-admin functions create \
  --jar $PULSAR_FUNCTIONS_JAR \
  --className pulsarfunctions.starter.javanative.SimpleStringFunction \
  --inputs input_topic \
  --output output_topic

Included functions

The following example functions are included in this repo:

Function name Description API used
ExclamationFunction Treats incoming message as string and appends exclamation('!') to it Java native API
SimpleStringFunction Ignores the input to the function and simply outputs the string "This is my function!" every time a message arrives Java native API
CustomSerDeInputFunction This function uses a custom serialization class for deserializing input message (TweetSerDe) to type Tweet objects Java native API
CustomSerDeOutputFunction This function uses a custom serialization class for serializing output message (TweetSerDe) from type Tweet objects Java native API
LogFunction This function uses the inbuilt sdk's functionality to route log messages to a log topic Java SDK API
PublishFunction This function uses the inbuilt sdk's functionality to publish messages to a specific topic Java SDK API
UserConfigFunction This function uses the inbuilt sdk's functionality to get command line parameters inside the function runtime Java SDK API
WordCountFunction This function uses the inbuilt sdk's state functionality to do word count Java SDK API

About

An easy way to get started writing Pulsar Functions in Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages