Hi,

I play more with actorPublisher, yes it is great thing, but - when I have 
stream like this:

val jobManagerSource = Source.actorPublisher[UserRegisterSource.
RegisterUser](UserRegisterSource.props)

val ref = Flow[UserRegisterSource.RegisterUser]
.mapAsync(1)(callMe)
.to(Sink.ignore)
.runWith(jobManagerSource)

ref ? UserRegisterSource.RegisterUser("test")

And then ask it, like in previous message, in ask result I see what 
jobManagerSource answer me. I can't understand how I can send some value to 
actorPublisher source and then obtain result of flow execution

понедельник, 8 июня 2015 г., 1:10:01 UTC+3 пользователь Владимир Морозов 
написал:
>
> I solve this problem, but found new one:
>
> val ref = Flow[UserRegisterSource.RegisterUser]
> .mapAsync(1)(callMe)
> .to(Sink.ignore)
> .runWith(jobManagerSource)
>
> val t = (ref ask 
> UserRegisterSource.RegisterUser("test")).mapTo[UserRegisterSource.RegisterUser]
>
> but t never complete, always end with Timeout exception
>
> воскресенье, 7 июня 2015 г., 23:13:29 UTC+3 пользователь Владимир Морозов 
> написал:
>>
>> Hi,
>>
>> I try but get error message:
>>
>> java.lang.IllegalStateException: onNext is not allowed when the stream 
>> has not requested elements, totalDemand was 0
>>
>> My code is:
>>
>> val jobManagerSource = 
>> Source.actorPublisher[UserRegisterSource.RegisterUser](UserRegisterSource.props)
>>
>> val ref = Flow[UserRegisterSource.RegisterUser]
>> .mapAsync(1)(callMe)
>> .to(Sink.ignore)
>> .runWith(jobManagerSource)
>>
>> ref ! UserRegisterSource.RegisterUser("test")
>>
>>
>> class UserRegisterSource extends 
>> ActorPublisher[UserRegisterSource.RegisterUser] {
>>
>>     import akka.stream.actor.ActorPublisherMessage._
>>     import UserRegisterSource._
>>
>>     val MaxBufferSize = 100
>>     var buf = Vector.empty[RegisterUser]
>>
>>     override def receive: Receive = {
>>         case request: RegisterUser =>
>>             onNext(request)
>>         case Cancel =>
>>             context.stop(self)
>>     }
>> }
>>
>>
>> воскресенье, 7 июня 2015 г., 14:53:15 UTC+3 пользователь Akka Team 
>> написал:
>>>
>>> Hi,
>>>
>>> On Fri, Jun 5, 2015 at 7:53 PM, Владимир Морозов <[email protected]> 
>>> wrote:
>>>
>>>> Yes, I know about mapAsync, but my problem with Source. A want to use 
>>>> single stream for processing some group of events
>>>>
>>>
>>> I am not sure if I understand your question properly, but if you want to 
>>> run the stream *once* and then reuse the stream for all the requests, then 
>>> you can try to create an ActorPublisher as your Source, then run the stream 
>>> outside of the Http handler logic. You can then use "ask" on that actor in 
>>> the Http route.
>>>
>>> -Endre
>>>  
>>>
>>>>
>>>> пятница, 5 июня 2015 г., 20:29:16 UTC+3 пользователь Paul Kinsky 
>>>> написал:
>>>>
>>>>> Use mapAsync: `def mapAsync[T](parallelism: Int)(f: (Out) ⇒ 
>>>>> Future[T]): Repr[T, Mat]`.
>>>>>
>>>>> On Friday, June 5, 2015 at 9:23:24 AM UTC-7, Владимир Морозов wrote:
>>>>>>
>>>>>> Hi all,
>>>>>>
>>>>>> I have some simple application based on akka streams and http:
>>>>>>
>>>>>> My Flow items:
>>>>>>
>>>>>> val resultSink = Sink.head[String]
>>>>>>
>>>>>> val fl0 = Flow[String].map(_.toInt)
>>>>>> val fl2 = Flow[Int].map{
>>>>>>     case value =>
>>>>>>         Thread.sleep(10000)
>>>>>>         value.toString
>>>>>> }
>>>>>> val fl3 = Flow[String].mapAsync(1)(callMe)
>>>>>>
>>>>>>
>>>>>> Part of my akka-http route:
>>>>>>
>>>>>> val route = get {
>>>>>>     path("test") {
>>>>>>         path("register") {
>>>>>>             parameter('username) { case username: Username =>
>>>>>>                 
>>>>>> Source.single(username).via(fl0).via(fl2).via(fl3).runWith(resultSink): 
>>>>>> Future[String]
>>>>>>         }
>>>>>>     }
>>>>>> }
>>>>>>
>>>>>> I want to use one flow : Source.single(username).
>>>>>> via(fl0).via(fl2).via(fl3).runWith(resultSink) for processing all 
>>>>>> requests. I want this for use streams back-pressure. But I can't figure 
>>>>>> out 
>>>>>> how create Source that can accept values like call def proccess(
>>>>>> username: String): Future[String] but with back-pressure, because, 
>>>>>> for example, a want long-call DB in fl2 step, and DB can't accept 
>>>>>> more than 1 request per time (only for example)
>>>>>>
>>>>>> With best regards, Vladimir.
>>>>>>
>>>>>>  -- 
>>>> >>>>>>>>>> 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.
>>>>
>>>
>>>
>>>
>>> -- 
>>> Akka Team
>>> Typesafe - Reactive apps on the JVM
>>> Blog: letitcrash.com
>>> Twitter: @akkateam
>>>  
>>

-- 
>>>>>>>>>>      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