Hi,

I'm trying to transfer serialized java objects to an Actor.

What I want to do is to transfer a java serialised object with a key. 
(Think of it is like a key value cache) The server is written with Akka 
Actors and the client is Java.

On the actor side I get the "ByteString" objects, and when I immediately 
send them to Java client I can read them. There is no problem with this. 
The problem is, I want to know which keys and objects are received on the 
actor level. But I only get ByteString, and I don't know which of them is 
the key or the object. Is there kind of a delimiter which I should check, 
like "now I'm receiving the key, and now I receive the related object"?

The example java code I'm using:

InetAddress address = InetAddress.getByName("127.0.0.1");
Socket socket = new Socket(address, 7000);

ObjectOutputStream outputStream = new ObjectOutputStream(socket.
getOutputStream());
outputStream.writeObject("key1");
outputStream.writeObject(user);


ObjectInputStream inputStream = new ObjectInputStream(socket.getInputStream
());

String str2 = (String)inputStream.readObject();
System.out.println("Received string2 object: "+str2);

User user2 = (User)inputStream.readObject();
System.out.println("Received user2 object: "+user2.fullName());



And my data handler is the example given on the Akka.io socket introduction:

class SimplisticHandler extends Actor with ActorLogging {

 override def preStart() = {
 log.info("SimplisticHandler started!")
 }

 def receive = {
 case Received(data) =>
 log.info("Received data: "+data)
 sender() ! Write(data)
 case PeerClosed => context.stop(self)
 }

 override def postStop() = {
 log.info("SimplisticHandler stopped!")
 }
}


-- 
>>>>>>>>>>      Read the docs: http://akka.io/docs/
>>>>>>>>>>      Check the FAQ: 
>>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>>      Search the archives: https://groups.google.com/group/akka-user
--- 
You received this message because you are subscribed to the Google Groups "Akka 
User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to