Akka Java TCP client , Sink.ignore()

37 views
Skip to first unread message

murtuza chhil

unread,
Jul 29, 2016, 6:48:52 AM7/29/16
to Akka User List

Hi,

I am an Akka newbie trying to get my head around streams.

In the following working snippet, if I have a netcat server running I can get the client to send the bytes across.

The sink.ignore that I added is simply because I needed a sink to connect to to run the graph. Is that really needed and how would I run something without it because as I see it, 
I have a source and a the flow created by the Tcp.get(....), that should be sufficient to send the data. 

Did have a look at the TCpEcho example, but I want to do it without the runfold.

```
Flow<ByteString, ByteString, CompletionStage<OutgoingConnection>> flow = Tcp
.get(system).outgoingConnection("127.0.0.1", 6000);
Source<ByteString, NotUsed> clientSource = Source.single(ByteString
.fromString("Chhil"));
clientSource.via(flow).to(Sink.ignore()).run(mat);
```

-chhil

Johan Andrén

unread,
Aug 1, 2016, 3:15:22 AM8/1/16
to Akka User List
Hi Chhil,

If you do not care about any incoming data from the TCP server Sink.ignore should be fine (it will accept but discard any data from the server).

--
Johan
Akka Team

murtuza chhil

unread,
Aug 1, 2016, 6:20:32 AM8/1/16
to Akka User List
Thanks for the clarification Konrad.
I kind  of figured it was a NoOp sink, but wasn't sure if there would be any side effects due to lack of knowledge.
For now my baby step simply wants to connect. As I move forward the Sink.ignore will get replaced by a sink that handles the responses.
My problem was resolved in this thread.

-chhil
Reply all
Reply to author
Forward
0 new messages