On 08/25/2015 11:34 AM, Endre Varga wrote:
Hi Simon,
tcpFlow is the description of a TCP connetion, it does not connect
itself. Whenever you materialize that flow as part of a larger stream,
it connects.
Your send() method calls "runFold" on a stream that contains this
tcpFlow, therefore you always open a new connection in send().
Ok, thanks. That clears out a lot of things. Still, I don't understand
how I move from a finite stream to an infinite one. I just want to have
one single open connection (maybe more than one, but then they come from
a connection pool) over which I can send and receive data.
I thought the whole point of reactive streams is to make working with
infinite data easy. But the akka-strems documentation never mentions
that. They explain things with a `Source(1 to 100)`, which isn't very
useful, since it is finite. This concept of materializing also doesn't
make sense to me when I have infinite data. I can't materialize
anything, since there is no end. For finite data I can just use the
collection library, I don't see why I should use akka-streams here.
-Endre
On Fri, Aug 21, 2015 at 11:39 PM, Simon Schäfer <[email protected]
<mailto:[email protected]>> wrote:
I get the following log messages every time I send a message to to
the remote system:
backend [DEBUG] [08/21/2015 23:26:40.513]
[default-akka.actor.default-dispatcher-23]
[akka://default/system/IO-TCP/selectors/$a/18] Attempting
connection to [/127.0.0.1:6666 <http://127.0.0.1:6666>]
backend [DEBUG] [08/21/2015 23:26:40.514]
[default-akka.actor.default-dispatcher-23]
[akka://default/system/IO-TCP/selectors/$a/18] Connection
established to [/127.0.0.1:6666 <http://127.0.0.1:6666>
Does this mean a connection is created every time I try to send
something or is the connection reused? I would prefer the latter
how can I achieve that if it is not already the case?
My code looks basically like this:
// I would like to do some caching here
val tcpFlow = Tcp().outgoingConnection(host, port)
// Here, a connection should only be created when none exists
def send() = {
implicit val m = ActorMaterializer()
val byteString: IndexedSeq[akka.util.ByteString] = ...
val resp =
Source(byteString).via(tcpFlow).runFold(ByteString.empty)(_++_)
resp onComplete { ... }
}
--
>>>>>>>>>> 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]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at http://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 a topic in the
Google Groups "Akka User List" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/akka-user/qpqWePkADwU/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
[email protected]
<mailto:[email protected]>.
To post to this group, send email to [email protected]
<mailto:[email protected]>.
Visit this group at http://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 [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.