我正在使用远程Akka actor,并且我想发送序列化消息,使用ObjectOutputStream,但是当本地actor将消息发送给远程actor时出现abd错误,该错误是:java.io.NotRerializableException没有配置的序列化-类java的绑定。 io.ObjectOutputStream建议使用哪种类型的序列化?
A java.io.ObjectOutputStream
is not serializable so it can't be sent as a remote message out-of-the-box. You'll either need to send a different message or write a serializer for that class and configure Akka appropriately. But, given what an ObjectOutputStream
is, it doesn't even make sense for an object of that type to be sent over the wire.
Moreover, java.io.ObjectOutputStream
is effectively mutable and so it absolutely should not be sent as a message in Akka anyways, rendering this whole thing moot. Just don't do it.
You don't have to create your own ObjectOutputStream
to send the message. You just a domain message object (eg, Person
, AddItem
, ...) that is serializable to your Akka actors. Akka will take care of sending it over the wire. By default it will use Java serialization (which is not the most efficient).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.