简体   繁体   English

RMI公开的jBoss EJB上的并发远程调用是否已序列化?

[英]Are concurrent remote invocations on an RMI exposed jBoss EJB serialized?

This is a more detailed version of the same question asked yesterday. 这是昨天提出的同一问题的更详细的版本。

I have a client app which communicates with the server app through RMI calls to stateless EJBs. 我有一个客户端应用程序,该客户端应用程序通过对无状态EJB的RMI调用与服务器应用程序进行通信。 The initial context is being built with these config params: 初始上下文是使用以下配置参数构建的:

InitialContext ctx = new InitialContext(new Hashtable<String, String>() {
  {
    this.put("java.naming.provider.url", "serverUrl:portNumber");
    this.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
    this.put("java.naming.factory.url", "org.jnp.interfaces.TimedSocketFactory");
  }
});

A proxy is then looked up using: 然后使用以下命令查找代理:

ServerBean bean = (ServerBean) ctx.lookup("ejb/ServerBeanImpl");

Client then spawns many threads sharing this same instance of the ServerBean . 然后,客户端会产生许多线程,共享该ServerBean同一实例。 Every thread now and then invokes remote calls on the shared bean. 每个线程现在都会在共享bean上调用远程调用。

My question is, are these calls performed in a serial or parallel manner? 我的问题是,这些调用是以串行还是并行方式执行的? Every remote call is executed on the server. 每个远程调用都在服务器上执行。 Some computing is performed and a result is returned. 执行一些计算并返回结果。 If all calls are serialized then I'll have to limit the number of existing threads since many of them can be blocked on the ServerBean . 如果所有调用都被序列化了,那么我将必须限制现有线程的数目,因为许多线程可以在ServerBeanServerBean

The calls will be blocked by the container on the server side at the very least. 调用至少会被服务器端的容器阻止。 But beware that nearly all app servers have thread pools to limit the number of requests, so having a stateless bean pool size of 1000 and a server thread pool size of 100 does you little good -- your stateless bean pool will never grow past 100. 但是请注意,几乎所有应用服务器都具有线程池来限制请求数,因此,将无状态Bean池大小设为1000,将服务器线程池的大小设为100会对您有好处,因为无状态Bean池永远不会超过100。

So the things to check are: 因此要检查的事情是:

  1. Is there a client-side connection pool and what is its size? 是否有一个客户端连接池,它的大小是多少?
  2. Is there a server-side thread pool and what is its size? 有服务器端线程池,它的大小是多少?

If there is no client-side connection pool and all threads share the same connection, you're pretty much limited right there unless NIO is used between client/server. 如果没有客户端连接池,并且所有线程共享相同的连接,那么除非在客户端/服务器之间使用NIO,否则您将受到很大的限制。

If the goal is to just do things in parallel, I'd use the EJB 3.1 @Asynchronous method support which does support @Remote calls. 如果目标是只是并行执行操作,那么我将使用EJB 3.1 @Asynchronous方法支持,该支持确实支持@Remote调用。 That will give you the most concurrency the most portably without having to worry about throttling your own usage. 这样一来,您便可以最大程度地并发使用最大的并发性,而不必担心限制您自己的使用。

我想使用MDB / MDP是您想要异步行为的方式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM