users@glassfish.java.net

Re: Using an HTTP Client from within Java EE application

From: Jan Algermissen <jan.algermissen_at_nordsc.com>
Date: Thu, 26 Sep 2013 10:25:42 +0200

On 26.09.2013, at 10:12, Paulo Pires <pjpires_at_gmail.com> wrote:

> Why don't use JAX-RS 2.0 client API in an EJB or something like that?

Well, sure. But it opens connection and (maybe) manages its own thread pool (both 'forbidden' by EE spec).

In practive, I use an EJB singleton as a producer for injecting a single JAX-RS 2.0 client instance (assuming JAX-RS 2 Clients being thread safe / making sure I only use a thread save implementation, e.g. Apache client) - this works fine, but works against the idea that the container should manage the connections (and threads).

IOW, it works now, but might not work tomorrow.

Hence my question.

Jan


>
>
> On Tue, Sep 24, 2013 at 4:01 PM, Jan Algermissen <jan.algermissen_at_nordsc.com> wrote:
> Hi,
>
> sorry, I guess I am not the first one to ask this, but searching really does not turn up anything useful for me so far.
>
> In the application In develop, I need to make outgoing HTTP requests. Given I should neither manage HTTP connections nor associated threads myself in an EE container, I wonder
>
> - whether Glassfish maybe comes with the appropriate JCA connector to do this already?
>
> - what other's do (besides ignoring the spec and simply firing up an Apache HTTP client withit's own thread pool)?
>
>
> Jan
>
>
>
> --
> Paulo Pires