How to deploy an Unomi extension
Question
I want to deploy an Unomi extension. Can I have an example on how to deploy a custom plugin with a real application?
Answer
Examples of Unomi extensions can be found in Unomi source code in github: https://github.com/apache/unomi/tree/master/extensions
Let's take the salesforce-connector as an example: https://github.com/apache/unomi/tree/master/extensions/salesforce-connector which implements a connector to salesforce allowing unomi to update leads based on profile information.
You can start by cloning the repository, going to the extension path and using maven to build the extension:
git clone https://github.com/apache/unomi.git
cd unomi/extensions/salesforce-connector/
mvn clean install
If the build runs smoothly you should get the following output in terminal at the end:
...
[INFO] --- maven-install-plugin:2.5.2:install (default-install) @ unomi-salesforce-connector-karaf-kar ---
[INFO] Installing /Users/wernernedel/Jahia/Git/unomi/extensions/salesforce-connector/karaf-kar/target/unomi-salesforce-connector-karaf-kar-1.4.0.kar to /Users/wernernedel/.m2/repository/org/apache/unomi/unomi-salesforce-connector-karaf-kar/1.4.0/unomi-salesforce-connector-karaf-kar-1.4.0.kar
[INFO] Installing /Users/wernernedel/Jahia/Git/unomi/extensions/salesforce-connector/karaf-kar/pom.xml to /Users/wernernedel/.m2/repository/org/apache/unomi/unomi-salesforce-connector-karaf-kar/1.4.0/unomi-salesforce-connector-karaf-kar-1.4.0.pom
[INFO] Installing /Users/wernernedel/Jahia/Git/unomi/extensions/salesforce-connector/karaf-kar/target/feature/feature.xml to /Users/wernernedel/.m2/repository/org/apache/unomi/unomi-salesforce-connector-karaf-kar/1.4.0/unomi-salesforce-connector-karaf-kar-1.4.0-features.xml
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for Apache Unomi :: Extensions :: Salesforce connector 1.4.0:
[INFO]
[INFO] Apache Unomi :: Extensions :: Salesforce connector . SUCCESS [ 0.880 s]
[INFO] Apache Unomi :: Extensions :: Salesforce connector :: Service SUCCESS [ 2.164 s]
[INFO] Apache Unomi :: Extensions :: Salesforce connector :: REST API SUCCESS [ 0.822 s]
[INFO] Apache Unomi :: Extensions :: Salesforce connector :: Rule Actions SUCCESS [ 0.240 s]
[INFO] Apache Unomi :: Extensions :: Salesforce connector :: Apache Karaf Feature and KAR archive SUCCESS [ 1.266 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 6.404 s
[INFO] Finished at: 2020-01-03T23:15:24-05:00
[INFO] ------------------------------------------------------------------------
So now connect to Unomi karaf console. If you are using default configuration you should be able to connect by running the following command (password karaf):
ssh -p 8102 karaf@localhost
Now you can install the feature with the syntax groupId/artifactId[/[version]/[type]]. The proper artifactId can be obtained from "mvn clean install" output.
karaf@root()> feature:repo-add mvn:org.apache.unomi/unomi-salesforce-connector-karaf-kar/1.4.0/xml/features
Adding feature url mvn:org.apache.unomi/unomi-salesforce-connector-karaf-kar/1.4.0/xml/features
karaf@root()> feature:install unomi-salesforce-connector-karaf-kar
Initializing SFDC service endpoint...
karaf@root()>
Now if you list the bundles you should be able to see salesforce extensions:
karaf@root()> bundle:list
START LEVEL 100 , List Threshold: 50
ID │ State │ Lvl │ Version │ Name
────┼────────┼─────┼─────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
268 │ Active │ 85 │ 1.4.0 │ Apache Unomi :: Extensions :: Salesforce connector :: Rule Actions
269 │ Active │ 85 │ 1.4.0 │ Apache Unomi :: Extensions :: Salesforce connector :: REST API
270 │ Active │ 85 │ 1.4.0 │ Apache Unomi :: Extensions :: Salesforce connector :: Service