Re: [akka-user] Akka create two Tcp Connections with the same port

2016-07-14 Thread Chris Stewart
So you can't have unique ip addresses that are out on the web? Only ones 
that are local to my machine? That seems rather limiting. 

On Thursday, July 14, 2016 at 10:58:08 AM UTC-5, Akka Team wrote:
>
> Akka will work out of the box if the host names resolve to separate ip 
> addresses and those addresses belong to the system you run the akka 
> application on.
>
> --
> Johan
>
> On Thu, Jul 14, 2016 at 3:08 PM, Chris Stewart  > wrote:
>
>> So just to make sure I understand you, I NEED to create this virtual 
>> interface if the hosts resolve to different ip addresses, or akka should 
>> work out of the box if the hosts resolve to different ip addresses. 
>>
>> On Tuesday, July 12, 2016 at 8:32:08 AM UTC-5, Akka Team wrote:
>>>
>>> That will only be possible if the hosts resolve to different 
>>> IP-addresses on the machine they are run on. For example you could create a 
>>> virtual interface with a separate IP address for one of the hostnames.
>>>
>>> --
>>> Johan
>>>
>>> On Mon, Jul 11, 2016 at 9:12 PM, Chris Stewart  
>>> wrote:
>>>
 Hi, as the title says i'm trying to create 2 tcp connections from the 
 same port 

 Here is the stackoverflow question: 
 https://stackoverflow.com/questions/38314437/akka-create-two-tcp-connections-with-the-same-port

 I'm trying to create two tcp connections that are bound to the same 
 port. I'm getting an error saying that the `java.net.BindException: 
 Address 
 already in use`. This makes sense since they are both using `18333` as a 
 port, but there must be some way to have two connections on a port that 
 have unique hosts. I'm following along with the [guide in the akka tcp 
 manual][1]. How can I make this work? The protocol says that connections 
 need to be created on `18333`, however if I can only have one peer at a 
 time it makes the p2p portion of the protocol useless. 

 Here is the code: 

 val probe1 = TestProbe()
 val probe2 = TestProbe()
 val client1 = system.actorOf(Client.props(TestNet3, probe1.ref))
 val client2 = system.actorOf(Client.props(TestNet3, probe2.ref))

 val local = new InetSocketAddress(18333)

 val remote1 = new InetSocketAddress("
 testnet-seed.bitcoin.petertodd.org", 18333)

 client1 ! Tcp.Connect(remote1,Some(local))
 probe1.expectMsgType[Tcp.Connected]

 val remote2 = new InetSocketAddress("testnet-seed.bluematt.me", 
 18333)
 client2 ! Tcp.Connect(remote2,Some(local))
 probe2.expectMsgType[Tcp.Connected]


 client1 ! Tcp.Abort
 client2 ! Tcp.Abort


   [1]: http://doc.akka.io/docs/akka/2.3.15/scala/io-tcp.html#Connecting

 -- 
 >> 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+...@googlegroups.com.
 To post to this group, send email to akka...@googlegroups.com.
 Visit this group at https://groups.google.com/group/akka-user.
 For more options, visit https://groups.google.com/d/optout.
>>>
>>> -- 
>> >> 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+...@googlegroups.com .
>> To post to this group, send email to akka...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>>
>

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


[akka-user] Run a Flow with an ActorPublisher as a Source

2016-07-14 Thread Olivier
When I upgrade my code from akka-stream-experimental 2.0.3 to akka-stream 
2.4.4,
I'm a little lost with the mean to run a Flow with an ActorPublisher as a 
source...

Previously the following code was working :
val (ref, scriptPlan) = runnableGraph.runWith(source, 
sinkScriptPlanExecution)

With a declared source :
  lazy val source: Source[Script, ActorRef] = {
Source.actorPublisher[Script](Props[ScriptAdmissionFlowActor])
  }

Then I can do ref !  ...

Now I have the following error in IDE :
type mismatch; found : 
 
akka.stream.scaladsl.Source[xxx.flows.scriptedflows.parts.StreamData.Script,akka.actor.ActorRef]
 
required: 
 
akka.stream.Graph[akka.stream.SourceShape[xxx.flows.scriptedflows.parts.StreamData.UnifiedScriptReceived],?]

I don't understand why it requires a Graph now ... and how can I do to run 
the Flow with the ActorPublisher as a source parameter
Any idea ?

thanks !
Olivier


My flow is defined as this :

  lazy val runnableGraph = Flow.fromGraph(GraphDSL.create() {
implicit builder =>
  import GraphDSL.Implicits._
  
   
  FlowShape(dispatchScriptSource.in, zippedExecutionReport.out)
})



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


Re: [akka-user] Akka Sen email alerts

2016-07-14 Thread Akka Team
Any Java SMTP client would do, if it is blocking, make sure that the actor
using it runs on a separate thread pool dispatcher rather than the default
fork join pool. Except for this nothing special about using them from Akka.

A google search will probably give you a lot of options to choose from.

--
Johan


On Wed, Jul 13, 2016 at 3:10 PM, padma priya chitturi <
padmapriy...@gmail.com> wrote:

> Hi All,
>
>   I would like to use Akka to send real-time alerts (email alerts) as soon
> as I receive messages. How would I go about it ?
>
> Thanks,
> Padma CH
>
> --
> >> 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.
>

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


Re: [akka-user] Akka create two Tcp Connections with the same port

2016-07-14 Thread Akka Team
Akka will work out of the box if the host names resolve to separate ip
addresses and those addresses belong to the system you run the akka
application on.

--
Johan

On Thu, Jul 14, 2016 at 3:08 PM, Chris Stewart 
wrote:

> So just to make sure I understand you, I NEED to create this virtual
> interface if the hosts resolve to different ip addresses, or akka should
> work out of the box if the hosts resolve to different ip addresses.
>
> On Tuesday, July 12, 2016 at 8:32:08 AM UTC-5, Akka Team wrote:
>>
>> That will only be possible if the hosts resolve to different IP-addresses
>> on the machine they are run on. For example you could create a virtual
>> interface with a separate IP address for one of the hostnames.
>>
>> --
>> Johan
>>
>> On Mon, Jul 11, 2016 at 9:12 PM, Chris Stewart 
>> wrote:
>>
>>> Hi, as the title says i'm trying to create 2 tcp connections from the
>>> same port
>>>
>>> Here is the stackoverflow question:
>>> https://stackoverflow.com/questions/38314437/akka-create-two-tcp-connections-with-the-same-port
>>>
>>> I'm trying to create two tcp connections that are bound to the same
>>> port. I'm getting an error saying that the `java.net.BindException: Address
>>> already in use`. This makes sense since they are both using `18333` as a
>>> port, but there must be some way to have two connections on a port that
>>> have unique hosts. I'm following along with the [guide in the akka tcp
>>> manual][1]. How can I make this work? The protocol says that connections
>>> need to be created on `18333`, however if I can only have one peer at a
>>> time it makes the p2p portion of the protocol useless.
>>>
>>> Here is the code:
>>>
>>> val probe1 = TestProbe()
>>> val probe2 = TestProbe()
>>> val client1 = system.actorOf(Client.props(TestNet3, probe1.ref))
>>> val client2 = system.actorOf(Client.props(TestNet3, probe2.ref))
>>>
>>> val local = new InetSocketAddress(18333)
>>>
>>> val remote1 = new InetSocketAddress("
>>> testnet-seed.bitcoin.petertodd.org", 18333)
>>>
>>> client1 ! Tcp.Connect(remote1,Some(local))
>>> probe1.expectMsgType[Tcp.Connected]
>>>
>>> val remote2 = new InetSocketAddress("testnet-seed.bluematt.me",
>>> 18333)
>>> client2 ! Tcp.Connect(remote2,Some(local))
>>> probe2.expectMsgType[Tcp.Connected]
>>>
>>>
>>> client1 ! Tcp.Abort
>>> client2 ! Tcp.Abort
>>>
>>>
>>>   [1]: http://doc.akka.io/docs/akka/2.3.15/scala/io-tcp.html#Connecting
>>>
>>> --
>>> >> 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+...@googlegroups.com.
>>> To post to this group, send email to akka...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/akka-user.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>> --
> >> 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.
>

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


Re: [akka-user] Access to LoggingAdapter

2016-07-14 Thread Akka Team
The prior one that is, the adapter as a parameter sounds right.

--
Johan

On Thu, Jul 14, 2016 at 4:57 PM, Viktor Klang 
wrote:

> but I'd recommend against that solution since it wouldn't necessarily be
> portable across materializer impls.
>
> --
> Cheers,
> √
> On Jul 14, 2016 08:39, "Akka Team"  wrote:
>
>> If you are writing a custom graph stage, you can access it inside the
>> GraphStageLogic from the ActorSystem like this:
>>
>> materializer match {
>>   case mat: ActorMaterializer => mat.logger
>>   case _ => throw new RuntimeException("this stage only works with an actor 
>> materializer")
>> }
>>
>> Note that this may make the stage impossible to use with any future
>> alternative materializers.
>>
>> --
>> Johan
>>
>> On Wed, Jul 13, 2016 at 9:54 PM, Richard Rodseth 
>> wrote:
>>
>>> Is there a way to get hold of the LoggingAdapter used by Akka streams?
>>>
>>> I'm making use of Viktor's Future retry
>>>
>>> https://gist.github.com/viktorklang/9414163
>>>
>>> and someone would like me to log something in the retry case. So I
>>> thought I would add an implicit LoggingAdapter parameter and supply it at
>>> the call site (which is a mapAsync call).
>>>
>>> Thanks
>>>
>>> --
>>> >> 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.
>>>
>>
>> --
>> >> 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.
>>
> --
> >> 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.
>

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


Re: [akka-user] Access to LoggingAdapter

2016-07-14 Thread Viktor Klang
but I'd recommend against that solution since it wouldn't necessarily be
portable across materializer impls.

-- 
Cheers,
√
On Jul 14, 2016 08:39, "Akka Team"  wrote:

> If you are writing a custom graph stage, you can access it inside the
> GraphStageLogic from the ActorSystem like this:
>
> materializer match {
>   case mat: ActorMaterializer => mat.logger
>   case _ => throw new RuntimeException("this stage only works with an actor 
> materializer")
> }
>
> Note that this may make the stage impossible to use with any future
> alternative materializers.
>
> --
> Johan
>
> On Wed, Jul 13, 2016 at 9:54 PM, Richard Rodseth 
> wrote:
>
>> Is there a way to get hold of the LoggingAdapter used by Akka streams?
>>
>> I'm making use of Viktor's Future retry
>>
>> https://gist.github.com/viktorklang/9414163
>>
>> and someone would like me to log something in the retry case. So I
>> thought I would add an implicit LoggingAdapter parameter and supply it at
>> the call site (which is a mapAsync call).
>>
>> Thanks
>>
>> --
>> >> 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.
>>
>
> --
> >> 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.
>

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


Re: [akka-user] Access to LoggingAdapter

2016-07-14 Thread Richard Rodseth
No, I'm just in a function creating a flow that includes
mapAsync(retry(somethingReturningFuture(..),...). Maybe I should just
create an adapter at the beginning of the program and pass it as a
parameter.

On Wed, Jul 13, 2016 at 11:38 PM, Akka Team  wrote:

> If you are writing a custom graph stage, you can access it inside the
> GraphStageLogic from the ActorSystem like this:
>
> materializer match {
>   case mat: ActorMaterializer => mat.logger
>   case _ => throw new RuntimeException("this stage only works with an actor 
> materializer")
> }
>
> Note that this may make the stage impossible to use with any future
> alternative materializers.
>
> --
> Johan
>
> On Wed, Jul 13, 2016 at 9:54 PM, Richard Rodseth 
> wrote:
>
>> Is there a way to get hold of the LoggingAdapter used by Akka streams?
>>
>> I'm making use of Viktor's Future retry
>>
>> https://gist.github.com/viktorklang/9414163
>>
>> and someone would like me to log something in the retry case. So I
>> thought I would add an implicit LoggingAdapter parameter and supply it at
>> the call site (which is a mapAsync call).
>>
>> Thanks
>>
>> --
>> >> 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.
>>
>
> --
> >> 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.
>

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


[akka-user] Akka Source.queue (Java DSL query)

2016-07-14 Thread Daniel Stoner
Recently I spotted a great example of how to use the Source.queue feature
in Streams to pre-materialise a flow and then pass events into it
independently.
http://stackoverflow.com/a/33415214/5142410

The examples utilising Actors were tempting but would over-complicate my
use case - which is to throttle writes to a database in a custom
persistence Journal implementation.

Using Source.queue for the life of me I cannot work out how to get the
SourceQueue from which to then 'offer' out of this flow within the Java DSL.

Scala example was:

val queue = Source.queue(bufferSize, overflowStrategy)
  .filter(!_.raining)
  .runForeach(println)

queue.offer(Weather("02139", 32.0, true))


My Java line for line conversion is:

> CompletionStage clearlyNotAQueue =
>  Source.queue(5, OverflowStrategy.dropHead())
> .filter(msg -> msg.equals(5))
> .runForeach(System.out::println, materializer)


However this returns a CompletionStage representing the runForEach's
completion without result.

A pointer in the right direction would be hugely appreciated.

Thanks,
Daniel Stoner
-- 
Daniel Stoner | Senior Software Engineer UtopiaIT | Ocado Technology
daniel.sto...@ocado.com | Ext 7969 | www.ocadotechnology.com

-- 


Notice:  This email is confidential and may contain copyright material of 
members of the Ocado Group. Opinions and views expressed in this message 
may not necessarily reflect the opinions and views of the members of the 
Ocado Group. 

 

If you are not the intended recipient, please notify us immediately and 
delete all copies of this message. Please note that it is your 
responsibility to scan this message for viruses. 

 

Fetch and Sizzle are trading names of Speciality Stores Limited, a member 
of the Ocado Group.

 

References to the “Ocado Group” are to Ocado Group plc (registered in 
England and Wales with number 7098618) and its subsidiary undertakings (as 
that expression is defined in the Companies Act 2006) from time to time.  
The registered office of Ocado Group plc is Titan Court, 3 Bishops Square, 
Hatfield Business Park, Hatfield, Herts. AL10 9NE.

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


Re: [akka-user] Re: CORS Support Akka-http

2016-07-14 Thread Konrad Malawski
Use the community provided ones.
There's no need for us to ship one if community has stepped up and provided
libraries, as is the case here I believe :-)

-- 
Konrad `ktoso` Malawski
Akka  @ Lightbend 

On 14 July 2016 at 15:26:04, Matan Safriel (dev.ma...@gmail.com) wrote:

Any built-in support for CORS by now?

On Friday, September 25, 2015 at 5:20:07 PM UTC+3, Patrik Nordwall wrote:
>
> Thanks for sharing, Patrick.
>
> On Tue, Sep 22, 2015 at 1:42 PM, Patrick Ting  > wrote:
>
>> Hi Everyone,
>>
>> I ended up porting and modifying Ganta's original CORS support with an
>> existing one I had that I pulled from the Spray mailing list awhile back
>> and posted it here: https://gist.github.com/pcting/2e65c36f868c5cee7d6a
>>
>> The most frustrating part was finding a way around the loss of
>> RequestContext.withRouteResponseHandling and
>> RequestContext.withHttpResponseHeadersMapped.
>>
>> Please fork it, poke holes int it, and send feedback!
>>
>> Cheers,
>> Patrick
>>
>> On Monday, August 17, 2015 at 1:40:42 PM UTC-7, Austin Guest wrote:
>>>
>>> Hi Yar. Thanks for getting back! The error message was regarding headers
>>> missing from the *server's* response to the actual POST request (it handled
>>> the "pre-flight" OPTIONS request just fine, which is why I was puzzled.
>>>
>>> I've since resolved the question, as it was a matter (as the blog you
>>> linked to helpfully pointed out) of the wildcard `*` as a value for the
>>> `Allow-Access-Origin` header being incompatible with setting
>>> `Allow-Access-Credentials` to `true`. I temporarily resolved the issue by
>>> disabling access credentials. Thanks for pointing me in the right
>>> direction! :)
>>>
>>> Not the best long-term fix, but necessary for the time being as a
>>> workaround for running locally (since I will always have the origin
>>> 'localhost'. As a longer term fix, I plan on using Chrome's 
>>> Allow-Access-Origin
>>> Dev Tools add-on
>>> ,
>>> which spoofs a '*' header for running locally -- just as soon as I can
>>> figure out how to get my webpack dev server
>>>  to disable
>>> credentials so the the Allow-Access headers won't conflict.
>>>
>>> If anyone's stuck on a similar problem and is interested in results, I'm
>>> happy to post them here. (Though that set of problem solving would belong
>>> more properly on a React mailing list than one pertaining to akka-http! :P)
>>>
>>> /a/
>>>
>>> On Sunday, August 16, 2015 at 5:12:29 AM UTC-4, Yar Ilich wrote:

 Hi,

 pleasure to be of use. I got confused: did client part omit headers
 from POST request? Where did you get the message "No
 'Access-Control-Allow-Origin' header is present on the requested resource."
 from? The problem may be some caveats of using Access-Control-Allow-Origin.
 See http://www.webdavsystem.com/ajax/programming/cross_origin_requests,
 specifically the first Important! box.

 On 16 August 2015 at 10:07, Austin Guest  wrote:

> Great implementation `yar...`!
>
> Question: I borrowed this code in my own implementation but ran into
> an odd problem where it worked just fine on the preflight `OPTIONS`
> request, but then omitted the CORS headers from the subsequent `POST` that
> was getting preflighted, causing the request to be rejected with a 400
> Error. ("No 'Access-Control-Allow-Origin' header is present on the
> requested resource.' etc...)
>
> Here's my version of your impl:
>
> https://github.com/the-learning-collective/whereat-server/blob/dev/src/main/scala/routes/CorsSupport.scala
>
> And here's me using it:
>
> https://github.com/the-learning-collective/whereat-server/blob/master/src/main/scala/routes/Routes.scala#L24
>
> Any idea why I'm getting this error?
>
> I'm using superagent  on
> the client side (which someone had this CORS-related issue
>  with, but I
> think that's a red-herring, since I very much want/need my `content-type`
> to be `application/json`, unlike this user and the proposed solution he
> winds up being offered.)
>
>
>
> On Thursday, June 18, 2015 at 12:23:50 PM UTC-4, yar@gmail.com
> wrote:
>>
>> Hi,
>>
>> I didn't find a counterpart of mapRequestContext in akka-http, so I
>> just allow all the methods I have in my route. Here is my shot at CORS in
>> akka-http:
>>
>> import akka.http.scaladsl.model.HttpMethods._
>> import akka.http.scaladsl.model.HttpResponse
>> import akka.http.scaladsl.model.headers._
>> import akka.http.scaladsl.server.Directives._
>> import akka.http.scaladsl.server.{AuthenticationFailedRejection, 
>> Directive0, 

Re: [akka-user] Re: CORS Support Akka-http

2016-07-14 Thread Matan Safriel
Any built-in support for CORS by now?

On Friday, September 25, 2015 at 5:20:07 PM UTC+3, Patrik Nordwall wrote:
>
> Thanks for sharing, Patrick.
>
> On Tue, Sep 22, 2015 at 1:42 PM, Patrick Ting  > wrote:
>
>> Hi Everyone,
>>
>> I ended up porting and modifying Ganta's original CORS support with an 
>> existing one I had that I pulled from the Spray mailing list awhile back 
>> and posted it here: https://gist.github.com/pcting/2e65c36f868c5cee7d6a
>>
>> The most frustrating part was finding a way around the loss of 
>> RequestContext.withRouteResponseHandling and 
>> RequestContext.withHttpResponseHeadersMapped.
>>
>> Please fork it, poke holes int it, and send feedback!
>>
>> Cheers,
>> Patrick
>>
>> On Monday, August 17, 2015 at 1:40:42 PM UTC-7, Austin Guest wrote:
>>>
>>> Hi Yar. Thanks for getting back! The error message was regarding headers 
>>> missing from the *server's* response to the actual POST request (it handled 
>>> the "pre-flight" OPTIONS request just fine, which is why I was puzzled.
>>>
>>> I've since resolved the question, as it was a matter (as the blog you 
>>> linked to helpfully pointed out) of the wildcard `*` as a value for the 
>>> `Allow-Access-Origin` header being incompatible with setting 
>>> `Allow-Access-Credentials` to `true`. I temporarily resolved the issue by 
>>> disabling access credentials. Thanks for pointing me in the right 
>>> direction! :)
>>>
>>> Not the best long-term fix, but necessary for the time being as a 
>>> workaround for running locally (since I will always have the origin 
>>> 'localhost'. As a longer term fix, I plan on using Chrome's 
>>> Allow-Access-Origin 
>>> Dev Tools add-on 
>>> ,
>>>  
>>> which spoofs a '*' header for running locally -- just as soon as I can 
>>> figure out how to get my webpack dev server 
>>> to disable 
>>> credentials so the the Allow-Access headers won't conflict.
>>>
>>> If anyone's stuck on a similar problem and is interested in results, I'm 
>>> happy to post them here. (Though that set of problem solving would belong 
>>> more properly on a React mailing list than one pertaining to akka-http! :P)
>>>
>>> /a/
>>>
>>> On Sunday, August 16, 2015 at 5:12:29 AM UTC-4, Yar Ilich wrote:

 Hi, 

 pleasure to be of use. I got confused: did client part omit headers 
 from POST request? Where did you get the message "No 
 'Access-Control-Allow-Origin' header is present on the requested 
 resource." 
 from? The problem may be some caveats of using 
 Access-Control-Allow-Origin. 
 See http://www.webdavsystem.com/ajax/programming/cross_origin_requests, 
 specifically the first Important! box.

 On 16 August 2015 at 10:07, Austin Guest  wrote:

> Great implementation `yar...`!
>
> Question: I borrowed this code in my own implementation but ran into 
> an odd problem where it worked just fine on the preflight `OPTIONS` 
> request, but then omitted the CORS headers from the subsequent `POST` 
> that 
> was getting preflighted, causing the request to be rejected with a 400 
> Error. ("No 'Access-Control-Allow-Origin' header is present on the 
> requested resource.' etc...)
>
> Here's my version of your impl:
>
> https://github.com/the-learning-collective/whereat-server/blob/dev/src/main/scala/routes/CorsSupport.scala
>
> And here's me using it:
>
> https://github.com/the-learning-collective/whereat-server/blob/master/src/main/scala/routes/Routes.scala#L24
>
> Any idea why I'm getting this error? 
>
> I'm using superagent  on 
> the client side (which someone had this CORS-related issue 
>  with, but I 
> think that's a red-herring, since I very much want/need my `content-type` 
> to be `application/json`, unlike this user and the proposed solution he 
> winds up being offered.)
>
>
>
> On Thursday, June 18, 2015 at 12:23:50 PM UTC-4, yar@gmail.com 
> wrote:
>>
>> Hi,
>>
>> I didn't find a counterpart of mapRequestContext in akka-http, so I 
>> just allow all the methods I have in my route. Here is my shot at CORS 
>> in 
>> akka-http:
>>
>> import akka.http.scaladsl.model.HttpMethods._
>> import akka.http.scaladsl.model.HttpResponse
>> import akka.http.scaladsl.model.headers._
>> import akka.http.scaladsl.server.Directives._
>> import akka.http.scaladsl.server.{AuthenticationFailedRejection, 
>> Directive0, RejectionHandler, Route}
>> import com.typesafe.config.ConfigFactory
>>
>> trait CorsSupport {
>>   lazy val allowedOrigin = {
>> val config = ConfigFactory.load()
>> val sAllowedOrigin = config.getString("cors

Re: [akka-user] Akka create two Tcp Connections with the same port

2016-07-14 Thread Chris Stewart
So just to make sure I understand you, I NEED to create this virtual 
interface if the hosts resolve to different ip addresses, or akka should 
work out of the box if the hosts resolve to different ip addresses. 

On Tuesday, July 12, 2016 at 8:32:08 AM UTC-5, Akka Team wrote:
>
> That will only be possible if the hosts resolve to different IP-addresses 
> on the machine they are run on. For example you could create a virtual 
> interface with a separate IP address for one of the hostnames.
>
> --
> Johan
>
> On Mon, Jul 11, 2016 at 9:12 PM, Chris Stewart  > wrote:
>
>> Hi, as the title says i'm trying to create 2 tcp connections from the 
>> same port 
>>
>> Here is the stackoverflow question: 
>> https://stackoverflow.com/questions/38314437/akka-create-two-tcp-connections-with-the-same-port
>>
>> I'm trying to create two tcp connections that are bound to the same port. 
>> I'm getting an error saying that the `java.net.BindException: Address 
>> already in use`. This makes sense since they are both using `18333` as a 
>> port, but there must be some way to have two connections on a port that 
>> have unique hosts. I'm following along with the [guide in the akka tcp 
>> manual][1]. How can I make this work? The protocol says that connections 
>> need to be created on `18333`, however if I can only have one peer at a 
>> time it makes the p2p portion of the protocol useless. 
>>
>> Here is the code: 
>>
>> val probe1 = TestProbe()
>> val probe2 = TestProbe()
>> val client1 = system.actorOf(Client.props(TestNet3, probe1.ref))
>> val client2 = system.actorOf(Client.props(TestNet3, probe2.ref))
>>
>> val local = new InetSocketAddress(18333)
>>
>> val remote1 = new InetSocketAddress("
>> testnet-seed.bitcoin.petertodd.org", 18333)
>>
>> client1 ! Tcp.Connect(remote1,Some(local))
>> probe1.expectMsgType[Tcp.Connected]
>>
>> val remote2 = new InetSocketAddress("testnet-seed.bluematt.me", 
>> 18333)
>> client2 ! Tcp.Connect(remote2,Some(local))
>> probe2.expectMsgType[Tcp.Connected]
>>
>>
>> client1 ! Tcp.Abort
>> client2 ! Tcp.Abort
>>
>>
>>   [1]: http://doc.akka.io/docs/akka/2.3.15/scala/io-tcp.html#Connecting
>>
>> -- 
>> >> 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+...@googlegroups.com .
>> To post to this group, send email to akka...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/akka-user.
>> For more options, visit https://groups.google.com/d/optout.
>
>

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


[akka-user] KillSwitch not having an effect

2016-07-14 Thread robinmoss
Hello,

I've been arguing with KillSwitch for a couple of hours and seem to be 
unable to get it to work, the example for using it gives the following code:



   1. final Source countingSrc = Source.from(new ArrayList
   <>(Arrays.asList(1, 2, 3, 4)))
   2..delay(FiniteDuration.apply(1, TimeUnit.SECONDS), 
   DelayOverflowStrategy.backpressure());
   3. final Sink> lastSnk = Sink.last();
   4. 
   5. final Pair> stream = 
   countingSrc
   6..viaMat(KillSwitches.single(), Keep.right())
   7..toMat(lastSnk, Keep.both()).run(mat);
   8. 
   9. final UniqueKillSwitch killSwitch = stream.first();
   10. final CompletionStage completionStage = stream.second();
   11. 
   12. doSomethingElse();
   13. killSwitch.shutdown();
   14. 
   15. final int finalCount = completionStage.toCompletableFuture().get(1, 
   TimeUnit.SECONDS);
   16. assertEquals(2, finalCount);


I tweaked it slightly to make it run locally but the finalCount is always 
4, I then spent a bit of time trying to work out whats happening and wrote 
the following:

Sink> sink = Sink.last();

Source source = Source.from(Arrays.asList(0, 1, 2, 
3, 4, 5, 6, 7, 8, 9, 10));

final Pair> stream = 
source.via(new StubFlow("pre"))
.viaMat(KillSwitches.single(), Keep.right()).via(new 
StubFlow("post")).toMat(sink, Keep.both())
.run(mat);

final UniqueKillSwitch killSwitch = stream.first();
final CompletionStage completionStage = stream.second();

Thread.sleep(2000);

System.out.println("Calling shutdown");
killSwitch.shutdown();
System.out.println("Shutdown called");

final int finalCount = completionStage.toCompletableFuture().get(1, 
TimeUnit.SECONDS);
System.out.println("count = " + finalCount);


and the stub flow is:

 public class StubFlow extends GraphStage> {

public final Outlet out = Outlet.create("StubFlow.out");

public final Inlet in = Inlet.create("StubFlow.in");

private final FlowShape shape = FlowShape.of(in, out);

private final String name;

public StubFlow(String name) {
this.name = name;
}

@Override
public FlowShape shape() {
return shape;
}

@Override
public GraphStageLogic createLogic(Attributes arg0) {
return new GraphStageLogic(shape) {
{
setHandler(in, new AbstractInHandler() {

@Override
public void onUpstreamFailure(Throwable ex) throws 
Exception {
ex.printStackTrace();
}

@Override
public void onUpstreamFinish() throws Exception {
System.out.println(name + " - upstream finished"
);
completeStage();
}

@Override
public void onPush() throws Exception {
I input = grab(in);
System.out.println(input);
push(out, input);
Thread.sleep(1000);

}
});
setHandler(out, new AbstractOutHandler() {

@Override
public void onPull() throws Exception {
pull(in);

}
});
}
};
}

}

Whats odd is that dispite calling KillSwitch.shutdown(), the stream will 
complete normally and the output ends up being:


0
> 0
> Calling shutdown
> 1
> Shutdown called
> 1
> Exception in thread "main" java.util.concurrent.TimeoutException  
>
2
> 2
> 3
> 3
> 4
> 4
> 5
> 5
> 6
> 6
> 7
> 7
> 8
> 8
> 9
> 9
> 10
> pre - upstream finished
> 10
> post - upstream finished
>


Am i using the KillSiwtch wrong or is something else going wrong?

Thanks,
Robin

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


Re: [akka-user] Akka Streams as an ETL tool?

2016-07-14 Thread James Matlik
Using Akka streams for ETL is our primary use case. The back pressure
support has been extremely useful in helping us maximize throughout while
at the same time avoid overwhelming the multiple external rest services we
query against. By maintaining dedicated, fixed sized dispatcher pools, we
can easily use our legacy blocking client SDKs over a fixed max number of
concurrent connections/requests. Then the ETL can process as fast as it
possibly can within those constraints.

We found the learning curve to be on the steep side, but once it clicks,
the power and ease of use Streams provides is... impressive...
refreshing... exhilarating... addicting.. take your pick.

On Jul 14, 2016 12:28 AM, "Beno"  wrote:

> Ive been using Akka streaming for a use case which I dont see much about -
> that of a small/moderate scale ETL or simple processing pipeline. Im
> relatively new to it all, so I just wanted to see if I might be missing
> something that would change my opinion, which is that Akka Streams is among
> the best tools for data cleaning--  the graph dsl is so easy to code with
> and reason about.
>
> The details: Batch processing to clean and curate data, with external
> calls RESTful requests as part of the flow.
>
> Source[A] (read from file or DB) ~> Flow[A,B](some transformation
> function) ~>  Flow[B,C] (by way of a RESTful request/response) ~>
> Flow[C,D](graph query) ~> Sink[D](to DB)
>
> Where Source might be 50,000 lines in a file or rows in a table.
>
> Thanks for any feedback
>
> --
> >> 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.
>

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