Hi,

I have a simple client that reads a csv file and send it across. When I 
have a netcat server I can see the data come through.

However when I have a Akka stream based server I do see the connection but 
I don't see the data come through. 

Could someone be kind enough to let me know where I have screwed up?

Server code 


        ActorSystem system = ActorSystem.create("System");
        ActorMaterializer mat = ActorMaterializer.create(system);

        Source<IncomingConnection, CompletionStage<ServerBinding>> serverSource 
= Tcp
                .get(system).bind("127.0.0.1", 6000);
        serverSource.runForeach(
                conn -> {
                    System.out.println(conn.remoteAddress());
                    Sink<ByteString, NotUsed> receiveSink = conn
                            .flow()
                            .via(Framing.delimiter(
                                    ByteString.fromString("\r\n"), 100000))
                            .to(Sink.foreach(str -> {
                                System.out.println("< " + str);
                                // Thread.sleep(10);
                            }));
                    Source<ByteString, NotUsed> emptySource = Source.empty();
                    emptySource.to(receiveSink).run(mat);

                }, mat);

​


Client code : Reads a file, prints it line by and sends it over the socket. 
The connecting and sending part works as I can see the data received at a 
netcat server.

        ActorSystem system = ActorSystem.create("client");
        ActorMaterializer mat = ActorMaterializer.create(system);

        Flow<ByteString, ByteString, CompletionStage<OutgoingConnection>> 
serverConnection = Tcp
                .get(system).outgoingConnection("127.0.0.1", 6000);
        Path file = Paths.get("C:\\temp\\Generic.csv");
        CompletionStage<IOResult> cs = FileIO.fromPath(file)

        .via(Framing.delimiter(ByteString.fromString("\r\n"), 100000))
                .map(str -> {
                    System.out.println(str.utf8String());
                    return str.concat(ByteString.fromString("\r\n"));
                })

                .via(serverConnection).to(akka.stream.javadsl.Sink.ignore())
                .run(mat);

​
-chhil

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