miladamery opened a new issue, #1806:
URL: https://github.com/apache/fury/issues/1806

   ## Is your feature request related to a problem? Please describe.
   Hi. When using Akka toolkit you need to serialize objects for persistence 
and clustering. Akka gives you the option for providing
   your own serializer. The problem is in akka you have something called 
`ActorRef`. this class is used for replying to actors that send commands. but 
this `ActorRef` serialization/deserialization is special in `Akka`. 
[Here](https://doc.akka.io/docs/akka/current/serialization.html#serializing-actorrefs)
 is how you can do it.
   Fury provides custom serializers for whole class according to 
[this](https://fury.apache.org/docs/guide/java_object_graph_guide#implement-a-customized-serializer)
   
   ```java
   import akka.actor.typed.ActorRef;
   import akka.actor.typed.ActorRefResolver;
   import org.apache.fury.Fury;
   import org.apache.fury.memory.MemoryBuffer;
   import org.apache.fury.serializer.Serializer;
   
   public class FuryActorRefSerializer extends Serializer<ActorRef> {
   
       private final ActorRefResolver actorRefResolver;
   
       public FuryActorRefSerializer(Fury fury, ActorRefResolver 
actorRefResolver) {
           super(fury, ActorRef.class);
           this.actorRefResolver = actorRefResolver;
       }
   
       @Override
       public void write(MemoryBuffer buffer, ActorRef value) {
           var serialized = 
actorRefResolver.toSerializationFormat(value).getBytes();
           buffer.writeInt32(serialized.length);
           buffer.writeBytes(serialized);
       }
   
       @Override
       public ActorRef read(MemoryBuffer buffer) {
           var length = buffer.readInt32();
           var ref = buffer.readBytes(length);
           return actorRefResolver.resolveActorRef(new String(ref));
       }
   }
   ```
   
   Here is my implementation for serializing `ActorRef` (I appreciate it if 
some one can say if this is correct)
   but this `ActorRef` discussed earlier is usually used as a field in commands 
not as a standalone class.
   Is there a way that Fury support this? I mean writing a serializer like 
above and fury understands class field it is serializing and 
   use appropriate serializer for that field?
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to