I have a Akka Actor application which works on localhost - mainly to run an
asynchronous batch job. Tests on localhost work as expected. However, when
deployed to AWS EC2, the actors don't start. I don't know what could be
work.
Below is the application main class and after it is the Actor class to star
object ApplicationMain {
def main(args: Array[String]): Unit = {
val system = ActorSystem("MyPIIScannerActorSystem")
val systemSupervisor = system.actorOf(Props[AppSupervisor],
"MyPIIScannerActorSystem")
val s3BucketName = System.getenv("MY_S3_BUCKET")
val s3Prefix = System.getenv("MY_S3_PREFIX")
require(!s3BucketName.isEmpty, "ENV Variable: MY_S3_BUCKET must be
available")
systemSupervisor ! Props(new ScanRequestActor(bucketName=s3BucketName,
s3Prefix = Some(s3Prefix)))
val objectScanRequestActor = system.actorOf(
Props(new ScanRequestActor(bucketName=s3BucketName, s3Prefix =
Some(s3Prefix)))
)
// initialize scan request on bucket
objectScanRequestActor ! ScanRequestActor.Initialize
System.setProperty("log4j2.debug", "")
ElasticWrapper.getClusterConnection().rest.close()
system.terminate()
}
}
Akka Actor class to start
class ScanRequestActor(val bucketName: String = null, val s3Prefix:
Option[String] = None)
extends Actor with ActorLogging {
import ScanRequestActor._
if (bucketName == null) {
throw new NullPointerException(s"Constructor AWS S3 BucketName cannot be
null or empty")
context.system.terminate()
}
val scanResultsActor = context.actorOf(ScanResultsActor.props,
"scanResultsActor")
def receive = {
case Initialize =>
log.info(s"Initialied S3 Scan Request on " +
s"Bucket: ${bucketName} and Prefix: ${s3Prefix.orNull} ")
// do bucket scanning here and send message to ScanResultsActor
val scanRequestMessage = BaseClassifier.setS3ScanInputPath(bucketName,
s3Prefix.orNull)
scanResultsActor ! ScanRequestMessage(scanRequestMessage)
case ScanResultsActor.ScanResultsMessage(text) =>
log.info("In ScanResultsActor - received message: {}", text)
context.system.terminate()
}
}
object ScanRequestActor {
val props: Props = Props[ScanRequestActor]
case object Initialize
case class ScanRequestMessage(fullScanStats: FullScanStats)
}
Enter code here...
Is there anything I am doing wrong?
Thanks in advance
--
*****************************************************************************************************
** New discussion forum: https://discuss.akka.io/ replacing akka-user
google-group soon.
** This group will soon be put into read-only mode, and replaced by
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*****************************************************************************************************
>>>>>>>>>>
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ:
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.