Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions PEKKO_UPGRADE_README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# Apache Pekko 1.0.3 Upgrade

## Overview

This document describes the upgrade of sunbird-utils repository from Akka 2.5.19 to Apache Pekko 1.0.3.

## Why This Upgrade

1. License Compliance: Akka changed from Apache 2.0 to Business Source License 1.1, requiring commercial licenses for production use. Apache Pekko maintains Apache 2.0 license.
2. Security: Akka 2.5.19 no longer receives security updates.
3. Modernization: Access to latest features and performance improvements.

## Technology Stack Changes

- Actor Framework: Akka 2.5.19 to Apache Pekko 1.0.3
- Scala: 2.11 to 2.13
- Jackson Module Scala: 2.10.1 to 2.14.3

## Key Changes

### Dependencies

All Maven POM files updated with new versions. Scala library exclusions added to prevent version conflicts between Scala 2.11 and 2.13.

Updated POM files:
- sunbird-platform-core/actor-core/pom.xml
- sunbird-platform-core/actor-util/pom.xml
- sunbird-platform-core/common-util/pom.xml
- sunbird-es-utils/pom.xml

### Source Code

Akka imports migrated to Pekko across all Java files:
- akka.actor to org.apache.pekko.actor
- akka.pattern to org.apache.pekko.pattern
- akka.routing to org.apache.pekko.routing
- akka.util to org.apache.pekko.util
- akka.dispatch to org.apache.pekko.dispatch

### Configuration

Configuration references updated from akka to pekko namespaces:
- akka.actor.provider to pekko.actor.provider
- akka.remote.RemoteActorRefProvider to org.apache.pekko.remote.RemoteActorRefProvider
- akka.remote.netty.tcp to pekko.remote.artery
- akka:// protocol references to pekko://

### Scala Version Handling

Added exclusions to prevent Scala 2.11 transitive dependencies:
- Excluded scala-library and scala-reflect from cloud-store-sdk in common-util
- Explicitly declared scala-library 2.13.12 dependency across all modules

## Build Instructions

Build all modules:
```
mvn clean install -DskipTests
```

Build with tests:
```
mvn clean install
```

Check dependency tree for verification:
```
mvn dependency:tree
```

## Migration Impact

Business Logic: No changes to business logic or functionality
API Compatibility: Maintained, as Pekko is API-compatible with Akka
Code Changes: Primarily package name updates from akka to pekko
License: Now compliant with Apache 2.0 throughout the stack

## Verification

After upgrade, verify:
1. Build succeeds without errors
2. No Akka dependencies remain: mvn dependency:tree | grep akka
3. Pekko dependencies present: mvn dependency:tree | grep pekko
4. All tests pass

## Known Issues

Scala 2.11/2.13 Conflict: If you encounter NoClassDefFoundError for scala.collection classes, verify dependency tree to ensure no Scala 2.11 artifacts are present. Run mvn dependency:tree and add exclusions for any scala-library or scala-reflect with version 2.11.
12 changes: 12 additions & 0 deletions sunbird-es-utils/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<scoverage.plugin.version>1.1.1</scoverage.plugin.version>
<pekko.version>1.0.3</pekko.version>
<scala.binary.version>2.13</scala.binary.version>
</properties>
<dependencies>
<!-- added for rest client -->
Expand All @@ -37,6 +39,16 @@
<artifactId>log4j-core</artifactId>
<version>2.8.2</version>
</dependency>
<dependency>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-actor_${scala.binary.version}</artifactId>
<version>${pekko.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.13.12</version>
</dependency>
<dependency>
<groupId>org.sunbird</groupId>
<artifactId>common-util</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static org.sunbird.common.models.util.ProjectUtil.isNotNull;

import akka.util.Timeout;
import org.apache.pekko.util.Timeout;
import com.typesafe.config.Config;
import java.math.BigInteger;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.sunbird.common;

import akka.dispatch.Futures;
import org.apache.pekko.dispatch.Futures;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.sunbird.common;

import akka.dispatch.Futures;
import akka.util.Timeout;
import org.apache.pekko.dispatch.Futures;
import org.apache.pekko.util.Timeout;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import static org.sunbird.common.models.util.ProjectUtil.isNotNull;

import akka.dispatch.Futures;
import org.apache.pekko.dispatch.Futures;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.typesafe.config.Config;
import java.io.IOException;
Expand Down
26 changes: 16 additions & 10 deletions sunbird-platform-core/actor-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
<scoverage.plugin.version>1.1.1</scoverage.plugin.version>
<slf4j.version>1.6.1</slf4j.version>
<logback.version>1.0.7</logback.version>
<learner.akka.version>2.5.19</learner.akka.version>
<pekko.version>1.0.3</pekko.version>
<scala.binary.version>2.13</scala.binary.version>
</properties>
<dependencies>
<dependency>
Expand All @@ -24,19 +25,24 @@
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId>
<version>${learner.akka.version}</version>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-actor_${scala.binary.version}</artifactId>
<version>${pekko.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-slf4j_2.11</artifactId>
<version>${learner.akka.version}</version>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-slf4j_${scala.binary.version}</artifactId>
<version>${pekko.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-remote_2.11</artifactId>
<version>${learner.akka.version}</version>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-remote_${scala.binary.version}</artifactId>
<version>${pekko.version}</version>
</dependency>
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.13.12</version>
</dependency>
<dependency>
<groupId>org.reflections</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.sunbird.actor.core;

import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.UntypedAbstractActor;
import akka.util.Timeout;
import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.actor.ActorSelection;
import org.apache.pekko.actor.UntypedAbstractActor;
import org.apache.pekko.util.Timeout;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import com.typesafe.config.ConfigValue;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.sunbird.actor.core;

import akka.actor.ActorRef;
import akka.actor.Props;
import akka.routing.FromConfig;
import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.actor.Props;
import org.apache.pekko.routing.FromConfig;
import java.util.Set;
import org.apache.commons.lang3.StringUtils;
import org.reflections.Reflections;
Expand All @@ -26,7 +26,7 @@ public abstract class BaseRouter extends BaseActor {
public void onReceive(Request request) throws Throwable {
String senderPath = sender().path().toString();
if (RouterMode.LOCAL.name().equalsIgnoreCase(getRouterMode())
&& !StringUtils.startsWith(senderPath, "akka://")) {
&& !StringUtils.startsWith(senderPath, "pekko://")) {
throw new RouterException(
"Invalid invocation of the router. Processing not possible from: " + senderPath);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.sunbird.actor.router;

import akka.actor.ActorRef;
import org.apache.pekko.actor.ActorRef;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.sunbird.actor.router;

import akka.actor.ActorRef;
import akka.dispatch.OnComplete;
import akka.pattern.Patterns;
import akka.util.Timeout;
import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.dispatch.OnComplete;
import org.apache.pekko.pattern.Patterns;
import org.apache.pekko.util.Timeout;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -96,7 +96,7 @@ public void onComplete(Throwable failure, Object result) {
ProjectLogger.log(failure.getMessage(), failure);
if (failure instanceof ProjectCommonException) {
parent.tell(failure, self());
} else if (failure instanceof akka.pattern.AskTimeoutException) {
} else if (failure instanceof org.apache.pekko.pattern.AskTimeoutException) {
ProjectCommonException exception =
new ProjectCommonException(
ResponseCode.operationTimeout.getErrorCode(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package org.sunbird.actor.service;

import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import akka.actor.ActorSystem;
import akka.actor.Props;
import akka.routing.FromConfig;
import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.actor.ActorSelection;
import org.apache.pekko.actor.ActorSystem;
import org.apache.pekko.actor.Props;
import org.apache.pekko.routing.FromConfig;
import com.typesafe.config.Config;
import com.typesafe.config.ConfigFactory;
import java.util.ArrayList;
Expand Down Expand Up @@ -83,10 +83,9 @@ protected static ActorSystem getActorSystem(String host, String port) {

protected static Config getRemoteConfig(String host, String port) {
List<String> details = new ArrayList<String>();
details.add("akka.actor.provider=akka.remote.RemoteActorRefProvider");
details.add("akka.remote.enabled-transports = [\"akka.remote.netty.tcp\"]");
if (StringUtils.isNotBlank(host)) details.add("akka.remote.netty.tcp.hostname=" + host);
if (StringUtils.isNotBlank(port)) details.add("akka.remote.netty.tcp.port=" + port);
details.add("pekko.actor.provider=org.apache.pekko.remote.RemoteActorRefProvider");
details.add("pekko.remote.artery.canonical.hostname=" + (StringUtils.isNotBlank(host) ? host : "127.0.0.1"));
details.add("pekko.remote.artery.canonical.port=" + (StringUtils.isNotBlank(port) ? port : "25520"));

return ConfigFactory.parseString(StringUtils.join(details, ","));
Copy link

Copilot AI Nov 10, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The HOCON configuration format requires newlines or proper delimiters between properties, not commas. Using commas as delimiters will cause parsing errors. Change StringUtils.join(details, \",\") to StringUtils.join(details, \"\\n\") to properly format the configuration string.

Suggested change
return ConfigFactory.parseString(StringUtils.join(details, ","));
return ConfigFactory.parseString(StringUtils.join(details, "\n"));

Copilot uses AI. Check for mistakes.
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.sunbird.actor.service;

import akka.actor.ActorRef;
import akka.actor.ActorSelection;
import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.actor.ActorSelection;
import org.sunbird.actor.router.BackgroundRequestRouter;
import org.sunbird.actor.router.RequestRouter;
import org.sunbird.common.models.util.JsonKey;
Expand Down
23 changes: 12 additions & 11 deletions sunbird-platform-core/actor-util/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,31 @@

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<learner.akka.version>2.5.19</learner.akka.version>
<pekko.version>1.0.3</pekko.version>
<scala.binary.version>2.13</scala.binary.version>
</properties>

<dependencies>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-actor_2.11</artifactId>
<version>${learner.akka.version}</version>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-actor_${scala.binary.version}</artifactId>
<version>${pekko.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-slf4j_2.11</artifactId>
<version>${learner.akka.version}</version>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-slf4j_${scala.binary.version}</artifactId>
<version>${pekko.version}</version>
</dependency>
<dependency>
<groupId>com.typesafe.akka</groupId>
<artifactId>akka-remote_2.11</artifactId>
<version>${learner.akka.version}</version>
<groupId>org.apache.pekko</groupId>
<artifactId>pekko-remote_${scala.binary.version}</artifactId>
<version>${pekko.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.scala-lang/scala-library -->
<dependency>
<groupId>org.scala-lang</groupId>
<artifactId>scala-library</artifactId>
<version>2.11.11</version>
<version>2.13.12</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.sunbird.actorutil;

import akka.actor.ActorRef;
import org.apache.pekko.actor.ActorRef;
import org.sunbird.common.request.Request;
import scala.concurrent.Future;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.sunbird.actorutil.courseenrollment;

import akka.actor.ActorRef;
import org.apache.pekko.actor.ActorRef;
import java.util.Map;
import org.sunbird.common.models.response.Response;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.sunbird.actorutil.courseenrollment.impl;

import akka.actor.ActorRef;
import org.apache.pekko.actor.ActorRef;
import java.util.Map;
import org.sunbird.actorutil.InterServiceCommunication;
import org.sunbird.actorutil.InterServiceCommunicationFactory;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.sunbird.actorutil.email;

import akka.actor.ActorRef;
import org.apache.pekko.actor.ActorRef;
import java.util.Map;
import org.sunbird.common.models.response.Response;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package org.sunbird.actorutil.email.impl;

import akka.actor.ActorRef;
import org.apache.pekko.actor.ActorRef;
import java.util.HashMap;
import java.util.Map;
import org.sunbird.actorutil.InterServiceCommunication;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package org.sunbird.actorutil.impl;

import akka.actor.ActorRef;
import akka.pattern.Patterns;
import akka.util.Timeout;
import org.apache.pekko.actor.ActorRef;
import org.apache.pekko.pattern.Patterns;
import org.apache.pekko.util.Timeout;
import java.util.concurrent.TimeUnit;
import org.sunbird.actorutil.InterServiceCommunication;
import org.sunbird.common.exception.ProjectCommonException;
Expand Down
Loading