From users-return-267492-archive-asf-public=cust-asf.ponee.io@tomcat.apache.org Mon May 6 15:34:16 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 ABB6118060F for ; Mon, 6 May 2019 17:34:15 +0200 (CEST) Received: (qmail 1863 invoked by uid 500); 6 May 2019 15:34:12 -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 1851 invoked by uid 99); 6 May 2019 15:34:12 -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:34:12 +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 6ABD5C368B for ; Mon, 6 May 2019 15:34:11 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.924 X-Spam-Level: X-Spam-Status: No, score=0.924 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FROM_LOCAL_NOVOWEL=0.5, HK_RANDOM_ENVFROM=0.626, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=-0.001, SPF_PASS=-0.001] autolearn=disabled Authentication-Results: spamd4-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id nuKovZbCxBdr for ; Mon, 6 May 2019 15:34:09 +0000 (UTC) Received: from mail-it1-f194.google.com (mail-it1-f194.google.com [209.85.166.194]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTPS id BE9395F10C for ; Mon, 6 May 2019 15:34:07 +0000 (UTC) Received: by mail-it1-f194.google.com with SMTP id u16so9820816itc.0 for ; Mon, 06 May 2019 08:34:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=Bpot+vjMz6U9DAnf7zrnxu2PrpGqdtqUBkNksJtBLoo=; b=cvX2A9Zc4YBK8YweAHvmqRyVig96xpIvgRzE8RqhSghs/5g1YeW8N+cGkRz9IvdfwC jPPfhF5D2o/l1Dnr/pCSon59eqMLFZzhp3kao/oRQfdZf4Jw9sNJUag0q7FKqQyxyfq/ 7MUJ1I4ZN7doXczHlB1brszpG19ufhbuYfZO7SAr7esfDDoyAwk005Nj89g9D6l/Z84x jY87uKqsqCQeUmacejhkCYB/muJK0T4V5WlY3k9AVIMegjdGus8pwCo+AUNUjdOREL9X MTTnoUncImja63HpYkf9X3Dy4QxSRGiHIqcbxAKzbWXCIC2e7n1zVuQME9NFFvXIKqK3 XAvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=Bpot+vjMz6U9DAnf7zrnxu2PrpGqdtqUBkNksJtBLoo=; b=mw51/UUSd3lNYk8sPp5rZqwvjy6WCbyouc3wWXP8JoEyLXbdjx3nFOtt5yNo5leh8a s/eMj+IrNXzhs9tF4ZvxZMWxBuiNCnWdpp5AaSTMGKTvYz/npwIjmOVmfOfHyCGCASlO EnpQJz20D/FoYdb6jjflYANW8me6P0VNtAlq7yTcLR9L/X+Mbn4WDRmyk0FqIsnzC3f3 THZ0ZYvnZfyOQ7lq+owpg03LUtQ/YnU8jC7wA2Azjo52EbrxlmLcHvX7yQX09yq3tZJB WRbZDmFpFIKoG6V4ulOYdOHps7RNeMwoC6pCAwkyL2xbkvdUXhBQhaTye01JdeYsEZs7 OyfQ== X-Gm-Message-State: APjAAAUzWdFqxLVV3n5ikR3ox5yPBJdlyCKRIfktRa+79eFiV7lJ7nwG CGDV/wnr3EqOioykIaCQpeuas2cQEJR58pjeXEweBQ== X-Google-Smtp-Source: APXvYqyFx68h+YLkdccmbIaNcUi9CI3Tjka3ISCgxiZ6M1AUf2v0APdWgTN3u79yTCT1RJyPPNGE4/OdwbhITLiRmaU= X-Received: by 2002:a05:660c:4d0:: with SMTP id v16mr6410794itk.62.1557156840576; Mon, 06 May 2019 08:34:00 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a4f:aa46:0:0:0:0:0 with HTTP; Mon, 6 May 2019 08:33:59 -0700 (PDT) In-Reply-To: References: From: John Dale Date: Mon, 6 May 2019 09:33:59 -0600 Message-ID: Subject: Re: Initiating httpservletrequest from inside Tomcat / TomEE To: Tomcat Users List Cc: users@tomee.apache.org Content-Type: text/plain; charset="UTF-8" Another thought is that servlets maintain contextual information and resources .. that's nice, saves a lot of time. As soon as you need a database resource or an extension of your pruned-back HTTP implementation on the server socket, you'll be rebuilding what Tomcat has already done? 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