0

I have a Main program that queries data from DB using slick. It constructs JSON from the record it gets from DB and then publishes to some kafka topics. Almost at the end of the program, I m trying to call a stored procedure that updates the records.

My code looks like this :

implicit val system: ActorSystem = ActorSystem()
implicit val mat: ActorMaterializer = ActorMaterializer()
implicit val ec = system.dispatcher

implicit val session: SlickSession = SlickSession.forConfig("blwl-mysql")

def myProcedure() = {
   sqlu"""CALL `dbName`.`update_history();"""
}

then

 for {
      record1 <- selectQuery1
      record2 <- selectQuery2 
     // create JSON and publish to kafka, this is done using akka streams to get list of Future[Done]
     topicsExecuted: List[Done] <- topicsExecutedF
     procedureExecuted: Int <- session.db.run(myProcedure)
     _ = println("is successfully executed ::::"+ procedureExecuted)
   } 
    {
       session.close()
       system.terminate()
    }

procedureExecuted prints some value and confirms that the procedure is executed however, it does not end the main program.

If I remove the procedure call, the programs ends fine. I also converted the procedure call to a JDBC statement, which is synchronous and that also works fine. But when I try to call the procedure using Async code (something that returns Future), program does not end somehow.

These are my library specifications :

  Manifest-Version: 1.0
  Implementation-Title: akka-stream-alpakka-slick
  Automatic-Module-Name: akka.stream.alpakka.slick
  Implementation-Version: 1.0-M1
  Specification-Vendor: Lightbend Inc.
  Specification-Title: akka-stream-alpakka-slick
  Implementation-Vendor-Id: com.lightbend.akka
  Specification-Version: 1.0-M1
  Implementation-URL: https://github.com/akka/alpakka
  Implementation-Vendor: Lightbend Inc.



     
     
user9920500
  • 606
  • 7
  • 21
  • What is in `myProcedure`? What do you mean "`procedureExecuted` prints some value and confirms that the procedure is executed" - it's Int, it cannot print anything ;) Show more code please – amorfis Jun 29 '21 at 08:23
  • Thanks for replying, I have now updated the question. "myProcedure" is just a Call procedure statement. If I run the same procedure in database, It executes correct. It contains some update logic. – user9920500 Jun 29 '21 at 09:05

0 Answers0