Skip to content

Commit

Permalink
Disable existing transaction counter
Browse files Browse the repository at this point in the history
  • Loading branch information
IsuruMaduranga committed Nov 1, 2023
1 parent 06c15ef commit b81ae6e
Show file tree
Hide file tree
Showing 12 changed files with 40 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,6 @@ public boolean invoke(Object object, String name) throws SynapseException {
}
axis2MsgCtx.setProperty(MessageContext.TRANSPORT_HEADERS, transportHeaders);

// set transaction property
axis2MsgCtx.setProperty(BaseConstants.INTERNAL_TRANSACTION_COUNTED,
msg.getBooleanProperty(BaseConstants.INTERNAL_TRANSACTION_COUNTED));
// set the JMS Message ID as the Message ID of the MessageContext
try {
if (msg.getJMSMessageID() != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,6 @@ public static Map<String, Object> getTransportHeaders(Message message, MessageCo
log.error("Error while reading the Transport Headers from JMS Message", e);
}

// remove "INTERNAL_TRANSACTION_COUNTED" header from the transport level headers map.
// this property will be maintained in the message context. Therefore, no need to set this in the transport
// headers.
map.remove(BaseConstants.INTERNAL_TRANSACTION_COUNTED);
return map;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,10 @@ public ManagementInternalApi() {
resourcesList.add(new ApiResourceAdapter(PREFIX_LOGOUT, new LogoutResource()));
resourcesList.add(new ApiResourceAdapter(PREFIX_SERVER_DATA, new MetaDataResource()));
resourcesList.add(new LogFilesResource(PREFIX_LOG_FILES));
resourcesList.add(new ApiResourceAdapter(PREFIX_TRANSACTION + PATH_PARAM_TRANSACTION,
new RequestCountResource()));

// Disabling this API as the this version of transaction counter is deprecated.
// resourcesList.add(new ApiResourceAdapter(PREFIX_TRANSACTION + PATH_PARAM_TRANSACTION, new RequestCountResource()));

resourcesList.add(new ExternalVaultResource(PREFIX_EXTERNAL_VAULTS
+ PATH_PARAM_EXTERNAL_VAULT_NAME));
resourcesList.add(new ApiResourceAdapter(PREFIX_DATA_SOURCES, new DataSourceResource()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@
import org.wso2.micro.integrator.initializer.deployment.application.deployer.CappDeployer;
import org.wso2.micro.integrator.initializer.handler.ProxyLogHandler;
import org.wso2.micro.integrator.initializer.handler.SynapseExternalPropertyConfigurator;
import org.wso2.micro.integrator.initializer.handler.transaction.TransactionCountHandler;
import org.wso2.micro.integrator.initializer.handler.transaction.TransactionCountHandlerComponent;
import org.wso2.micro.integrator.initializer.persistence.MediationPersistenceManager;
import org.wso2.micro.integrator.initializer.services.SynapseConfigurationService;
import org.wso2.micro.integrator.initializer.services.SynapseConfigurationServiceImpl;
Expand All @@ -80,10 +78,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.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

Expand Down Expand Up @@ -111,9 +106,9 @@ public class ServiceBusInitializer {

private DataSourceService dataSourceService;

private TransactionCountHandlerComponent transactionCountHandlerComponent;

private ExecutorService transactionCountExecutor;
// This implementation of transaction counter is deprecated
// private TransactionCountHandlerComponent transactionCountHandlerComponent;
// private ExecutorService transactionCountExecutor;

@Activate
protected void activate(ComponentContext ctxt) {
Expand Down Expand Up @@ -198,14 +193,14 @@ protected void activate(ComponentContext ctxt) {
synapseEnvironment.registerSynapseHandler(new SynapseExternalPropertyConfigurator());
synapseEnvironment.registerSynapseHandler(new ProxyLogHandler());

// Register internal transaction synapse handler
boolean transactionPropertyEnabled = TransactionCountHandlerComponent.isTransactionPropertyEnabled();
if (transactionPropertyEnabled) {
transactionCountHandlerComponent = new TransactionCountHandlerComponent();
transactionCountHandlerComponent.start(dataSourceService);
transactionCountExecutor = Executors.newFixedThreadPool(100);
synapseEnvironment.registerSynapseHandler(new TransactionCountHandler(transactionCountExecutor));
}
// This implementation of transaction counter is deprecated
// boolean transactionPropertyEnabled = TransactionCountHandlerComponent.isTransactionPropertyEnabled();
// if (transactionPropertyEnabled) {
// transactionCountHandlerComponent = new TransactionCountHandlerComponent();
// transactionCountHandlerComponent.start(dataSourceService);
// transactionCountExecutor = Executors.newFixedThreadPool(100);
// synapseEnvironment.registerSynapseHandler(new TransactionCountHandler(transactionCountExecutor));
// }
if (log.isDebugEnabled()) {
log.debug("SynapseEnvironmentService Registered");
}
Expand Down Expand Up @@ -260,12 +255,15 @@ private String getMainSequenceName(String cappName) {

@Deactivate
protected void deactivate(ComponentContext ctxt) {
if (Objects.nonNull(transactionCountHandlerComponent)) {
transactionCountHandlerComponent.cleanup();
}
if (Objects.nonNull(transactionCountExecutor)) {
transactionCountExecutor.shutdownNow();
}

// This implementation of transaction counter is deprecated
// if (Objects.nonNull(transactionCountHandlerComponent)) {
// transactionCountHandlerComponent.cleanup();
// }
// if (Objects.nonNull(transactionCountExecutor)) {
// transactionCountExecutor.shutdownNow();
// }

List handlers = serverManager.getServerContextInformation().getSynapseEnvironment().getSynapseHandlers();
Iterator<SynapseHandler> iterator = handlers.iterator();
while (iterator.hasNext()) {
Expand Down
1 change: 1 addition & 0 deletions distribution/src/dbscripts/db2/db2_transaction_count.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- Related to the deprecated transaction count feature
CREATE TABLE IF NOT EXISTS CURRENT_STATS (
TIME_STAMP DATE NOT NULL,
NODE_ID VARCHAR(40) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- Related to the deprecated transaction count feature
IF NOT EXISTS (SELECT * FROM SYS.OBJECTS WHERE OBJECT_ID = OBJECT_ID(N'[DBO].[CURRENT_STATS]') AND TYPE IN (N'U'))
CREATE TABLE CURRENT_STATS (
TIME_STAMP DATE NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- Related to the deprecated transaction count feature
CREATE TABLE IF NOT EXISTS CURRENT_STATS (
TIME_STAMP DATE NOT NULL,
NODE_ID VARCHAR(40) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- Related to the deprecated transaction count feature
CREATE TABLE CURRENT_STATS (
TIME_STAMP DATE NOT NULL,
NODE_ID VARCHAR(40) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- Related to the deprecated transaction count feature
CREATE TABLE CURRENT_STATS (
TIME_STAMP DATE NOT NULL,
NODE_ID VARCHAR(40) NOT NULL,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
-- Related to the deprecated transaction count feature
CREATE TABLE IF NOT EXISTS CURRENT_STATS (
TIME_STAMP DATE NOT NULL,
NODE_ID VARCHAR(40) NOT NULL,
Expand Down
10 changes: 5 additions & 5 deletions distribution/src/resources/config-tool/deployment-full.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1099,11 +1099,11 @@ user.password = "pwd-2"
enable = false

#################### Transaction Counter Handler ############################
[transaction_counter]
enable = true
data_source = "WSO2_COORDINATION_DB"
update_interval = 2

# This implementation of transaction counter is deprecated
#[transaction_counter]
#enable = true
#data_source = "WSO2_COORDINATION_DB"
#update_interval = 2

#################### Service Catalog #######################################
[[service_catalog]]
Expand Down
7 changes: 5 additions & 2 deletions integration/mediation-tests/tests-platform/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@
<module>tests-rabbitmq</module>
<module>tests-coordination</module>
<module>tests-userstore</module>
<module>tests-transaction</module>
<!-- <module>tests-wso2mb</module>-->

<!-- This implementation of transaction counter is deprecated -->
<!--<module>tests-transaction</module>-->

<!--<module>tests-wso2mb</module>-->
<!--<module>tests-sap</module>-->
</modules>

Expand Down

0 comments on commit b81ae6e

Please sign in to comment.