Could you create an issue <https://github.com/akka/akka/issues/new> for
this. I think this is a bug.

On Fri, Sep 28, 2018 at 1:53 PM <oscar.sanchez.delar...@tecsisa.com> wrote:

> I have an actor with the next behaviour. When i stash commands, they never
> go back to mailbox. Use versions "akka-actor-typed" and
> "akka-persistence-typed" 2.5.17
>
> object Blog {
>   //#event
>   sealed trait BlogEvent                                           extends 
> Serializable
>   final case class PostAdded(postId: String, content: PostContent) extends 
> BlogEvent
>   //#event
>
>   //#state
>   object BlogState {
>     val empty = BlogState(None)
>   }
>
>   final case class BlogState(content: Option[PostContent]) {
>     def withContent(newContent: PostContent): BlogState =
>       copy(content = Some(newContent))
>     def isEmpty: Boolean = content.isEmpty
>     def postId: String = content match {
>       case Some(c) ⇒ c.postId
>       case None    ⇒ throw new IllegalStateException("postId unknown before 
> post is created")
>     }
>   }
>   //#state
>
>   //#commands
>   sealed trait BlogCommand                                                    
>    extends Serializable
>   final case class AddPost(content: PostContent, replyTo: 
> ActorRef[AddPostDone]) extends BlogCommand
>   final case class Accumulate(num: Int)                                       
>    extends BlogCommand
>   final case class AddPostDone(postId: String)
>   final case class PostContent(postId: String, title: String, body: String)
>   //#commands
>
>   def behavior: Behavior[BlogCommand] =
>     Behaviors.setup[BlogCommand] { ctx ⇒
>       val buffer = StashBuffer[BlogCommand](capacity = 1000)
>
>       //#initial-command-handler
>       def initial(cmd: BlogCommand): Effect[BlogEvent, BlogState] =
>         cmd match {
>           case AddPost(content, replyTo) ⇒
>             Effect
>               .persist(PostAdded(content.postId, content))
>               .thenRun { _ ⇒
>                 replyTo ! AddPostDone(content.postId)
>                 println("initial thenRun " + buffer.toString)
>                 buffer.unstashAll(ctx, this.behavior)
>                 println("initial thenRun 2 " + buffer.toString)
>               }
>           case a @ Accumulate(_) =>
>             println("initial antes de stash " + buffer.toString)
>             buffer.stash(a)
>             println("initial despues de stash " + buffer.toString)
>             Effect.none
>           case _ ⇒
>             Effect.unhandled
>
>
>

-- 

Patrik Nordwall
Akka Tech Lead
Lightbend <http://www.lightbend.com/> -  Reactive apps on the JVM
Twitter: @patriknw

-- 
*****************************************************************************************************
** New discussion forum: https://discuss.akka.io/ replacing akka-user 
google-group soon.
** This group will soon be put into read-only mode, and replaced by 
discuss.akka.io
** More details: https://akka.io/blog/news/2018/03/13/discuss.akka.io-announced
*****************************************************************************************************
>>>>>>>>>> 
>>>>>>>>>>      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 akka-user+unsubscr...@googlegroups.com.
To post to this group, send email to akka-user@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.

Reply via email to