Code Monkey home page Code Monkey logo

akka-persistence-hazelcast's Introduction

Akka Persistence Hazelcast

Build Status Release 2.12 Release 2.12

Introduction

A plugin for Akka Persistence, which provides a journal and a snapshot store backed by Hazelcast. Please, consider to read the documentation for the plugin and the Hazelcast itself.

Prerequisites

The plugin is tested against:

  • Scala 2.11/2.12
  • Java 8
  • Hazelcast 3.6.x-3.8.x
  • Akka 2.4.x-2.5.x

Installation

Dependencies

The plugin works with Scala 2.11/2.12, Hazelcast 3.6.x/3.7.x/3.8.x and Akka 2.4.x/2.5.x, but does not define them as compile time dependencies. Therefore, please, make sure that you have included all the relevant dependencies in your project.

All of the examples below are for Scala 2.12. You can easily change 2.12 to 2.11 in order to get the right artifacts.

Gradle

dependencies {
    compile "com.github.sorokinigor:akka-persistence-hazelcast_2.12:1.1.0"
    compile "org.scala-lang:scala-library:2.12.1"
    compile "com.typesafe.akka:akka-persistence_2.12:2.5.3"
    compile "com.hazelcast:hazelcast:3.8.3"
}

repositories {
    mavenCentral()
}

Sbt

libraryDependencies += "com.github.sorokinigor" % "akka-persistence-hazelcast_2.12" % "1.1.0"
libraryDependencies += "org.scala-lang" % "scala-library" % "2.12.1"
libraryDependencies += "com.typesafe.akka" % "akka-persistence_2.12" % "2.5.3"
libraryDependencies += "com.hazelcast" % "hazelcast" % "3.8.3" 

Maven

<dependency>
  <groupId>com.github.sorokinigor</groupId>
  <artifactId>akka-persistence-hazelcast_2.12</artifactId>
  <version>1.1.0</version>
</dependency>

<dependency>
    <groupId>org.scala-lang</groupId>
    <artifactId>scala-library</artifactId>
    <version>2.12.1</version>
</dependency>

<dependency>
    <groupId>com.typesafe.akka</groupId>
    <artifactId>akka-persistence_2.12</artifactId>
    <version>2.5.3</version>
</dependency>

<dependency>
    <groupId>com.hazelcast</groupId>
    <artifactId>hazelcast</artifactId>
    <version>3.8.3</version>
</dependency>

Activate plugin

Put this in a application.conf:

akka.persistence {
  journal.plugin = "hazelcast.journal"
  snapshot-store.plugin = "hazelcast.snapshot-store"
}

See more about the configuration in the reference.conf, documentation and unit tests.

akka-persistence-hazelcast's People

Contributors

sorokinigor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

akka-persistence-hazelcast's Issues

Moving akka-persistence-hazelcast:1.0 to work with external hazelcast client

I would like to change current implementation akka-persistence-hazelcast:1.0 to work with external hazelcast cluster.

So I changed client implementation in HazelcastExtention.scala with the following code:

val hazelcast: HazelcastInstance = {
    val classLoader = Thread.currentThread().getContextClassLoader
    val clientConfig = new XmlClientConfigBuilder("hazelcast-client.xml").build
    clientConfig.setClassLoader(classLoader)
    val serializationConfig = clientConfig.getSerializationConfig
    serializationConfig.addSerializerConfig(createSerializationConfig(classOf[PersistentRepr]))
    serializationConfig.addSerializerConfig(createSerializationConfig(classOf[PersistenceSnapshot]))
    HazelcastClient.newHazelcastClient(clientConfig)
  }

but when I run the code, I'm getting exception:

[ERROR] [12/03/2017 11:43:06.506] [application-akka.actor.default-dispatcher-4] [akka://application/user/hazelcastActor] Persistence failure when replaying events for persistenceId [hazelcastActor]. Last known sequence number [0]
com.hazelcast.core.HazelcastException: java.util.concurrent.ExecutionException: com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.ClassNotFoundException: com.vanilla.actor.hazelcast.journal.LongExtractor$
	at com.hazelcast.client.proxy.ClientMapProxy.aggregate(ClientMapProxy.java:1343)
	at com.hazelcast.client.proxy.ClientMapProxy.aggregate(ClientMapProxy.java:1316)
	at com.vanilla.actor.hazelcast.journal.MapJournal$$anonfun$asyncReadHighestSequenceNr$1.apply$mcJ$sp(MapJournal.scala:145)
	at com.vanilla.actor.hazelcast.journal.MapJournal$$anonfun$asyncReadHighestSequenceNr$1.apply(MapJournal.scala:139)
	at com.vanilla.actor.hazelcast.journal.MapJournal$$anonfun$asyncReadHighestSequenceNr$1.apply(MapJournal.scala:139)
	at scala.concurrent.impl.Future$PromiseCompletingRunnable.liftedTree1$1(Future.scala:24)
	at scala.concurrent.impl.Future$PromiseCompletingRunnable.run(Future.scala:24)
	at akka.dispatch.TaskInvocation.run(AbstractDispatcher.scala:39)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
Caused by: java.util.concurrent.ExecutionException: com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.ClassNotFoundException: com.vanilla.actor.hazelcast.journal.LongExtractor$
	at com.hazelcast.client.spi.impl.ClientInvocationFuture.resolve(ClientInvocationFuture.java:66)
	at com.hazelcast.spi.impl.AbstractInvocationFuture$1.run(AbstractInvocationFuture.java:246)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:748)
	at com.hazelcast.util.executor.HazelcastManagedThread.executeRun(HazelcastManagedThread.java:76)
	at com.hazelcast.util.executor.HazelcastManagedThread.run(HazelcastManagedThread.java:92)
Caused by: com.hazelcast.nio.serialization.HazelcastSerializationException: java.lang.ClassNotFoundException: com.vanilla.actor.hazelcast.journal.LongExtractor$
	at com.hazelcast.internal.serialization.impl.JavaDefaultSerializers$JavaSerializer.read(JavaDefaultSerializers.java:224)
	at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
	at com.hazelcast.internal.serialization.impl.AbstractSerializationService.readObject(AbstractSerializationService.java:251)
	at com.hazelcast.internal.serialization.impl.ByteArrayObjectDataInput.readObject(ByteArrayObjectDataInput.java:600)
	at com.hazelcast.mapreduce.aggregation.impl.AcceptAllSupplier.readData(AcceptAllSupplier.java:77)
	at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.readInternal(DataSerializableSerializer.java:151)
	at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.read(DataSerializableSerializer.java:104)
	at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.read(DataSerializableSerializer.java:54)
	at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
	at com.hazelcast.internal.serialization.impl.AbstractSerializationService.readObject(AbstractSerializationService.java:251)
	at com.hazelcast.internal.serialization.impl.ByteArrayObjectDataInput.readObject(ByteArrayObjectDataInput.java:600)
	at com.hazelcast.mapreduce.aggregation.impl.PredicateSupplier.readData(PredicateSupplier.java:90)
	at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.readInternal(DataSerializableSerializer.java:151)
	at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.read(DataSerializableSerializer.java:104)
	at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.read(DataSerializableSerializer.java:54)
	at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
	at com.hazelcast.internal.serialization.impl.AbstractSerializationService.readObject(AbstractSerializationService.java:251)
	at com.hazelcast.internal.serialization.impl.ByteArrayObjectDataInput.readObject(ByteArrayObjectDataInput.java:600)
	at com.hazelcast.mapreduce.aggregation.impl.SupplierConsumingMapper.readData(SupplierConsumingMapper.java:84)
	at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.readInternal(DataSerializableSerializer.java:151)
	at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.read(DataSerializableSerializer.java:104)
	at com.hazelcast.internal.serialization.impl.DataSerializableSerializer.read(DataSerializableSerializer.java:54)
	at com.hazelcast.internal.serialization.impl.StreamSerializerAdapter.read(StreamSerializerAdapter.java:48)
	at com.hazelcast.internal.serialization.impl.AbstractSerializationService.toObject(AbstractSerializationService.java:172)
	at com.hazelcast.client.impl.protocol.task.mapreduce.MapReduceForMapMessageTask.getMapper(MapReduceForMapMessageTask.java:64)
	at com.hazelcast.client.impl.protocol.task.mapreduce.AbstractMapReduceTask.startSupervisionTask(AbstractMapReduceTask.java:111)
	at com.hazelcast.client.impl.protocol.task.mapreduce.AbstractMapReduceTask.processMessage(AbstractMapReduceTask.java:77)
	at com.hazelcast.client.impl.protocol.task.AbstractMessageTask.initializeAndProcessMessage(AbstractMessageTask.java:128)
	at com.hazelcast.client.impl.protocol.task.AbstractMessageTask.run(AbstractMessageTask.java:108)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
	... 2 more
Caused by: java.lang.ClassNotFoundException
	at com.hazelcast.client.impl.protocol.ClientExceptionFactory$12.createException(ClientExceptionFactory.java:170)
	at com.hazelcast.client.impl.protocol.ClientExceptionFactory.createException(ClientExceptionFactory.java:622)
	at com.hazelcast.client.impl.protocol.ClientExceptionFactory.createException(ClientExceptionFactory.java:589)
	at com.hazelcast.client.spi.impl.ClientInvocationServiceSupport$ResponseThread.handleClientMessage(ClientInvocationServiceSupport.java:331)
	at com.hazelcast.client.spi.impl.ClientInvocationServiceSupport$ResponseThread.process(ClientInvocationServiceSupport.java:313)
	at com.hazelcast.client.spi.impl.ClientInvocationServiceSupport$ResponseThread.doRun(ClientInvocationServiceSupport.java:306)
	at com.hazelcast.client.spi.impl.ClientInvocationServiceSupport$ResponseThread.run(ClientInvocationServiceSupport.java:283)
 

I'm new to Hazelcast, but we need to use it as a persistence solution for state resilience. Anyway, I believe that this is good feature that your plugin will run on external client.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.