Hi Guys - I am trying to 'create a function' ... p...
# general
j
Hi Guys - I am trying to 'create a function' ... programmatically ... in Java ... using the code in the 'Create a function' section here. In other words I am trying to get code like this to work >
Copy code
FunctionConfig functionConfig = new FunctionConfig();
> functionConfig.setTenant(tenant);
> functionConfig.setNamespace(namespace);
> functionConfig.setName(functionName);
> functionConfig.setRuntime(FunctionConfig.Runtime.JAVA);
> functionConfig.setParallelism(1);
> functionConfig.setClassName("org.apache.pulsar.functions.api.examples.ExclamationFunction");
> functionConfig.setProcessingGuarantees(FunctionConfig.ProcessingGuarantees.ATLEAST_ONCE);
> functionConfig.setTopicsPattern(sourceTopicPattern);
> functionConfig.setSubName(subscriptionName);
> functionConfig.setAutoAck(true);
> functionConfig.setOutput(sinkTopic);
> admin.functions().createFunction(functionConfig, fileName);
But I am having trouble. Might anybody be able to point me to some example Java code that preferably comes with a pom.xml file which: (i) pulls the necessary Pulsar libraries and (ii) just builds ... to create a working executable that actually successfully deploys a function using code like the last line in the code snippet above? If I have that to work backwards from I am confident that I will be able to get my code working. I would think there must be at least one working example program (that does this) somewhere.
a
To confirm, are you looking for an example of how to create a java function or for an example of how to use java to deploy your already built function?
j
The example I have in mind would do both - it would create a simple 'Pulsar Java function' then deploy that function using 'admin.functions().createFunction()'.
If I have an example that does both then I will feel 100% confident that I have everything I need.
a
To get some inspiration you can take a look at this repo from datastax: https://github.com/datastax/pulsar-examples/blob/master/functions/java/README-java.md