Skip to content

Commit

Permalink
Merge pull request #3042 from IsuruMaduranga/transactional-pricing
Browse files Browse the repository at this point in the history
Integrate transaction counter with MI
  • Loading branch information
isudana authored Dec 4, 2023
2 parents c273010 + 3cb8ca8 commit 40b20ef
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 0 deletions.
4 changes: 4 additions & 0 deletions components/org.wso2.micro.integrator.initializer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,10 @@
<groupId>org.wso2.ei</groupId>
<artifactId>org.wso2.micro.integrator.observability</artifactId>
</dependency>
<dependency>
<groupId>org.wso2.integration.transaction.counter</groupId>
<artifactId>transaction-count-handler</artifactId>
</dependency>
</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,11 @@
import org.osgi.service.component.annotations.ReferencePolicy;
import org.wso2.carbon.inbound.endpoint.EndpointListenerLoader;
import org.wso2.carbon.securevault.SecretCallbackHandlerService;
import org.wso2.config.mapper.ConfigParser;
import org.wso2.micro.application.deployer.CarbonApplication;
import org.wso2.micro.core.Constants;
import org.wso2.micro.core.ServerShutdownHandler;
import org.wso2.integration.transaction.counter.TransactionCountHandler;
import org.wso2.micro.integrator.core.services.Axis2ConfigurationContextService;
import org.wso2.micro.integrator.core.services.CarbonServerConfigurationService;
import org.wso2.micro.integrator.core.util.MicroIntegratorBaseUtils;
Expand Down Expand Up @@ -81,6 +83,7 @@
import java.nio.file.Paths;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Properties;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
Expand Down Expand Up @@ -219,6 +222,11 @@ protected void activate(ComponentContext ctxt) {
synapseEnvironment.registerSynapseHandler(new SynapseExternalPropertyConfigurator());
synapseEnvironment.registerSynapseHandler(new ProxyLogHandler());

// Register transaction counter handler
if (isTransactionCounterEnabled()) {
synapseEnvironment.registerSynapseHandler(new TransactionCountHandler());
log.debug("Transaction Count Handler registered");
}
if (log.isDebugEnabled()) {
log.debug("SynapseEnvironmentService Registered");
}
Expand Down Expand Up @@ -626,4 +634,13 @@ protected void setDatasourceHandlerService(DataSourceService dataSourceService)
protected void unsetDatasourceHandlerService(DataSourceService dataSourceService) {
this.dataSourceService = null;
}

private boolean isTransactionCounterEnabled() {
boolean transactionCounterEnabled = false;
Object object = ConfigParser.getParsedConfigs().get("integration.transaction_counter.enable");
if (Objects.nonNull(object)) {
transactionCounterEnabled = Boolean.parseBoolean(object.toString());
}
return transactionCounterEnabled;
}
}
16 changes: 16 additions & 0 deletions distribution/src/conf/deployment.toml
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,19 @@ algorithm = "AES"

# [dashboard_config]
# dashboard_url = "https://localhost:9743/dashboard/api/"

# [integration.transaction_counter]
# enable = true
# server_id = "MI_node_1"
# producer_counting_thread_pool_size = 10
# producer_scheduled_interval = 10
# max_transaction_count_per_record = 20
# min_transaction_count_per_record = 5
# record_queue_size = 1000
# publisher_scheduled_interval = 5
# publisher_max_batch_size = 100
# publisher_max_retries = 3
# store_impl = "org.wso2.integration.transaction.counter.store.TransactionRecordStoreImpl"
# service_url = "https://localhost:8080/transactions/records"
# service_username = "admin"
# service_password = "admin"
17 changes: 17 additions & 0 deletions distribution/src/resources/config-tool/deployment-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,23 @@ user.password = "pwd-2"
[internal_apis.file_user_store]
enable = false

#################### Transaction Counter Handler ############################
[integration.transaction_counter]
enable = true
server_id = "MI_node_1"
producer_counting_thread_pool_size = 10
producer_scheduled_interval = 10
max_transaction_count_per_record = 20
min_transaction_count_per_record = 5
record_queue_size = 1000
publisher_scheduled_interval = 5
publisher_max_batch_size = 100
publisher_max_retries = 3
store_impl = "org.wso2.integration.transaction.counter.store.TransactionRecordStoreImpl"
service_url = "https://localhost:8080/transactions/records"
service_username = "admin"
service_password = "admin"

#################### Service Catalog #######################################
[[service_catalog]]
apim_host = "https://127.0.0.1:9443"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@
<bundleDef>
org.wso2.ei:org.wso2.micro.integrator.transport.handlers:${project.version}
</bundleDef>
<bundleDef>
org.wso2.integration.transaction.counter:transaction-count-handler:${counter.org.wso2.integration.transaction.version}
</bundleDef>
<!--
Removed since not used for task deployment, this is mainly for admin service
<bundleDef>
Expand Down
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,7 @@
<groupId>org.wso2.ei</groupId>
<artifactId>org.wso2.micro.integrator.observability</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.wso2.orbit.debezium</groupId>
<artifactId>debezium</artifactId>
Expand All @@ -1449,6 +1450,11 @@
<artifactId>gson</artifactId>
<version>${version.com.google.code.gson}</version>
</dependency>
<dependency>
<groupId>org.wso2.integration.transaction.counter</groupId>
<artifactId>transaction-count-handler</artifactId>
<version>${counter.org.wso2.integration.transaction.version}</version>
</dependency>
</dependencies>
</dependencyManagement>

Expand Down Expand Up @@ -1677,6 +1683,9 @@
<javax.jsr311.api.version>1.1.1</javax.jsr311.api.version>
<org.wso2.orbit.javax.xml.bind.version>2.3.1.wso2v2</org.wso2.orbit.javax.xml.bind.version>

<!-- Transaction Counter -->
<counter.org.wso2.integration.transaction.version>1.0.0</counter.org.wso2.integration.transaction.version>

<config.mapper.version>1.0.20</config.mapper.version>
<javax.xml.parsers.import.pkg.version>[0.0.0, 1.0.0)</javax.xml.parsers.import.pkg.version>
<imp.pkg.version.javax.servlet>[2.6.0, 3.0.0)</imp.pkg.version.javax.servlet>
Expand Down

0 comments on commit 40b20ef

Please sign in to comment.