From users-return-267490-archive-asf-public=cust-asf.ponee.io@tomcat.apache.org Mon May 6 15:18:46 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id B1AB018060F for ; Mon, 6 May 2019 17:18:45 +0200 (CEST) Received: (qmail 37662 invoked by uid 500); 6 May 2019 15:18:42 -0000 Mailing-List: contact users-help@tomcat.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Tomcat Users List" Delivered-To: mailing list users@tomcat.apache.org Received: (qmail 37650 invoked by uid 99); 6 May 2019 15:18:42 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 May 2019 15:18:42 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id 87996C22CD for ; Mon, 6 May 2019 15:18:41 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2 X-Spam-Level: ** X-Spam-Status: No, score=2 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=2, RCVD_IN_DNSWL_NONE=-0.0001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=jini-guru.20150623.gappssmtp.com Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id gtsGx2IL--Ev for ; Mon, 6 May 2019 15:18:39 +0000 (UTC) Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTPS id 4FF176126F for ; Mon, 6 May 2019 15:18:39 +0000 (UTC) Received: by mail-wr1-f46.google.com with SMTP id v10so5498541wrt.6 for ; Mon, 06 May 2019 08:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jini-guru.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XDoLZOcTYJbZoQFhiSLiU76PiGaDKRmjfQskR1QL39g=; b=I3MR0dhpj720KQg+qpf/zn3Bn3yQq0syWXEREAACh/IzacLYjDMgku4Jg6dZfUVEJ6 Smt8z5nt2w1Kpzj6EtLmir1Y4/fkywffhfmTZabnTjMI2utrsrb77oxboeYVR99ajrDa v3I4pYFsAngjYoKwar+BP61DJH3mt10cmGuY78zyBMkAfYVArlVsltGVFjv1isV+3W9c qwI9O5e8eZN5PvKILytwOJRBSDPh1LpoGMGoMs8TYCu9hjN2qxmn11CD6h02ByThPBpu +8wT4NEY8JNV+LyO1i+LxMgCle2gBbSoBgjCA8ZdM41gIhxHuc8YqGIsUU/w8SEx1xzU 0r9Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XDoLZOcTYJbZoQFhiSLiU76PiGaDKRmjfQskR1QL39g=; b=ZiOVyWrHLjVap4Wn16kfL6rRys9JipMKSxrQTPXZcp1DbUvWxUTf6e9yy8dRbDk69f N3/OYpKI9NoD4Ei/YYzgJmOyohTpLxJV0L1BwGj/OoDoVLrwzIuarrdd1+HRALent+tU isOxJpuPdyWugKtvs4VfUu8yG/dpwBsgXlrLorqvz6bzw1xyhdXTipmYz8K8arBWvZTu rV67Biy5KdMCmz2uW6nWIEsCEPd2N9B+tKc5ciRUJA5zNrXy+i+TZzRkKgjiYlj7EPKb lku2tA9ImAXP2O1wNaY5lLwMNaxp/SjxR5NePCM0V695veSiGv1AKkG+0iKvLCStMw2o N2ZQ== X-Gm-Message-State: APjAAAVu/vvqubjmxVmeo9c69vx2SfkKqtk8cezkrCYAGEShXNGtDK4z YyLO/wMwnksuU4ceAQ40TTxLU7rLo3scleG/D/KTubm9Lf8= X-Google-Smtp-Source: APXvYqyheB9kOKg2bUhhGvyuwpD+/e6edslfkNgnU7KGPG6hRdI16CBgRECNgYT0nX6gNaCigpcM1QSDdQ22RNae9Qw= X-Received: by 2002:a05:6000:104c:: with SMTP id c12mr18357728wrx.35.1557155918019; Mon, 06 May 2019 08:18:38 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Paul Carter-Brown Date: Mon, 6 May 2019 17:18:26 +0200 Message-ID: Subject: Re: Initiating httpservletrequest from inside Tomcat / TomEE To: Tomcat Users List Cc: users@tomee.apache.org Content-Type: multipart/alternative; boundary="0000000000005aa5060588399d13" --0000000000005aa5060588399d13 Content-Type: text/plain; charset="UTF-8" I think we are completely missing each other. Forget sockets - that was just an example. I have code running in a Tomcat App server which is not managed by Tomcat and is not initiated by anything within Tomcat. That code now wants to call a servlet hosted in that very same JVM. Any way to do that without going out and back in on TCP? On Mon, May 6, 2019 at 5:14 PM John Dale wrote: > Sockets are an implementation of TCP/UDP inherently. > > Perhaps a mountaintop signal fire? > > ;) > > John > > > On 5/6/19, Paul Carter-Brown wrote: > > lol on the Semaphore Telegraph, > > > > I can't use a request dispatcher as the request is being initiated from > > code that has no context. I already have it working with HTTP using > > asynchttp library, but I want to avoid the overhead. E.g. lets say I > wrote > > my own server socket listener on port 10000 running in the Tomcat JVM and > > got some request in some propriatary protocol called X. Now I want to > call > > a Tomcat servlet in the current JVM with some info I got over X without > > going out on TCP and back in.... > > > > On Mon, May 6, 2019 at 4:40 PM John Dale wrote: > > > >> If you're wanting to forward control to another servlet deployed in > >> the same context: > >> https://www.javatpoint.com/requestdispatcher-in-servlet > >> > >> If you are okay going through TCP to facilitate some future or current > >> distribution of services, Use HTTPURLConnection (not sure what you're > >> wanting to do with the result of the request, if anything): > >> > >> > https://stackoverflow.com/questions/2793150/how-to-use-java-net-urlconnection-to-fire-and-handle-http-requests > >> > >> If you need more sophisticated HTTP interactions, Apache maintains a > >> very useful library for that: http://hc.apache.org/ > >> > >> If these don't work-out for you, rather than using .NET, PHP, Python, > >> or some other Java facsimile at best, I recommend using the semaphore > >> telegraph: > >> https://en.wikipedia.org/wiki/Semaphore_telegraph > >> > >> Sincerely, > >> > >> John > >> DB2DOM > >> > >> On 5/6/19, Paul Carter-Brown wrote: > >> > Hi John, > >> > > >> > Thanks for your feedback. > >> > > >> > The request I'm initiating should not or need not carry any context > >> > from > >> > the originating code. There is also no session to worry about as its > >> > just > >> > for rest calls. So basically I have the headers, path and body and > need > >> to > >> > generate a http servlet request and get an http servlet response (or > >> > similar) back. I have this working by calling into localhost but > >> > ideally > >> > want to skip the trombone out and back in. > >> > > >> > Have you got any basic code examples? > >> > > >> > Paul > >> > > >> > On Tue, Apr 30, 2019 at 5:27 PM John Dale wrote: > >> > > >> >> Another thought .. you can do some request dispatching, but without > >> >> knowing more about the tools you're using, I can't say for sure if > >> >> this is the direction you'll want to go. > >> >> > >> >> On 4/29/19, Paul Carter-Brown wrote: > >> >> > Hi > >> >> > > >> >> > I'm trying to design a Kafka consumer and producer that will run > >> inside > >> >> the > >> >> > tomcat jvm and pick up messages off a Kafka topic and translate > them > >> >> into a > >> >> > servlet request and pass it through tomcat and then when the > >> >> > response > >> >> > is > >> >> > complete then translate it into a Kafka message and put it onto > >> another > >> >> > topic as a reply. This way I can reuse our existing jax-rs rest > >> >> > services > >> >> > and expose them as an async api over Kafka. The idea is to make the > >> >> > Kafka > >> >> > messages similar to http in that they would consist of headers and > a > >> >> body. > >> >> > The body would be json. > >> >> > > >> >> > Now I know this could be done by calling localhost with an http > call > >> to > >> >> > trombone the requests back into tomcat but I'd like to avoid the > >> >> associated > >> >> > latency and overhead. Is it possible to call tomcat directly > >> >> > in-process. > >> >> > This does not need to be portable to other containers so can be > >> >> > proprietary. > >> >> > > >> >> > I'm using tomcat 8. In fact its tomee 8 but guessed this is more a > >> >> > tomcat > >> >> > question than tomee but have sent to both groups just in case. > >> >> > > >> >> > Thanks for any insights. > >> >> > > >> >> > Paul > >> >> > > >> >> > >> > > >> > >> --------------------------------------------------------------------- > >> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > >> For additional commands, e-mail: users-help@tomcat.apache.org > >> > >> > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org > For additional commands, e-mail: users-help@tomcat.apache.org > > --0000000000005aa5060588399d13--