You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Akka持久化快照存储配置错误:求插件类配置值及补充配置

Fixing Your Akka Persistence Configuration & Code Issues

Hey there! Let's walk through fixing your Akka Persistence setup step by step—you're close, just a couple of small tweaks needed.

1. Fix the Snapshot Store Class & Config Typo

First, let's tackle the error you're seeing: the snapshot store class is missing, and there's a sneaky typo in your config that's making things worse.

The Issues

  • You have a typo: snaphot-store should be snapshot-store (you missed an 's' in two places)
  • The required akka.persistence.snapshot-store.local.class property needs the fully qualified class name of Akka's built-in local snapshot store implementation.

Corrected reference.conf

akka.persistence.journal.plugin="akka.persistence.journal.leveldb"
akka.persistence.snapshot-store.plugin="akka.persistence.snapshot-store.local"  # Fixed typo here
akka.persistence.journal.leveldb.dir="target/sample/leveldb"
akka.persistence.snapshot-store.local.dir="target/sample/snapshots"  # Fixed typo here
akka.persistence.journal.leveldb.native=off
akka.persistence.snapshot-store.local.class="akka.persistence.snapshot.local.LocalSnapshotStore"  # Added correct class

What Each Config Does

  • akka.persistence.journal.leveldb.dir: Defines where LevelDB saves its journal files
  • akka.persistence.snapshot-store.local.dir: Sets the disk location for snapshot files
  • akka.persistence.journal.leveldb.native=off: Uses the Java-based LevelDB implementation (avoids platform-specific native dependencies)
  • akka.persistence.snapshot-store.local.class: Points to Akka's official local snapshot store implementation

2. Fix Message Sending in Your Main Class

Looking at your main class code, you're sending Increment(3) directly to the actor—but your Counter's receiveCommand only handles Cmd(op) messages. Those raw Increment/Decrement messages are being ignored right now!

Corrected Main Class Code

import akka.actor._
import Counter._

object Main extends App {
  val system = ActorSystem("persistent")
  val persistentActor = system.actorOf(Props[Counter], "counter")
  
  // Wrap operations in Cmd as defined in your Counter companion object
  persistentActor ! Cmd(Increment(3))
  persistentActor ! Cmd(Increment(5))
  persistentActor ! Cmd(Decrement(2))
  persistentActor ! "print"
  
  Thread.sleep(5000L)
  system.terminate()
}

3. Expected Output After Fixes

Once you apply these changes, running your main class should produce output like this:

Starting...
counter received command Increment(3)
counter received command Increment(5)
counter received command Decrement(2)
current state of the counter is State(6)

Key Takeaways

  • Always double-check config spelling (typos like snaphot-store are easy to miss!)
  • Make sure your messages match what your actor's receive handlers expect
  • For Akka Persistence default plugins, use the official implementation classes provided by the framework

内容的提问来源于stack exchange,提问作者user51

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.15 03:38:43