English 中文(简体)
有没有Java EE应用程序的"套接字连接池"之类的东西?
原标题:Is there a "Socket Connection Pool" of sorts for Java EE apps?

我在编写一个JAX-RS网络服务。它通过响应客户端调用来运行:

  1. Retrieving some info from a database
  2. Making a call to an external server

2)服务器不公开网络服务接口(即没有WSDL接口或REST API)。相反,它使用TCP/IP上的自定义协议。我想要从我的JAX-RS资源 直接向此服务器进行客户端调用,但我不想为每个调用我的JAX-RS资源而打开连接,验证并关闭连接。有没有方法解决这个问题?换句话说,是否有像“套接字连接池”这样的东西可用于Java EE应用程序?我是否必须使用类似ESB的东西?还是有我忽略的替代方案?

最佳回答

这样做的“正确”方式是为您的外部服务器编写一个JCA连接器。 JCA是Java EE堆栈的一部分,其意义正是如此:从应用服务器到外部系统提供入站和出站连接。它支持连接池,身份验证,事务等(顺便提一下,数据库和JMS代理通过JCA连接器访问)。

然而编写这样的适配器可能相当困难。或许可以研究一下轻量级的方法,使用一个通用的连接池库(例如commons-pool或c3p0),也许会更容易些。

也可以看看关于TCP连接池的这个回答

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签