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

查看:253
本文介绍了在单个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添加额外的连接器来添加端口). 适用于所有Web服务调用,但不适用于wsdl请求,例如http://localhost:8092/simulator/sim?wsdl,其中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天全站免登陆