diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_event_based/pom.xml b/custom-artifacts/inbound-endpoint/custom_inbound_event_based/pom.xml new file mode 100644 index 000000000..feb3dd6dd --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_event_based/pom.xml @@ -0,0 +1,146 @@ + + + + + 4.0.0 + org.apache.synapse.inbound + custom-event-based-inbound-consumer + 1.0.0 + Custom Event based inbound consumer Sample + http://wso2.org + + + org.apache.synapse + synapse-core + 4.0.0-wso2v268 + + + org.wso2.ei + org.wso2.micro.integrator.inbound.endpoint + 4.5.0 + + + + + wso2-maven2-repository + http://dist.wso2.org/maven2 + + + central + http://repo1.maven.org/maven2/ + + + atlassian-contrib + https://maven.atlassian.com/contrib + + + atlassian-proxy + https://maven.atlassian.com/repository/public + + + atlassian-public + https://maven.atlassian.com/public/ + + true + never + warn + + + true + warn + + + + wso2-nexus + WSO2 internal Repository + https://maven.wso2.org/nexus/content/groups/wso2-public/ + + true + never + ignore + + + + wso2 + WSO2 internal Repository + http://dist.wso2.org/maven2/ + + true + never + ignore + + + + + wso2.snapshots + WSO2 Snapshot Repository + http://maven.wso2.org/nexus/content/repositories/snapshots/ + + true + never + + + false + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5 + + 1.7 + 1.7 + + + + maven-assembly-plugin + 3.3.0 + + + ${basedir}/src/main/assembly/filter.properties + + + src/main/assembly/zip-assembly.xml + + false + + + + make-assembly + package + + single + + + + + + + + + wso2-maven2-repository + WSO2 Maven2 Repository + scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/ + + + diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/assembly/filter.properties b/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/assembly/filter.properties new file mode 100644 index 000000000..739fb0078 --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/assembly/filter.properties @@ -0,0 +1,5 @@ +custom.inbound.groupId=${project.groupId} +custom.inbound.artifactId=${project.artifactId} +custom.inbound.version=${project.version} + +#Add any dynamic parameters you defined in descriptor.yml here. diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/assembly/zip-assembly.xml b/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/assembly/zip-assembly.xml new file mode 100644 index 000000000..092dcaa31 --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/assembly/zip-assembly.xml @@ -0,0 +1,33 @@ + + bundle + + zip + + false + + + ${project.build.directory} + / + + *.jar + + + + + + src/main/resources/uischema.json + /resources + + + src/main/resources/connector.xml + / + + + src/main/resources/descriptor.yml + / + true + + + diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/java/org/wso2/carbon/inbound/custom/event/SampleEventBasedInboundConsumer.java b/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/java/org/wso2/carbon/inbound/custom/event/SampleEventBasedInboundConsumer.java new file mode 100644 index 000000000..b2cc083ea --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/java/org/wso2/carbon/inbound/custom/event/SampleEventBasedInboundConsumer.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.inbound.custom.event; + +import java.util.Properties; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.synapse.core.SynapseEnvironment; +import org.wso2.carbon.inbound.endpoint.protocol.generic.GenericEventBasedConsumer; + +public class SampleEventBasedInboundConsumer extends GenericEventBasedConsumer { + + private static final Log log = LogFactory.getLog(SampleEventBasedInboundConsumer.class); + + /** + * @param properties + * @param name + * @param synapseEnvironment + * @param injectingSeq + * @param onErrorSeq + * @param coordination + * @param sequential + */ + public SampleEventBasedInboundConsumer(Properties properties, String name, SynapseEnvironment synapseEnvironment, + String injectingSeq, String onErrorSeq, boolean coordination, boolean sequential) { + super(properties, name, synapseEnvironment, injectingSeq, onErrorSeq, coordination, sequential); + log.info("Initialized the busy waiting consumer."); + } + + /** + * Start listening for incoming events on the inbound endpoint. + *

+ * This is the main entry point that activates the event listener and begins processing + * incoming events from the configured source. + */ + @Override + public void listen() { + //TODO: Implement logic to start listening for events + log.info("Inside the listen method. Starting to listen for events."); + } + + /** + * Gracefully suspend event processing. + *

+ * pause() temporarily halts the processing of incoming events without destroying the connection + * or releasing resources, allowing the endpoint to resume event processing later. + */ + @Override + public void pause(){ + //TODO: Implement logic to gracefully suspend event processing + log.info("Inside the pause method. Gracefully suspending event processing."); + } + + /** + * Implement resume() method to enable dynamic lifecycle control (activate/deactivate) of the inbound endpoint. + *

+ * resume() should re-establish the connections and restore the endpoint to an active state. + *

+ * Note: While resume() and destroy() methods are loosely coupled, ensure that resume() performs all necessary + * restoration actions corresponding to the cleanup performed in destroy(). + */ + @Override + public void resume(){ + //TODO: Implement logic to restore endpoint to active state + log.info("Inside the resume method. Restoring the event-based inbound endpoint."); + } + + /** + * Completely shut down the event listener and release all resources. + *

+ * destroy() terminates event listening, closes all connections, and releases allocated resources. + *

+ * Note: destroy() is coupled with resume() to enable dynamic control of event-based inbound endpoint. + */ + @Override + public void destroy() { + //TODO: Implement logic to terminate event listening and release resources + log.info("Inside the destroy method. Terminating event listening and releasing resources."); + } +} diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/resources/connector.xml b/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/resources/connector.xml new file mode 100644 index 000000000..eac85f7d4 --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/resources/connector.xml @@ -0,0 +1,23 @@ + + + + + WSO2 Sample Event-based Inbound Endpoint + + diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/resources/descriptor.yml b/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/resources/descriptor.yml new file mode 100644 index 000000000..d606d665a --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/resources/descriptor.yml @@ -0,0 +1,12 @@ +# Connector Descriptor File +# Specifies the dependencies and repositories required for the connector. +# The values are parameterized for customization and will be referenced during the build process from filter.properties. + +dependencies: + - groupId: "${custom.inbound.groupId}" + artifactId: "${custom.inbound.artifactId}" + version: "${custom.inbound.version}" + +repositories: + - id: "wso2-nexus" + url: "https://maven.wso2.org/nexus/content/groups/wso2-public/" diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/resources/uischema.json b/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/resources/uischema.json new file mode 100644 index 000000000..b9b7db2e5 --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_event_based/src/main/resources/uischema.json @@ -0,0 +1,153 @@ +{ + "id": "org.wso2.carbon.inbound.custom.event.SampleEventBasedInboundConsumer", + "name": "SampleEventBasedInboundConsumer", + "type": "event-integration", + "title": "SampleEventBasedInboundConsumer", + "help": "Configuration of Sample Event Based Inbound Endpoint", + "elements": [ + { + "type": "attributeGroup", + "value": { + "groupName": "Generic", + "elements": [ + { + "type": "attribute", + "value": { + "name": "name", + "displayName": "Event Integration Name", + "inputType": "string", + "required": true, + "helpTip": "Unique identifier for the Polling event integration." + } + }, + { + "type": "attribute", + "value": { + "name": "class", + "displayName": "Class Name", + "inputType": "string", + "required": true, + "hidden": true, + "defaultValue": "org.wso2.carbon.inbound.custom.event.SampleEventBasedInboundConsumer" + } + }, + { + "type": "attribute", + "value": { + "name": "generateSequences", + "displayName": "Automatically generate sequences", + "inputType": "checkbox", + "defaultValue": true + } + }, + { + "type": "attribute", + "value": { + "name": "sequence", + "displayName": "Injecting Sequence Name", + "inputType": "keyOrExpression", + "keyType": "sequence", + "required": true, + "enableCondition": [{"generateSequences":false}], + "helpTip": "Sequence to inject the SMS message" + } + }, + { + "type": "attribute", + "value": { + "name": "onError", + "displayName": "Error Sequence Name", + "inputType": "keyOrExpression", + "keyType": "sequence", + "required": false, + "enableCondition": [{"generateSequences":false}], + "helpTip": "Error sequence to invoke on fault" + } + } + ] + } + }, + { + "type": "attributeGroup", + "value": { + "groupName": "Inbound Functional", + "elements": [ + { + "type": "attribute", + "value": { + "name": "inbound.behavior", + "displayName": "Inbound behavior", + "hidden": true, + "inputType": "string", + "defaultValue": "eventBased", + "required": true, + "helpTip": "Inbound behavior" + } + }, + { + "type": "attribute", + "value": { + "name": "sequential", + "displayName": "Execute sequentially", + "inputType": "checkbox", + "defaultValue": true, + "required": false, + "helpTip": "The behaviour when executing the given sequence." + } + }, + { + "type": "attribute", + "value": { + "name": "coordination", + "displayName": "Coordination", + "inputType": "checkbox", + "defaultValue": true, + "required": false, + "helpTip": "In a clustered setup, this will run the inbound only in a single worker node." + } + }, + { + "type": "attribute", + "value": { + "name": "suspend", + "displayName": "Suspend Inbound", + "inputType": "checkbox", + "defaultValue": false, + "hidden": false, + "required": false, + "helpTip": "Enable this option to suspend the inbound endpoint immediately after deployment." + } + } + ] + } + }, + { + "type": "attributeGroup", + "value": { + "groupName": "Configuration Group 01", + "elements": [ + { + "type": "attribute", + "value": { + "name": "config1", + "displayName": "Sample Listener Inbound configuration 1", + "inputType": "string", + "required": true, + "helpTip": "Unique identifier for the Sample listener configuration." + } + }, + { + "type": "attribute", + "value": { + "name": "config2", + "displayName": "Sample Listener Inbound configuration 2", + "inputType": "string", + "required": false, + "helpTip": "Unique identifier for the Sample listener configuration." + } + } + ] + } + } + ] +} diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_listening/pom.xml b/custom-artifacts/inbound-endpoint/custom_inbound_listening/pom.xml new file mode 100644 index 000000000..9be2060c9 --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_listening/pom.xml @@ -0,0 +1,146 @@ + + + + + 4.0.0 + org.apache.synapse.inbound + custom-listening-inbound-endpoint + 1.0.0 + Custom Listening Inbound endpoint Sample + http://wso2.org + + + org.apache.synapse + synapse-core + 4.0.0-wso2v268 + + + org.wso2.ei + org.wso2.micro.integrator.inbound.endpoint + 4.5.0 + + + + + wso2-maven2-repository + http://dist.wso2.org/maven2 + + + central + http://repo1.maven.org/maven2/ + + + atlassian-contrib + https://maven.atlassian.com/contrib + + + atlassian-proxy + https://maven.atlassian.com/repository/public + + + atlassian-public + https://maven.atlassian.com/public/ + + true + never + warn + + + true + warn + + + + wso2-nexus + WSO2 internal Repository + https://maven.wso2.org/nexus/content/groups/wso2-public/ + + true + never + ignore + + + + wso2 + WSO2 internal Repository + http://dist.wso2.org/maven2/ + + true + never + ignore + + + + + wso2.snapshots + WSO2 Snapshot Repository + http://maven.wso2.org/nexus/content/repositories/snapshots/ + + true + never + + + false + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5 + + 1.7 + 1.7 + + + + maven-assembly-plugin + 3.3.0 + + + ${basedir}/src/main/assembly/filter.properties + + + src/main/assembly/zip-assembly.xml + + false + + + + make-assembly + package + + single + + + + + + + + + wso2-maven2-repository + WSO2 Maven2 Repository + scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/ + + + diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/assembly/filter.properties b/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/assembly/filter.properties new file mode 100644 index 000000000..739fb0078 --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/assembly/filter.properties @@ -0,0 +1,5 @@ +custom.inbound.groupId=${project.groupId} +custom.inbound.artifactId=${project.artifactId} +custom.inbound.version=${project.version} + +#Add any dynamic parameters you defined in descriptor.yml here. diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/assembly/zip-assembly.xml b/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/assembly/zip-assembly.xml new file mode 100644 index 000000000..092dcaa31 --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/assembly/zip-assembly.xml @@ -0,0 +1,33 @@ + + bundle + + zip + + false + + + ${project.build.directory} + / + + *.jar + + + + + + src/main/resources/uischema.json + /resources + + + src/main/resources/connector.xml + / + + + src/main/resources/descriptor.yml + / + true + + + diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/java/org/wso2/carbon/inbound/custom/listen/SampleListeningInboundEndpoint.java b/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/java/org/wso2/carbon/inbound/custom/listen/SampleListeningInboundEndpoint.java new file mode 100644 index 000000000..183cdf64e --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/java/org/wso2/carbon/inbound/custom/listen/SampleListeningInboundEndpoint.java @@ -0,0 +1,93 @@ +/* + * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.inbound.custom.listen; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.synapse.inbound.InboundProcessorParams; +import org.wso2.carbon.inbound.endpoint.protocol.generic.GenericInboundListener; + +public class SampleListeningInboundEndpoint extends GenericInboundListener{ + + private static final Log log = LogFactory.getLog(SampleListeningInboundEndpoint.class); + + /** + * Constructor + * + * @param params Parameters of the inbound endpoint + */ + public SampleListeningInboundEndpoint(InboundProcessorParams params) { + super(params); + log.info("Initialized the custom listening inbound endpoint."); + } + + /** + * Initialize the listening + */ + public void init() { + //TODO : need to implement the logic here + log.info("Inside the init method, listening starts here ..."); + } + + /** + * Stopping the inbound endpoint + */ + public void destroy() { + //TODO : need to implement the logic here + log.info("Inside the destroy method, destroying the listening inbound ..."); + } + + /** + * Implement pause method with necessary logic to enable graceful shutdown in your custom inbound endpoint. + *

+ * pause() temporarily stops accepting incoming messages without destroying + * the listener or releasing resources, allowing the endpoint to be resumed later. + */ + @Override + public void pause(){ + //TODO : need to implement the logic here + log.info("Inside the pause method, Pausing the listening inbound..."); + } + + /** + * Implement activate(), deactivate() and isDeactivated() methods with necessary logic + * to enable dynamic control (activate/deactivate) in your custom inbound endpoint + */ + @Override + public boolean activate() { + //TODO : need to implement the logic here + log.info("Inside the activate method, activating the listening inbound after a deactivation..."); + return false; + } + + @Override + public boolean deactivate() { + //TODO : need to implement the logic here + log.info("Inside the deactivate method, deactivating the listening inbound..."); + return false; + } + + @Override + public boolean isDeactivated() { + //TODO : need to implement the logic here + log.info("Inside the isDeactivated method, check running status of the listening inbound..."); + return false; + } + +} diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/resources/connector.xml b/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/resources/connector.xml new file mode 100644 index 000000000..ea1b3ee10 --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/resources/connector.xml @@ -0,0 +1,23 @@ + + + + + WSO2 Sample Listener Inbound Endpoint + + diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/resources/descriptor.yml b/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/resources/descriptor.yml new file mode 100644 index 000000000..d606d665a --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/resources/descriptor.yml @@ -0,0 +1,12 @@ +# Connector Descriptor File +# Specifies the dependencies and repositories required for the connector. +# The values are parameterized for customization and will be referenced during the build process from filter.properties. + +dependencies: + - groupId: "${custom.inbound.groupId}" + artifactId: "${custom.inbound.artifactId}" + version: "${custom.inbound.version}" + +repositories: + - id: "wso2-nexus" + url: "https://maven.wso2.org/nexus/content/groups/wso2-public/" diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/resources/uischema.json b/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/resources/uischema.json new file mode 100644 index 000000000..f97267f1b --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_listening/src/main/resources/uischema.json @@ -0,0 +1,153 @@ +{ + "id": "org.wso2.carbon.inbound.custom.listen.SampleListeningInboundEndpoint", + "name": "SampleListenerInbound", + "type": "event-integration", + "title": "SampleListenerInbound", + "help": "Configuration of Sample Listener Inbound Endpoint", + "elements": [ + { + "type": "attributeGroup", + "value": { + "groupName": "Generic", + "elements": [ + { + "type": "attribute", + "value": { + "name": "name", + "displayName": "Event Integration Name", + "inputType": "string", + "required": true, + "helpTip": "Unique identifier for the Listener event integration." + } + }, + { + "type": "attribute", + "value": { + "name": "class", + "displayName": "Class Name", + "inputType": "string", + "required": true, + "hidden": true, + "defaultValue": "org.wso2.carbon.inbound.custom.listen.SampleListeningInboundEndpoint" + } + }, + { + "type": "attribute", + "value": { + "name": "generateSequences", + "displayName": "Automatically generate sequences", + "inputType": "checkbox", + "defaultValue": true + } + }, + { + "type": "attribute", + "value": { + "name": "sequence", + "displayName": "Injecting Sequence Name", + "inputType": "keyOrExpression", + "keyType": "sequence", + "required": true, + "enableCondition": [{"generateSequences":false}], + "helpTip": "Sequence to inject the SMS message" + } + }, + { + "type": "attribute", + "value": { + "name": "onError", + "displayName": "Error Sequence Name", + "inputType": "keyOrExpression", + "keyType": "sequence", + "required": false, + "enableCondition": [{"generateSequences":false}], + "helpTip": "Error sequence to invoke on fault" + } + } + ] + } + }, + { + "type": "attributeGroup", + "value": { + "groupName": "Inbound Functional", + "elements": [ + { + "type": "attribute", + "value": { + "name": "inbound.behavior", + "displayName": "Inbound behavior", + "hidden": true, + "inputType": "string", + "defaultValue": "listening", + "required": true, + "helpTip": "Inbound behavior" + } + }, + { + "type": "attribute", + "value": { + "name": "sequential", + "displayName": "Execute sequentially", + "inputType": "checkbox", + "defaultValue": true, + "required": false, + "helpTip": "The behaviour when executing the given sequence." + } + }, + { + "type": "attribute", + "value": { + "name": "coordination", + "displayName": "Coordination", + "inputType": "checkbox", + "defaultValue": true, + "required": false, + "helpTip": "In a clustered setup, this will run the inbound only in a single worker node." + } + }, + { + "type": "attribute", + "value": { + "name": "suspend", + "displayName": "Suspend Inbound", + "inputType": "checkbox", + "defaultValue": false, + "hidden": false, + "required": false, + "helpTip": "Enable this option to suspend the inbound endpoint immediately after deployment." + } + } + ] + } + }, + { + "type": "attributeGroup", + "value": { + "groupName": "Configuration Group 01", + "elements": [ + { + "type": "attribute", + "value": { + "name": "config1", + "displayName": "Sample Listener Inbound configuration 1", + "inputType": "string", + "required": true, + "helpTip": "Unique identifier for the Sample listener configuration." + } + }, + { + "type": "attribute", + "value": { + "name": "config2", + "displayName": "Sample Listener Inbound configuration 2", + "inputType": "string", + "required": false, + "helpTip": "Unique identifier for the Sample listener configuration." + } + } + ] + } + } + ] +} diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_polling/pom.xml b/custom-artifacts/inbound-endpoint/custom_inbound_polling/pom.xml new file mode 100644 index 000000000..a5d6da2c7 --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_polling/pom.xml @@ -0,0 +1,146 @@ + + + + + 4.0.0 + org.apache.synapse.inbound + custom-polling-inbound-consumer + 1.0.0 + Custom Polling Inbound Consumer Sample + http://wso2.org + + + org.apache.synapse + synapse-core + 4.0.0-wso2v268 + + + org.wso2.ei + org.wso2.micro.integrator.inbound.endpoint + 4.5.0 + + + + + wso2-maven2-repository + http://dist.wso2.org/maven2 + + + central + http://repo1.maven.org/maven2/ + + + atlassian-contrib + https://maven.atlassian.com/contrib + + + atlassian-proxy + https://maven.atlassian.com/repository/public + + + atlassian-public + https://maven.atlassian.com/public/ + + true + never + warn + + + true + warn + + + + wso2-nexus + WSO2 internal Repository + https://maven.wso2.org/nexus/content/groups/wso2-public/ + + true + never + ignore + + + + wso2 + WSO2 internal Repository + http://dist.wso2.org/maven2/ + + true + never + ignore + + + + + wso2.snapshots + WSO2 Snapshot Repository + http://maven.wso2.org/nexus/content/repositories/snapshots/ + + true + never + + + false + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5 + + 1.7 + 1.7 + + + + maven-assembly-plugin + 3.3.0 + + + ${basedir}/src/main/assembly/filter.properties + + + src/main/assembly/zip-assembly.xml + + false + + + + make-assembly + package + + single + + + + + + + + + wso2-maven2-repository + WSO2 Maven2 Repository + scp://dist.wso2.org/home/httpd/dist.wso2.org/maven2/ + + + diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/assembly/filter.properties b/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/assembly/filter.properties new file mode 100644 index 000000000..739fb0078 --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/assembly/filter.properties @@ -0,0 +1,5 @@ +custom.inbound.groupId=${project.groupId} +custom.inbound.artifactId=${project.artifactId} +custom.inbound.version=${project.version} + +#Add any dynamic parameters you defined in descriptor.yml here. diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/assembly/zip-assembly.xml b/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/assembly/zip-assembly.xml new file mode 100644 index 000000000..092dcaa31 --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/assembly/zip-assembly.xml @@ -0,0 +1,33 @@ + + bundle + + zip + + false + + + ${project.build.directory} + / + + *.jar + + + + + + src/main/resources/uischema.json + /resources + + + src/main/resources/connector.xml + / + + + src/main/resources/descriptor.yml + / + true + + + diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/java/org/wso2/carbon/inbound/custom/poll/SamplePollingInboundConsumer.java b/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/java/org/wso2/carbon/inbound/custom/poll/SamplePollingInboundConsumer.java new file mode 100644 index 000000000..d8b1d4289 --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/java/org/wso2/carbon/inbound/custom/poll/SamplePollingInboundConsumer.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2025, WSO2 LLC. (https://www.wso2.com). + * + * WSO2 LLC. licenses this file to you under the Apache License, + * Version 2.0 (the "License"); you may not use this file except + * in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package org.wso2.carbon.inbound.custom.poll; + +import java.util.Properties; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.synapse.core.SynapseEnvironment; +import org.wso2.carbon.inbound.endpoint.protocol.generic.GenericPollingConsumer; + +public class SamplePollingInboundConsumer extends GenericPollingConsumer{ + + private static final Log log = LogFactory.getLog(SamplePollingInboundConsumer.class); + + /** + * @param properties + * @param name + * @param synapseEnvironment + * @param scanInterval + * @param injectingSeq + * @param onErrorSeq + * @param coordination + * @param sequential + */ + public SamplePollingInboundConsumer(Properties properties, String name, + SynapseEnvironment synapseEnvironment, long scanInterval, + String injectingSeq, String onErrorSeq, boolean coordination, + boolean sequential) { + super(properties, name, synapseEnvironment, scanInterval, injectingSeq, onErrorSeq, coordination, + sequential); + log.info("Initialized the custom polling consumer."); + } + + /** + * Actively fetch the next available message from the configured source at the specified interval. + *

+ * poll() retrieves and returns the next message from the source. Returns null if no messages + * are currently available. + * + * @return the polled message, or null if no messages are available + */ + @Override + public Object poll() { + //TODO: Implement logic to fetch messages from the configured source + log.info("Inside the poll method. Fetching the next available message."); + return null; + } + + /** + * Gracefully suspend message polling. + *

+ * pause() temporarily halts polling and message processing without destroying the connection + * or releasing resources, allowing the endpoint to resume polling later. + */ + @Override + public void pause(){ + //TODO: Implement logic to gracefully suspend polling + log.info("Inside the pause method. Gracefully suspending message polling."); + } + + /** + * Implement resume() method to enable dynamic lifecycle control (activate/deactivate) of the inbound endpoint. + *

+ * resume() should re-establish the connections and restore the endpoint to an active state. + *

+ * Note: While resume() and destroy() methods are loosely coupled, ensure that resume() performs all necessary + * restoration actions corresponding to the cleanup performed in destroy(). + */ + @Override + public void resume(){ + //TODO: Implement logic to restore endpoint to active polling state + log.info("Inside the resume method. Restoring the polling inbound endpoint."); + } + + /** + * Completely shut down the polling mechanism and release all resources. + *

+ * destroy() terminates polling, closes all connections, and releases allocated resources. + *

+ * Note: destroy() is coupled with resume() to enable dynamic control of event-based inbound endpoint. + */ + @Override + public void destroy() { + //TODO: Implement logic to terminate polling and release resources + log.info("Inside the destroy method. Terminating polling and releasing resources."); + } +} diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/resources/connector.xml b/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/resources/connector.xml new file mode 100644 index 000000000..448bd7740 --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/resources/connector.xml @@ -0,0 +1,23 @@ + + + + + WSO2 Sample Polling Inbound Endpoint + + diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/resources/descriptor.yml b/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/resources/descriptor.yml new file mode 100644 index 000000000..d606d665a --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/resources/descriptor.yml @@ -0,0 +1,12 @@ +# Connector Descriptor File +# Specifies the dependencies and repositories required for the connector. +# The values are parameterized for customization and will be referenced during the build process from filter.properties. + +dependencies: + - groupId: "${custom.inbound.groupId}" + artifactId: "${custom.inbound.artifactId}" + version: "${custom.inbound.version}" + +repositories: + - id: "wso2-nexus" + url: "https://maven.wso2.org/nexus/content/groups/wso2-public/" diff --git a/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/resources/uischema.json b/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/resources/uischema.json new file mode 100644 index 000000000..fb6f2a64a --- /dev/null +++ b/custom-artifacts/inbound-endpoint/custom_inbound_polling/src/main/resources/uischema.json @@ -0,0 +1,153 @@ +{ + "id": "org.wso2.carbon.inbound.custom.poll.SamplePollingInboundConsumer", + "name": "SamplePollingInboundConsumer", + "type": "event-integration", + "title": "SamplePollingInboundConsumer", + "help": "Configuration of Sample Polling Inbound Endpoint", + "elements": [ + { + "type": "attributeGroup", + "value": { + "groupName": "Generic", + "elements": [ + { + "type": "attribute", + "value": { + "name": "name", + "displayName": "Event Integration Name", + "inputType": "string", + "required": true, + "helpTip": "Unique identifier for the Polling event integration." + } + }, + { + "type": "attribute", + "value": { + "name": "class", + "displayName": "Class Name", + "inputType": "string", + "required": true, + "hidden": true, + "defaultValue": "org.wso2.carbon.inbound.custom.poll.SamplePollingInboundConsumer" + } + }, + { + "type": "attribute", + "value": { + "name": "generateSequences", + "displayName": "Automatically generate sequences", + "inputType": "checkbox", + "defaultValue": true + } + }, + { + "type": "attribute", + "value": { + "name": "sequence", + "displayName": "Injecting Sequence Name", + "inputType": "keyOrExpression", + "keyType": "sequence", + "required": true, + "enableCondition": [{"generateSequences":false}], + "helpTip": "Sequence to inject the SMS message" + } + }, + { + "type": "attribute", + "value": { + "name": "onError", + "displayName": "Error Sequence Name", + "inputType": "keyOrExpression", + "keyType": "sequence", + "required": false, + "enableCondition": [{"generateSequences":false}], + "helpTip": "Error sequence to invoke on fault" + } + } + ] + } + }, + { + "type": "attributeGroup", + "value": { + "groupName": "Inbound Functional", + "elements": [ + { + "type": "attribute", + "value": { + "name": "inbound.behavior", + "displayName": "Inbound behavior", + "hidden": true, + "inputType": "string", + "defaultValue": "polling", + "required": true, + "helpTip": "Inbound behavior" + } + }, + { + "type": "attribute", + "value": { + "name": "sequential", + "displayName": "Execute sequentially", + "inputType": "checkbox", + "defaultValue": true, + "required": false, + "helpTip": "The behaviour when executing the given sequence." + } + }, + { + "type": "attribute", + "value": { + "name": "coordination", + "displayName": "Coordination", + "inputType": "checkbox", + "defaultValue": true, + "required": false, + "helpTip": "In a clustered setup, this will run the inbound only in a single worker node." + } + }, + { + "type": "attribute", + "value": { + "name": "suspend", + "displayName": "Suspend Inbound", + "inputType": "checkbox", + "defaultValue": false, + "hidden": false, + "required": false, + "helpTip": "Enable this option to suspend the inbound endpoint immediately after deployment." + } + } + ] + } + }, + { + "type": "attributeGroup", + "value": { + "groupName": "Configuration Group 01", + "elements": [ + { + "type": "attribute", + "value": { + "name": "config1", + "displayName": "Sample Listener Inbound configuration 1", + "inputType": "string", + "required": true, + "helpTip": "Unique identifier for the Sample listener configuration." + } + }, + { + "type": "attribute", + "value": { + "name": "config2", + "displayName": "Sample Listener Inbound configuration 2", + "inputType": "string", + "required": false, + "helpTip": "Unique identifier for the Sample listener configuration." + } + } + ] + } + } + ] +} diff --git a/en/docs/develop/customizations/creating-custom-inbound-endpoint.md b/en/docs/develop/customizations/creating-custom-inbound-endpoint.md index d1f7c9eee..fc2700bce 100644 --- a/en/docs/develop/customizations/creating-custom-inbound-endpoint.md +++ b/en/docs/develop/customizations/creating-custom-inbound-endpoint.md @@ -8,62 +8,233 @@ To support such scenarios, you can write your own custom inbound endpoint by ext ### Step 1: Develop the custom inbound endpoint -- To create a **custom listening inbound endpoint**, download the maven artifact used in theĀ [sample custom listening inbound endpoint configuration](https://github.com/wso2-docs/ESB/tree/master/ESB-Artifacts/inbound/custom_inbound_listening) configuration. - -- To create a **custom polling inbound endpoint**, download the maven artifact used in the [sample custom polling inbound endpoint configuration](https://github.com/wso2-docs/ESB/tree/master/ESB-Artifacts/inbound/custom_inbound). - -- To create a **custom event-based inbound endpoint**, download the maven artifact used in theĀ [sample custom event-based inbound endpoint configuration](https://github.com/wso2-docs/ESB/tree/master/ESB-Artifacts/inbound/custom_inbound_waiting). - -### Step 2: Deploy the custom inbound endpoint - -You need to copy the built jar file to the `MI_HOME/lib` directory and restart the WSO2 Integrator: MI to load the class. -To add the jar file via your integration project, copy it to the lib directory under the deployment directory in the **Explorer** view of the VSCode or add the maven dependency of the jar file to the pom.xml file of the project. - -### Step 3: Add the custom inbound endpoint - -1. If you have already created an [Integration Project]({{base_path}}/develop/create-integration-project), click the `+` button in the **Inbound Endpoints** section of the **WSO2 Integrator: MI: Project Explorer** and select **Custom**. This will open a form. -2. Give a unique name to the inbound endpoint and update the rest of the properties with the required details as follows: - - - - - - - - - - - - - - - - - - - - - - - - - -
-

Property Name

-
-

Description

-
- Sequence - Name of the sequence message that should be injected. Select the appropriate sequence from the drop-down menu. If you have not created sequences for your project yet, please create them first.
- onError - Name of the fault sequence that should be invoked in case of failure. Select the appropriate error sequence from the drop-down menu.
- class - - Name of the custom class you implemented in step 1. -
- inbound.behavior - - Specify whether your custom endpoint is listening, polling, or event-based. -
-3. Add any required parameters by clicking the **Add Parameter** button. Depending on the type of inbound endpoint (e.g., Kafka, HTTP), you may need to add additional parameters specific to the protocol or technology you are integrating with. -4. Click **Create** to add the custom inbound endpoint to the project. +You can use the sample custom inbound endpoint projects as a template to develop your custom inbound endpoint. Kindly focus on the relevant method descriptions in implementation. +Depending on the type of inbound endpoint you want to create, download the relevant maven artifact from the links given below: + +- To create a **custom listening inbound endpoint**, download the maven artifact used in the [sample custom listening inbound endpoint configuration](https://github.com/wso2/docs-mi/tree/main/custom_inbound_listening). + +- To create a **custom polling inbound endpoint**, download the maven artifact used in the [sample custom polling inbound endpoint configuration](https://github.com/wso2/docs-mi/tree/main/custom_inbound_polling). + +- To create a **custom event-based inbound endpoint**, download the maven artifact used in the [sample custom event-based inbound endpoint configuration](https://github.com/wso2/docs-mi/tree/main/custom_inbound_event_based). + +!!! note "Files to Modify" + + The following files need to be modified when developing your custom inbound endpoint. + + --- + + **1. connector.xml** + + *Purpose:* Defines the connector component metadata. + + *What to modify:* + + - `component name`: Give a preferred name to your inbound endpoint + - `package`: Update to match your Java package structure + - `description`: Provide a meaningful description of your inbound endpoint + + *Example:* + + ```xml + + Your Custom Inbound Endpoint Description + + ``` + + --- + + **2. descriptor.yml** + + *Purpose:* Specifies Maven dependencies and repositories for your connector. + + *What to modify:* + + - Parameters are inherited from `filter.properties` using placeholders. + - Add additional dependencies if your inbound endpoint requires external libraries + + *Example:* + + ```yaml + dependencies: + - groupId: "${custom.inbound.groupId}" + artifactId: "${custom.inbound.artifactId}" + version: "${custom.inbound.version}" + - groupId: "com.external.library" + artifactId: "library-name" + version: "1.0.0" + ``` + + You can also add custom repositories if needed. + + --- + + **3. filter.properties** + + *Purpose:* Defines property values that will be substituted into `descriptor.yml` during build. + + *What to modify:* + + - Default properties reference Maven project properties (usually keep as-is) + - Add any custom parameters defined in `descriptor.yml` + + *Example:* + + ```ini + custom.inbound.groupId=${project.groupId} + custom.inbound.artifactId=${project.artifactId} + custom.inbound.version=${project.version} + + # Add custom properties here + custom.property.name=custom.value + ``` + + --- + + **4. uischema.json** + + *Purpose:* Defines the UI schema for the Integration Studio graphical editor. + + **a. Basic Identifiers** + + Update the basic identification fields: + + ```json + { + "id": "org.wso2.carbon.inbound.custom.poll.SamplePollingInboundConsumer", + "name": "SamplePollingInboundConsumer", + "type": "event-integration", + "title": "SamplePollingInboundConsumer", + "help": "Configuration of Sample Polling Inbound Endpoint", + "elements": [] + } + ``` + + **b. Generic Configurations** + + Update the `name` attribute to reflect your inbound endpoint's name: + + ```json + { + "type": "attribute", + "value": { + "name": "name", + "displayName": "Event Integration Name", + "inputType": "string", + "required": true, + "helpTip": "Unique identifier for the Polling event integration." + } + } + ``` + Update the hidden `class` attribute with your fully qualified class name: + + ```json + { + "type": "attribute", + "value": { + "name": "class", + "displayName": "Class Name", + "inputType": "string", + "required": true, + "hidden": true, + "defaultValue": "org.wso2.carbon.inbound.custom.poll.SamplePollingInboundConsumer" + } + } + ``` + + !!! Important + - Keep other attributes in `Generic` and `Inbound Functional` groups unchanged. + - The `class` attribute in `uischema.json` must exactly match your Java implementation class. + + **c. Custom Configuration Attributes** + + Replace configuration groups with your actual settings. Each attribute defines a UI form field and you can add any number of configuration groups and attributes as necessary. + + ```json + { + "type": "attributeGroup", + "value": { + "groupName": "Connection Settings", + "elements": [ + { + "type": "attribute", + "value": { + "name": "hostname", + "displayName": "Host Name", + "inputType": "string", + "required": true, + "helpTip": "The hostname to connect to" + } + } + ] + } + } + ``` + + !!! Tip + - Use `hidden: true` for attributes that shouldn't appear in the UI + - Use `enableCondition` to show/hide fields based on other field values + + **d. Input Types Available** + + The following input types are available for form fields: + + - `string`: Text input field + - `checkbox`: Boolean checkbox + - `keyOrExpression`: Dropdown for sequences/keys + + You can also add validation attributes to any field: + + - `required`: Mark field as mandatory + - `defaultValue`: Set a default value + - `hidden`: Hide field from UI + - `enableCondition`: Show/hide field based on other field values + + --- + + **5. zip-assembly.xml** + + *Purpose:* Defines how the connector package is assembled. + + *What to modify:* + + - Usually no changes needed unless you have additional resources + - Add custom resource files if required + + *Example:* + + ```xml + + src/main/resources/custom-config.properties + /resources + + ``` + + +### Step 2: Build the custom inbound endpoint + +You need to build the developed custom inbound endpoint using Maven to generate the inbound zip file. +The following command builds the project and creates the zip file in the `/target` folder. + +```bash + mvn clean install +``` + +### Step 3: Add the custom inbound endpoint to your integration project + +1. If you have already created an [Integration Project]({{base_path}}/develop/create-integration-project), Go to 'File Explorer'. + + !!! Tip + - If you have not created an integration project yet, refer to [Creating an Integration Project]({{base_path}}/develop/create-integration-project) to create one first. + +2. Then navigate to 'src/main/wso2mi/resources' directory of your integration project. +3. Then create a folder named `inbound-connectors` inside the `/resources` folder if it does not already exist. +4. Copy the generated zip file from the `/target` folder of your custom inbound endpoint project to the `/inbound-connectors` folder you created in the previous step. +5. Then your custom inbound endpoint will be listed under Event Integration List. + +### Step 4: Create an inbound endpoint +1. Click on the WSO2 Integrator: MI icon on the Activity Bar of the VS Code editor. + Create New Project +2. In the Add Artifact interface, under Create an Integration, click Event Integration. This will open the list of event integrations available in WSO2 Integrator: MI. + Create New Project +3. Select your custom inbound from the list. +4. In the Create Event Integration form, provide the required details for your inbound endpoint and click `Create`. diff --git a/en/docs/install-and-setup/setup/deployment/deploying-wso2-mi.md b/en/docs/install-and-setup/setup/deployment/deploying-wso2-mi.md index 2d6ec876d..3a4487422 100644 --- a/en/docs/install-and-setup/setup/deployment/deploying-wso2-mi.md +++ b/en/docs/install-and-setup/setup/deployment/deploying-wso2-mi.md @@ -249,9 +249,9 @@ See [deployment synchronization]({{base_path}}/install-and-setup/setup/deploymen ## Registry synchronization (sharing) !!! Note - Registry sharing is only required if you have Message Processors in your deployment. + Registry sharing is only required if you have Message Processors or inbound endpoints in your deployment. -The shared registry maintains the state (active/inactive) of the Message Processor artifact. This ensures that the same state is maintained for Message Processor in all the WSO2 Integrator: MI nodes of the cluster. +The shared registry maintains the state (active/inactive) of the Message Processor/inbound endpoint artifact. This ensures that the same state is maintained for Message Processor/inbound endpoint in all the WSO2 Integrator: MI nodes of the cluster. 1. Follow the instructions on [configuring the file-based registry]({{base_path}}/install-and-setup/setup/deployment/file-based-registry) for a two-node deployment of the WSO2 Integrator: MI. 2. The `/registry` folder of each node in the cluster should be shared with each other. You can follow the same instructions as for [deployment synchronization]({{base_path}}/install-and-setup/setup/deployment/deployment-synchronization).