edgent-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Julian Feinauer <j.feina...@pragmaticminds.de>
Subject Re: How to connect Apache Edgent instances via HTTP?
Date Sat, 22 Sep 2018 08:21:29 GMT
Short appendix... I postet the link to the old lib.
You should use its successor http://hc.apache.org/

Am 22.09.18, 10:20 schrieb "Julian Feinauer" <j.feinauer@pragmaticminds.de>:

    Hi Tom,
    
    first of, I'm no real expert for Edgent.
    But my first question is, why do you need the HTTP Transport?
    Edgent provides many transport layers that work out of the box and I'm a bit unsure about
HTTP.
    
    For your direct question, sending should be fairly easy with libraries like Apaches HTTP
Client (http://hc.apache.org/httpclient-3.x/).
    But on the receiving side it should be a bit more different as you would need a HTTP Server
Listening, e.g., based on a Custom Servlet in Jetty or something.
    
    Perhaps, if you give some more background on your use case I can try to help you a bit
more.
    
    Best
    Julian
    
    Am 20.09.18, 21:55 schrieb "Tom G." <tom.gelbling@googlemail.com.INVALID>:
    
        Dear Apache Edgent community,
        
        I’m trying to figure out how to establish a HTTP connection between two
        Apache Edgent instances.
        I want to tail an active file and send the appended records via HTTP to
        another Apache Edgent instance.
        The second instance should receive these records via HTTP and write them to
        disk.
        
        My code for the first instance looks like this:
        
        package com.mycompany.app;
        
        import org.apache.edgent.connectors.http.*;
        import org.apache.edgent.connectors.file.*;
        import org.apache.edgent.providers.direct.DirectProvider;
        import org.apache.edgent.topology.TStream;
        import org.apache.edgent.topology.Topology;
        
        /**
         * Edgent Application template.
         */
        
        public class TemplateApp {
        
            public static void main(String[] args) throws Exception {
        
                 //Create a provider
                DirectProvider dp = new DirectProvider();
        
                //Create a topology
                Topology top = dp.newTopology();
        
                //Build the topology
                String watchedDir = "/tmp/test/";
        
                //Read file
                TStream<String> pathnames = FileStreams.directoryWatcher(top, () ->
        watchedDir, null);
                TStream<String> lines = FileStreams.textFileReader(pathnames);
        
                //Insert filter here
            lines.print();
        
                //Insert ‘send data to HTTP server’ here
        
                //Submit the topology
                dp.submit(top);
            }
        }
        
        How do I fill the gap after “//Insert ‘send data to HTTP server’ here” to
        be able to send the records to the second instance?
        
        How does the HTTP part of the second instance have to look like to be able
        to receive these records?
        
        Best regards,
        
        Tom
        
    
    

Mime
View raw message