在分布式微服务应用程序中为每个节点使用分离的本地缓存是不正确的做法?我听说在单片应用程序中使用本地EHCache作为Hibernate的二级缓存提供程序是可以的,但在分布式环境中,通常的做法是使用分布式缓存,例如Memcached,Redis或Hazelcast.为每个节点使用单独的缓存有什么后果?
我尝试让 akka 集群与分布式消息一起工作,但我陷入困境。我的演员已正确启动并订阅主题,但未收到任何消息。这是代码
import akka.actor.{Actor, ActorSystem, Props}
import akka.cluster.client.ClusterClient.Publish
import akka.cluster.pubsub.DistributedPubSub
import akka.cluster.pubsub.DistributedPubSubMediator.{Subscribe, SubscribeAck}
case object DistributedMessage
object ClusterExample extends App {
val system = ActorSystem("ClusterSystem")
val actor = system.actorOf(Props(classOf[ClusterExample]), "clusterExample")
}
class ClusterExample extends Actor {
private val mediator = DistributedPubSub(context.system).mediator
mediator ! Subscribe("content", self)
override def receive = {
case SubscribeAck(Subscribe("content", None, `self`)) =>
(1 to 100) foreach (_ => {
mediator ! Publish("content", msg = DistributedMessage)
})
case DistributedMessage => println("received message from queue!")
}
}
Run Code Online (Sandbox Code Playgroud)
这是配置: …