RedisPersistentVector fails to add byte array
This code does not work in
RedisPersistentVector log = new RedisPersistentVector("SOME_LOG");
if (msg instanceof Message) {
new Atomic<Object>() {
@Override
public Object atomically() {
try {
gameLog.add(((Message) msg).getMessage().getBytes(
"UTF-8")); //NoSuchMethodError is thrown here on the add()
} catch (UnsupportedEncodingException e) {
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}.execute();
}
[akka:event-driven:dispatcher:global-13] [ERROR] [2011-01-12 11:20:19,596] a.a.Actor$: Problem
java.lang.NoSuchMethodError: akka.persistence.redis.RedisPersistentVector.add([B)Lscala/collection/immutable/Vector;
at com.ga.games.gameactors.RedisGameStorage$2.atomically(RedisGameStorage.java:53) ~[classes/:na]
at akka.stm.Atomic$$anonfun$execute$1.apply(Atomic.scala:39) ~[akka-stm-1.0-RC2.jar:na]
at akka.stm.Stm$$anon$1.call(Stm.scala:53) ~[akka-stm-1.0-RC2.jar:na]
RedisPersistentVector log = new RedisPersistentVector("SOME_LOG");
if (msg instanceof Message) {
new Atomic<Object>() {
@Override
public Object atomically() {
try {
gameLog.add(((Message) msg).getMessage().getBytes(
"UTF-8")); //NoSuchMethodError is thrown here on the add()
} catch (UnsupportedEncodingException e) {
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
}.execute();
}
[akka:event-driven:dispatcher:global-13] [ERROR] [2011-01-12 11:20:19,596] a.a.Actor$: Problem
java.lang.NoSuchMethodError: akka.persistence.redis.RedisPersistentVector.add([B)Lscala/collection/immutable/Vector;
at com.ga.games.gameactors.RedisGameStorage$2.atomically(RedisGameStorage.java:53) ~[classes/:na]
at akka.stm.Atomic$$anonfun$execute$1.apply(Atomic.scala:39) ~[akka-stm-1.0-RC2.jar:na]
at akka.stm.Stm$$anon$1.call(Stm.scala:53) ~[akka-stm-1.0-RC2.jar:na]
Leave a comment
on 2011-01-12 22:39 *
By Peter Vlugter
RedisPersistentVector was 0.10?
From the documentation:
The following works fine for me (using 1.0-RC3):
From the documentation:
PersistentVector<byte[]> vector = RedisStorage.getVector(id);
The following works fine for me (using 1.0-RC3):
import java.io.UnsupportedEncodingException;
import akka.actor.UntypedActor;
import akka.persistence.common.PersistentVector;
import akka.persistence.redis.RedisStorage;
import akka.stm.*;
public class RedisActor extends UntypedActor {
private final String SOME_LOG = "some.log";
private final PersistentVector<byte[]> someLog = RedisStorage.newVector(SOME_LOG);
public void onReceive(final Object msg) throws Exception {
if (msg instanceof String) {
new Atomic() {
public Object atomically() {
try {
return someLog.add(((String) msg).getBytes("UTF-8"));
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
return null;
}
}.execute();
}
}
}
Akka persistence will be dropped.