1. Home
  2. Docs
  3. Functions
  4. Adding a function
  5. Adding Java functions

Adding Java functions

Java functions can be added by loading a Java jar file (.jar). When adding a Java files, you also need to specify the name of the class to execute as the function. For example, if the Python file is called function.py and the class is exclamation, then the class name would be “function.exclamation”. The file can contain multiple classes, but only one will be used. If there is no class in the Python file, for example when using a basic function, just specify the filename without the extension (ex. function).

ADDING A Java FUNCTION FILE

  1. From the left sidebar menu, select Functions/Add.
  2. Click on the Choose File button from the Function File field.
  3. Using the dialog box, select the Java jar file containing the function code.
  4. If the jar file has more than one class, then the Class Name drop-down will contain all the classes. Choose the class you want to execute as the function.
  5. Enter the function name in the Function Name field. The name will default to the filename without the extension.
  6. Select the namespace where you want to create the function in the Namespace field. Note that all topics (input, output, logs) must be in the same namespace as the function.
  7. If the Runtime field did not default to Java, set it to Java.
  8. Specify the input topic for the function in the Input Topic field. This the topic that the function will connect to and process messages from. If the input topic doesn’t exist when the function is added, it will be automatically created.
  9. Optionally, specify the output topic in the Output Topic field. If the function returns a value, you specify an output topic for this value to be published to. If the output topic doesn’t exist it will be created automatically when the function executes.
  10. Optionally, specify the log topic in the Log Topic field. If the function generates logs, you should specify a log topic. If the log topic doesn’t exist, it will be created when the function generates a log message.
  11. Specify the number of instances of this function to run in the Instances field. If the input topic receives a high rate of messages, you may need multiple function instances to keep up with the load. Note that the number of instances you can create will be limited by your Plan.
  12. Select the processing guarantee in the Processing Guarantee field. This field specifies how many times the function will be executed successfully for each message on the input topic.
  13. If the processing guarantee is At Least Once, enter the function timeout in milliseconds in the Time Out In Ms field.
  14. If you want the message to be automatically acknowledged when the function runs successfully, click on the Auto Ack checkbox. If you disable automatic acknowledgment, you must explicitly acknowledge the message in your function.
  15. If your function uses configurations keys as input, click on Click For Config Keys to display the key settings. Enter the key and value the Add Key button. To remove a key you have added, click on the X beside the key name.
  16. To add the function, click on the Add button. If the function is successfully added you will see the Function Details screen for the function.
Was this article helpful to you? Yes No

How can we help?