在单个 JBoss 实例上设置多个端口? [英] Setting up multiple ports on a single JBoss instance?

查看:20
本文介绍了在单个 JBoss 实例上设置多个端口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题背景

情况是这样的.我们正在运行一个来自战争的模拟器 servlet.我们正在模拟的 servlet 在一台机器上有许多实例,这些实例由端口号区分.我们只想部署一个可以被多个端口访问的单一战争.

Here's the situation. We are running a simulator servlet from a war. The servlet we are simulating has many instances on a single machine differentiated by port number. We would like to only deploy a single war which can be accessed by many ports.

我们目前所拥有的

使用 java Filter(见下面的 web.xml),我们能够根据端口号转发到每个 servlet 实现(通过向 deploy/jbossweb 添加额外的连接器来添加端口.sar/server.xml).这适用于所有网络服务调用,但不适用于 wsdl 请求,例如 http://localhost:8092/simulator/sim?wsdl where 8092是模拟器的理想版本(8091、8092、8093、8094).在该请求中,wsdl 正确返回(每个模拟器实现略有不同),除了 URL soap:address 标记始终使用端口 8091.

Using a java Filter (see below for web.xml) we are able to forward to each servlet implementation based on port number (ports were added by adding extra connectors to deploy/jbossweb.sar/server.xml). This works for all web service calls, but not for wsdl requests like http://localhost:8092/simulator/sim?wsdl where 8092 is the desired version of the simulator out of many (8091, 8092, 8093, 8094). On that request the wsdl is returned correctly (each simulator implementation is slightly different) except that the URL soap:address tag always uses port 8091.

注意:我们使用的是 JBoss 5.0

web.xml 的相关部分:

  <filter>
      <filter-name>SimFilter</filter-name>
      <filter-class>com.example.filter.MyFilter</filter-class>
  </filter>

  <filter-mapping>
      <filter-name>SimFilter</filter-name>
      <url-pattern>/*</url-pattern>
      <dispatcher>REQUEST</dispatcher>
      <dispatcher>INCLUDE</dispatcher>
      <dispatcher>FORWARD</dispatcher>
  </filter-mapping>  

推荐答案

需要修改Tomcat的配置(JBoss使用的是嵌入式版本的Tomcat).

You need to modify Tomcat's configuration (JBoss uses an embedded version of Tomcat).

相关文件是:

$ $JBOSS_HOME/server/default/deploy/jbossweb-tomcat55.sar/server.xml

有一部分用于配置绑定端口.这是默认的:

There is a portion where you configure the binding ports. This is what comes by default:

  <!-- A HTTP/1.1 Connector on port 8080 -->
  <Connector port="8080" address="${jboss.bind.address}"
     maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
     emptySessionPath="true"
     enableLookups="false" redirectPort="8443" acceptCount="100"
     connectionTimeout="20000" disableUploadTimeout="true"/>

您可以添加多个连接器".您需要的每个端口对应一个.

You can add several "connectors". One for each port you need.

然后重新启动您的 JBoss.

Then restart your JBoss.

你会在 LOG 上看到类似这样的内容:

You will see something like this on the LOG:

16:29:13,803 INFO  [Http11BaseProtocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-8080
16:29:13,804 INFO  [Http11BaseProtocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-8091
16:29:13,805 INFO  [Http11BaseProtocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-8092
16:29:13,805 INFO  [Http11BaseProtocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-8093
16:29:13,805 INFO  [Http11BaseProtocol] Initializing Coyote HTTP/1.1 on http-0.0.0.0-8094

这是您需要在 server.xml 文件中添加的内容:

This is what you need to add on your server.xml file:

  <Connector port="8091" address="${jboss.bind.address}"
     maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
     emptySessionPath="true"
     enableLookups="false" redirectPort="8443" acceptCount="100"
     connectionTimeout="20000" disableUploadTimeout="true"/>

  <Connector port="8092" address="${jboss.bind.address}"
     maxThreads="250" strategy="ms" maxHttpHeaderSize="8192"
     emptySessionPath="true"
     enableLookups="false" redirectPort="8443" acceptCount="100"
     connectionTimeout="20000" disableUploadTimeout="true"/>

  ....

每个新端口一个 XML 标记.

One XML tag for each new port.

这篇关于在单个 JBoss 实例上设置多个端口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆