Red Hat Training

A Red Hat training course is available for Red Hat JBoss Enterprise Application Platform

第 4 章 服务器配置的修改

4.1. 服务器配置迁移选项

要将你的服务器配置从 JBoss EAP 6 到 JBoss EAP 7,您可以使用 JBoss Server Migration Tool 或用管理 CLI 的 migrate 操作进行手动迁移。

JBoss Server Migration Tool

目前正开发的 JBoss Server Migration Tool 将是更新您的配置以包含 JBoss EAP 7 里新的功能和设置且保持现有配置的首选方法。

管理 CLI 的 migrate 操作

您可以使用管理 CLI 的 migrate 操作来更新 JBoss EAP 6 服务器配置文件里的 jacorbmessagingweb 子系统,允许它们运行在新版本上,但请注意其结果并非完整的 JBoss EAP 7 配置。例如:

  • 这个操作不会更新原来的 remote 协议和端口设置为 JBoss EAP 7 现在使用的新的 http-remoting 协议和端口设置。
  • 配置不包括新的 Java EAP 子系统或功能,如群集单点登录部署、优雅关闭等。
  • 配置不包括新的 Java EE 7 功能,如批处理。
  • The migrate operation does not migrate the ejb3 subsystem configuration. For information about possible EJB migration issues, see EJB Server Configuration Changes.

关于使用 migrate 操作来迁移服务器配置的更多信息,请参考管理 CLI 的 migration 操作

4.2. 管理 CLI 的迁移操作

您可以使用管理 CLI 来更新您的 JBoss EAP 6 服务器配置文件以运行在 JBoss EAP 7 上。管理 CLI 提供了 migrate 操作来自动更新之前版本的 jacorbmessagingweb 子系统到新配置里。在进行迁移前,您也可以对 jacorbmessagingweb 子系统执行 describe-migration 操作来复核配置的改动。目前没有 cmpjaxrthreads 的替代选项,您必须从服务器配置里删除它们。

重要

关于 migrate 操作的限制,请参考服务器配置迁移选项。目前正开发的 JBoss Server Migration Tool 将是更新您的配置以包含 JBoss EAP 7 里新的功能和设置且保持现有配置的首选方法。

表 4.1. 子系统迁移和管理 CLI 操作

JBoss EAP 6 子系统JBoss EAP 7 子系统管理 CLI 操作

cmp

no replacement

remove

jacorb

iiop-openjdk

migrate

jaxr

no replacement

remove

messaging

messaging-activemq

migrate

threads

no replacement

remove

web

undertow

migrate

Start the Server and the Management CLI

按照下列步骤更新您的 JBoss EAP 6 服务器配置使其运行在 JBoss EAP 7 里。

  1. 在开始之前,请参考备份重要数据并复查服务器状态。它包含关于确保服务器处于良好状态且已备份合适的文件的重要信息。
  2. 用 JBoss EAP 6 服务器配置启动 JBoss EAP 7 服务器。

    1. 备份 JBoss EAP 7 的服务器配置文件。
    2. 将配置文件从之前版本里复制到 JBoss EAP 7 目录里。

      $ cp EAP6_HOME/standalone/configuration/standalone-full.xml EAP7_HOME/standalone/configuration
    3. 进入 JBoss EAP 7 的安装目录并用 --admin-only 参数启动服务器。

      $ bin/standalone.sh -c standalone-full.xml --admin-only
      注意

      在您启动服务器时,您将在服务器日志里看到下列 org.jboss.as.controller.management-operation 错误。这是预料中的错误,表示旧的子系统配置必须删除并迁移至 JBoss EAP 7。

      • WFLYCTL0402: Subsystems [cmp] provided by legacy extension 'org.jboss.as.cmp' are not supported on servers running this version. Both the subsystem and the extension must be removed or migrated before the server will function.
      • WFLYCTL0402: Subsystems [jacorb] provided by legacy extension 'org.jboss.as.jacorb' are not supported on servers running this version. Both the subsystem and the extension must be removed or migrated before the server will function.
      • WFLYCTL0402: Subsystems [jaxr] provided by legacy extension 'org.jboss.as.jaxr' are not supported on servers running this version. Both the subsystem and the extension must be removed or migrated before the server will function.
      • WFLYCTL0402: Subsystems [messaging] provided by legacy extension 'org.jboss.as.messaging' are not supported on servers running this version. Both the subsystem and the extension must be removed or migrated before the server will function.
      • WFLYCTL0402: Subsystems [threads] provided by legacy extension 'org.jboss.as.threads' are not supported on servers running this version. Both the subsystem and the extension must be removed or migrated before the server will function.
      • WFLYCTL0402: Subsystems [web] provided by legacy extension 'org.jboss.as.web' are not supported on servers running this version. Both the subsystem and the extension must be removed or migrated before the server will function.
  3. 打开新的终端窗口,进入 JBoss EAP 7 安装目录,然后用 --controller=remote://localhost:9999 参数启动管理 CLI。

    $ bin/jboss-cli.sh --connect --controller=remote://localhost:9999

Migrate the JacORB, Messaging, and Web Subsystems

  1. 要在执行迁移前复核对子系统做的配置修改,请执行 describe-migration 操作。

    describe-migration 操作使用下列语法。

    /subsystem=SUBSYSTEM_NAME:describe-migration

    下面的例子描述了在迁移到 JBoss ESP 7 时对 JBoss EAP 6.4 standalone-full.xml 配置文件的修改。我们在输出里删除了条目以增强可读性和节省空间。

    describe-migration 操作的示例

    [standalone@localhost:9999 /] /subsystem=messaging:describe-migration
    {
        "outcome" => "success",
        "result" => {
            "migration-warnings" => [],
            "migration-operations" => [
                {
                    "operation" => "add",
                    "address" => [("extension" => "org.wildfly.extension.messaging-activemq")],
                    "module" => "org.wildfly.extension.messaging-activemq"
                },
                {
                    "operation" => "add",
                    "address" => [("subsystem" => "messaging-activemq")]
                },
                <!-- *** Entries removed for readability *** -->
                {
                    "operation" => "remove",
                    "address" => [("subsystem" => "messaging")]
                },
                {
                    "operation" => "remove",
                    "address" => [("extension" => "org.jboss.as.messaging")]
                }
            ]
        }
    }

  2. 执行 migrate 操作以迁移子系统配置。这个操作使用下列语法。

    /subsystem=SUBSYSTEM_NAME:migrate
    注意

    messaging 子系统及 describe-migrationmigrate 操作允许您传入参数以配置旧客户的访问。关于命令行语法的更多信息,请参考 Messaging Subsystem Migration and Forward Compatibility

  3. 查看命令的输出和结果。请确保操作成功地完成且没有 "migration-warning" 信息。这意味着子系统配置的迁移已完成。

    成功的 migrate 操作示例(没有警告信息)

    [standalone@localhost:9999 /] /subsystem=messaging:migrate
    {
        "outcome" => "success",
        "result" => {"migration-warnings" => []}
    }

    如果您在日志里看到 "migration-warnings" 信息,这表示服务器配置的迁移已成功完成,但它无法迁移所有的元素和属性。您必须根据 "migration-warnings" 提供的建议运行其他管理 CLI 命令来修改这些配置。下面是一个返回 "migration-warnings" 信息的 migrate 操作示例。

    带有警告信息的 migrate 操作示例

    [standalone@localhost:9999 /] /subsystem=messaging:migrate
    {
        "outcome" => "success",
        "result" => {"migration-warnings" => [
            "WFLYMSG0080: Could not migrate attribute group-address from resource [
        (\"subsystem\" => \"messaging-activemq\"),
        (\"server\" => \"default\"),
        (\"broadcast-group\" => \"groupB\")
    ]. Use instead the socket-binding attribute to configure this broadcast-group.",
            "WFLYMSG0080: Could not migrate attribute group-port from resource [
        (\"subsystem\" => \"messaging-activemq\"),
        (\"server\" => \"default\"),
        (\"broadcast-group\" => \"groupB\")
    ]. Use instead the socket-binding attribute to configure this broadcast-group.",
            "WFLYMSG0080: Could not migrate attribute local-bind-address from resource [
        (\"subsystem\" => \"messaging-activemq\"),
        (\"server\" => \"default\"),
        (\"broadcast-group\" => \"groupA\")
    ]. Use instead the socket-binding attribute to configure this broadcast-group.",
            "WFLYMSG0080: Could not migrate attribute local-bind-port from resource [
        (\"subsystem\" => \"messaging-activemq\"),
        (\"server\" => \"default\"),
        (\"broadcast-group\" => \"groupA\")
    ]. Use instead the socket-binding attribute to configure this broadcast-group.",
            "WFLYMSG0080: Could not migrate attribute group-address from resource [
        (\"subsystem\" => \"messaging-activemq\"),
        (\"server\" => \"default\"),
        (\"broadcast-group\" => \"groupA\")
    ]. Use instead the socket-binding attribute to configure this broadcast-group.",
            "WFLYMSG0080: Could not migrate attribute group-port from resource [
        (\"subsystem\" => \"messaging-activemq\"),
        (\"server\" => \"default\"),
        (\"broadcast-group\" => \"groupA\")
    ]. Use instead the socket-binding attribute to configure this broadcast-group."
        ]}
    }

  4. 查看服务器配置文件以验证扩展、子系统和命名空间都已更新且现有的子系统配置已迁移至 JBoss EAP 7。

    注意

    您必须通过下列命令为 jacorbmessagingweb 子系统重复这个过程。

    /subsystem=jacorb:migrate
    /subsystem=messaging:migrate
    /subsystem=web:migrate
  5. 从服务器配置里删除 cmpjaxrthreads 子系统和扩展。

    在管理 CLI 提示下,执行下列命令删除过时的 cmpjaxrthreads 子系统。

    /subsystem=cmp:remove
    /extension=org.jboss.as.cmp:remove
    /subsystem=jaxr:remove
    /extension=org.jboss.as.jaxr:remove
    /subsystem=threads:remove
    /extension=org.jboss.as.threads:remove
重要

您必须迁移 messagingjacorbweb 子系统并在重启服务器进行正常操作前删除 cmpjaxrthreads 扩展和子系统。如果在完成这个过程前您需要重启服务器,请确保在服务器启动命令里包含 --admin-only 参数。这允许您继续修改配置。

4.3. 日志消息前缀的修改

日志消息用报告该消息的子系统的项目代码作为前缀。JBoss EAP 7 已修改了所有日志消息的前缀。

For a complete list of the new log message project code prefixes used in JBoss EAP 7, see Project Codes Used in JBoss EAP in the JBoss EAP Development Guide.

4.4. Web 服务器配置的修改

4.4.1. 用 Undertow 替换 Web 子系统

在 JBoss EAP 7 里 Undertow 替换了 JBoss Web。这意味着旧的 web 子系统配置必须迁移到新的 JBoss EAP 7 的 undertow 子系统配置。

  • 服务器配置文件里的 urn:jboss:domain:web:2.2 子系统配置命名空间已被 urn:jboss:domain:undertow:3.1 命名空间替代。
  • 位于 EAP_HOME/modules/system/layers/base/ 里的 org.jboss.as.web 扩展模块,已被 org.wildfly.extension.undertow 扩展模块所替代。

您可以使用管理 CLI 的 migrate 操作将服务器配置文件里的 web 子系统迁移到 undertow。然而,请注意这个操作不能迁移所有的 JBoss Web 子系统配置。如果您看到 "migration-warning" 条目,您必须运行其他的管理 CLI 命令来迁移这些配置到 Undertow。关于管理 CLI 的 migrate 操作的更多信息,请参考 Management CLI Migration Operation

下面是 JBoss EAP 6 里默认的 web 子系统配置示例。

<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">
    <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
    <virtual-server name="default-host" enable-welcome-root="true">
        <alias name="localhost"/>
        <alias name="example.com"/>
    </virtual-server>
</subsystem>

下面是 JBoss EAP 6 里默认的 undertow 子系统配置示例。

<subsystem xmlns="urn:jboss:domain:undertow:3.1">
    <buffer-cache name="default"/>
    <server name="default-server">
        <http-listener name="default" socket-binding="http" redirect-socket="https"/>
        <host name="default-host" alias="localhost">
            <location name="/" handler="welcome-content"/>
            <filter-ref name="server-header"/>
            <filter-ref name="x-powered-by-header"/>
        </host>
    </server>
    <servlet-container name="default">
        <jsp-config/>
        <websockets/>
    </servlet-container>
    <handlers>
        <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
    </handlers>
    <filters>
        <response-header name="server-header" header-name="Server" header-value="JBoss-EAP/7"/>
        <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
    </filters>
</subsystem>

4.4.2. 迁移 JBoss Web 重写条件

管理 CLI 的 migrate 操作无法自动迁移重写条件,它们被报告为“migration-warnings”,您必须手动迁移它们。在 JBoss EAP 7 里,您可以用 Undertow Predicates Attributes and Handlers 创建同等的配置。

下面是 JBoss EAP 6 里包含 rewrite 配置的默认 web 子系统配置示例。

<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default" native="false">
    <virtual-server name="default" enable-welcome-root="true">
        <alias name="localhost"/>
        <rewrite name="test" pattern="(.*)/toberewritten/(.*)" substitution="$1/rewritten/$2" flags="NC"/>
        <rewrite name="test2" pattern="(.*)" substitution="-" flags="F">
            <condition name="get" test="%{REQUEST_METHOD}" pattern="GET"/>
            <condition name="andCond" test="%{REQUEST_URI}" pattern=".*index.html" flags="NC"/>
        </rewrite>
    </virtual-server>
</subsystem>

按照 Management CLI Migration Operation 说明启动服务器和管理 CLI,然后用下列命令迁移 web 子系统配置文件。

/subsystem=web:migrate

当您对上述配置运行 migrate 操作时会出现下面的 "migration-warnings" 信息。

/subsystem=web:migrate
{
    "outcome" => "success",
    "result" => {"migration-warnings" => [
        "WFLYWEB0002: Could not migrate resource {
    \"pattern\" => \"(.*)\",
    \"substitution\" => \"-\",
    \"flags\" => \"F\",
    \"operation\" => \"add\",
    \"address\" => [
        (\"subsystem\" => \"web\"),
        (\"virtual-server\" => \"default-host\"),
        (\"rewrite\" => \"test2\")
    ]
}",
        "WFLYWEB0002: Could not migrate resource {
    \"test\" => \"%{REQUEST_METHOD}\",
    \"pattern\" => \"GET\",
    \"flags\" => undefined,
    \"operation\" => \"add\",
    \"address\" => [
        (\"subsystem\" => \"web\"),
        (\"virtual-server\" => \"default-host\"),
        (\"rewrite\" => \"test2\"),
        (\"condition\" => \"get\")
    ]
}",
        "WFLYWEB0002: Could not migrate resource {
    \"test\" => \"%{REQUEST_URI}\",
    \"pattern\" => \".*index.html\",
    \"flags\" => \"NC\",
    \"operation\" => \"add\",
    \"address\" => [
        (\"subsystem\" => \"web\"),
        (\"virtual-server\" => \"default-host\"),
        (\"rewrite\" => \"test2\"),
        (\"condition\" => \"andCond\")
    ]
}"
    ]}
}

复查服务器配置文件,您会看到 undertow 子系统的下列配置。

注意

重写(Rewrite)配置已被舍弃。

<subsystem xmlns="urn:jboss:domain:undertow:3.1">
     <buffer-cache name="default"/>
     <server name="default-server">
         <http-listener name="http" socket-binding="http"/>
         <host name="default-host" alias="localhost, example.com">
             <location name="/" handler="welcome-content"/>
         </host>
     </server>
     <servlet-container name="default">
         <jsp-config/>
     </servlet-container>
     <handlers>
         <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
     </handlers>
 </subsystem>

使用管理 CLI 创建过滤器来替换 undertow 子系统里的重写配置。每个命令您都应该看到 "{"outcome" ⇒ "success"}" 信息。

# Create the filters
/subsystem=undertow/configuration=filter/expression-filter="test1":add(expression="path('(.*)/toberewritten/(.*)') -> rewrite('$1/rewritten/$2')")
/subsystem=undertow/configuration=filter/expression-filter="test2":add(expression="method('GET') and path('.*index.html') -> response-code(403)")

# Add the filters to the default server
/subsystem=undertow/server=default-server/host=default-host/filter-ref="test1":add
/subsystem=undertow/server=default-server/host=default-host/filter-ref="test2":add

复查已更新的服务器配置文件。JBoss Web 子系统现在已完全迁移且已配置了 undertow 子系统。

<subsystem xmlns="urn:jboss:domain:undertow:3.1">
    <buffer-cache name="default"/>
    <server name="default-server">
        <http-listener name="http" socket-binding="http"/>
        <host name="default-host" alias="localhost, example.com">
            <location name="/" handler="welcome-content"/>
            <filter-ref name="test1"/>
            <filter-ref name="test2"/>
        </host>
    </server>
    <servlet-container name="default">
        <jsp-config/>
    </servlet-container>
    <handlers>
        <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
    </handlers>
    <filters>
        <expression-filter name="test1" expression="path('(.*)/toberewritten/(.*)') -> rewrite('$1/rewritten/$2')"/>
        <expression-filter name="test2" expression="method('GET') and path('.*index.html') -> response-code(403)"/>
    </filters>
</subsystem>

For more information about how to configure filters and handlers using the management CLI, see Configuring the Web Server in the JBoss EAP 7 Configuration Guide.

4.4.3. Migrate JBoss Web System Properties

In the previous release of JBoss EAP, system properties could be used to modify the default JBoss Web behavior. For information about how to configure the same behavior in Undertow, see JBoss Web System Properties Migration Reference

4.4.4. Migrate JBoss Web jboss-web.xml Overlay

In JBoss EAP 6, JBoss Web supported the ability to specify additional static files for a web application using the overlay element in the jboss-web.xml file. This feature did not actually overlay existing files, but instead added static files to a deployment outside of the WAR archive.

In the following jboss-web.xml file example, /tmp/mycontents/test.html was returned by the JBoss EAP 6 server when you accessed the URL http://localhost:8080/example/test.html.

<jboss-web>
    <context-root>/example</context-root>
    <overlay>/tmp/mycontents/</overlay>
</jboss-web>

Undertow, which replaces JBoss Web in JBoss EAP 7, does not support the jboss-web.xml file overlay feature.

4.4.5. 迁移全局阀(Global Valve)

以前的 JBoss EAP 版本支持阀(Valve)。阀是在 Servlet 过滤器修改请求或执行其他处理前插入到应用程序的请求处理管道的自定义类。

  • 全局阀(Global Valve)插入到所有应用程序的请求处理管道且在服务器配置文件进行配置。
  • 验证阀(Authenticator valve)验证请求的凭证。
  • 自定义应用程序阀是通过继承 org.apache.catalina.valves.ValveBase 类并配置 jboss-web.xml 描述符文件里的 <valve> 元素来创建的。您必须手动迁移这些阀。

本节描述了如何迁移全局阀。本指南的『Migrate Custom Application Valves』章节涵盖了自定义和验证阀的迁移。

在 JBoss EAP 7 里替换了 JBoss Web 的 Undertow 不支持全局 Valve。然而,通过使用 Undertow 处理程序,您应该能够实现类似的功能。 Undertow 包含了大量的提供常用功能的内嵌处理程序。它也提供创建自定义处理程序的能力,它们可用来替代自定义 Valve 的功能。

如果您的应用程序使用了阀,在迁移至 JBoss EAP 7 时,您必须用合适的 Undertow 处理程序代码替代它们来实现相同功能。

For more information about how to configure handlers, see Configuring Handlers in the JBoss EAP 7 Configuration Guide.

For more information about how to configure filters, see Configuring Filters in the JBoss EAP 7 Configuration Guide.

迁移 JBoss Web 阀

下表列出之前版本的 JBoss EAP 和对应的 Undertow 内置处理程序提供的阀。JBoss Web 阀位于 org.apache.catalina.valves 软件包里。

表 4.2. 阀和处理程序的映射

处理程序

AccessLogValve

io.undertow.server.handlers.accesslog.AccessLogHandler

CrawlerSessionManagerValve

io.undertow.servlet.handlers.CrawlerSessionManagerHandler

ExtendedAccessLogValve

io.undertow.server.handlers.accesslog.AccessLogHandler

JDBCAccessLogValve

相关说明请参考下面的『JDBCAccessLogValve 手动迁移过程』

RemoteAddrValve

io.undertow.server.handlers.IPAddressAccessControlHandler

RemoteHostValve

io.undertow.server.handlers.AccessControlListHandler

RemoteIpValve

io.undertow.server.handlers.ProxyPeerAddressHandler

RequestDumperValve

io.undertow.server.handlers.RequestDumpingHandler

RewriteValve

关于手动迁移这些阀的说明,请参考『迁移 JBoss Web 重写条件』

StuckThreadDetectionValve

io.undertow.server.handlers.StuckThreadDetectionHandler

您可以使用管理 CLI 的 migrate 操作自动迁移满足下列标准的全局阀。

  • 它们必须是之前表里列出的不需要手动处理的阀。
  • 它们必须在服务器配置文件的 web 子系统里进行定义。

关于管理 CLI 的 migrate 操作的更多信息,请参考 Management CLI Migration Operation

JDBCAccessLogValve 的手动迁移过程

org.apache.catalina.valves.JDBCAccessLogValve 阀是规则的一个例外,它不能自动迁移到 io.undertow.server.handlers.JDBCLogHandler。请遵循下面的步骤来迁移示例阀。

<valve name="jdbc" module="org.jboss.as.web" class-name="org.apache.catalina.valves.JDBCAccessLogValve">
    <param param-name="driverName" param-value="com.mysql.jdbc.Driver" />
    <param param-name="connectionName" param-value="root" />
    <param param-name="connectionPassword" param-value="password" />
    <param param-name="connectionURL" param-value="jdbc:mysql://localhost:3306/wildfly?zeroDateTimeBehavior=convertToNull" />
    <param param-name="format" param-value="combined" />
</valve>
  1. 创建一个用于存储日志条目的数据库的驱动模块。
  2. 配置这个数据库的数据源并添加驱动到 datasources 子系统里的可用驱动列表。

    <datasources>
        <datasource jndi-name="java:jboss/datasources/accessLogDS" pool-name="accessLogDS" enabled="true" use-java-context="true">
            <connection-url>jdbc:mysql://localhost:3306/wildfly?zeroDateTimeBehavior=convertToNull</connection-url>
            <driver>mysql</driver>
            <security>
               <user-name>root</user-name>
               <password>Password1!</password>
            </security>
        </datasource>
        ...
        <drivers>
            <driver name="mysql" module="com.mysql">
                <driver-class>com.mysql.jdbc.Driver</driver-class>
            </driver>
        ...
        </drivers>
    </datasources>
  3. 用下列表达式配置 undertow 子系统里的 expression-filterjdbc-access-log(datasource=DATASOURCE_JNDI_NAME)

    <filters>
        <expression-filter name="jdbc-access" expression="jdbc-access-log(datasource='java:jboss/datasources/accessLogDS')" />
        ...
    </filters>

4.5. JGroups 服务器配置的修改

4.5.1. JGroups 默认使用私有网络接口

在 JBoss EAP 6 默认配置里,JGroups 使用了服务器配置文件的 <interfaces> 部分定义的 public 接口。

因为使用专有的网络接口是我们的推荐做法,在默认情况下,JGroups 使用 JBoss EAP 7 里服务器配置文件的 <interfaces> 部分定义的新的 private 接口。

4.5.2. JGroups 频道的修改

JGroups 以 JGroups 频道的形式提供对 HA 服务的组通讯支持。JBoss EAP 7 在服务器配置文件的 jgroups 子系统里引入了 <channel> 元素。您可以用管理 CLI 添加、删除或修改 JGroups频道的配置。

For more information about how to configure JGroups, see Cluster Communication with JGroups in the JBoss EAP Configuration Guide.

4.6. Infinispan 服务器配置的修改

4.6.1. Infinispan 的默认缓存配置的修改

In JBoss EAP 6, the default clustered caches for web session replication and EJB replication were replicated ASYNC caches. This has changed in JBoss EAP 7. The default clustered caches are now distributed ASYNC caches. The replicated caches are no longer even configured by default. See Configure the Cache Mode in the JBoss EAP Configuration Guide for information about how to add a replicated cache and make it the default.

这只适用于新的 JBoss EAP 7 默认配置。如果您从 JBoss EAP 6 迁移配置,那 infinispan 子系统的配置将被保留。

4.6.2. Infinispan 缓存策略的修改

JBoss EAP 7 已修改了 ASYNC 缓存策略的行为。

在 JBoss EAP 6 里,ASYNC 缓存的读操作是与锁无关的。虽然它们永不会阻塞,但很容易导致过时数据的脏读(Dirty Read),例如发生失效切换的时候。这是因为它会允许相同用户之后的请求在之前请求还未完成前开始。在使用分布式模式时,这种随意性是不能接受的,群集拓扑结构的修改可能影响到会话关联性且容易导致数据过时。

在 JBoss EAP 7 里,ASYNC 缓存读操作需要锁。既然它们现在会阻塞相同用户的新请求直至之前的复制完成,这可以防止脏读(Dirty Read)。

4.7. EJB Server Configuration Changes

If you use the management CLI migrate operation to upgrade your existing configuration, you might see exceptions in the server log when you deploy your EJB applications.

重要

If you use the JBoss Server Migration Tool to update your server configuration, the ejb3 subsystem should be configured correctly and you should not see any issues when you deploy your EJB applications.

DuplicateServiceException

The following DuplicateServiceException is caused by caching changes in JBoss EAP 7.

DuplicateServiceException in Server Log

ERROR [org.jboss.msc.service.fail] (MSC service thread 1-3) MSC000001: Failed to start service jboss.deployment.unit."mdb-1.0-SNAPSHOT.jar".cache-dependencies-installer: org.jboss.msc.service.StartException in service jboss.deployment.unit."mdb-1.0-SNAPSHOT.jar".cache-dependencies-installer: Failed to start service
...
Caused by: org.jboss.msc.service.DuplicateServiceException: Service jboss.infinispan.ejb."mdb-1.0-SNAPSHOT.jar".config is already registered

You must reconfigure the cache to resolve this error.

  1. Follow the instructions to Start the Server and the Management CLI.
  2. Issue the following commands to reconfigure caching in the ejb3 subsystem.

    /subsystem=ejb3/file-passivation-store=file:remove
    /subsystem=ejb3/cluster-passivation-store=infinispan:remove
    /subsystem=ejb3/passivation-store=infinispan:add(cache-container=ejb, max-size=10000)
    
    /subsystem=ejb3/cache=passivating:remove
    /subsystem=ejb3/cache=clustered:remove
    /subsystem=ejb3/cache=distributable:add(passivation-store=infinispan, aliases=[passivating, clustered])

4.8. 消息服务器配置的修改

在 JBoss EAP 7 里,ActiveMQ Artemis 作为 JMS 支持提供者替代了 HornetQ。本节描述了如何迁移配置和相关的消息数据。

4.8.1. 消息子系统的服务器配置修改

位于 EAP_HOME/modules/system/layers/base/org.jboss.as.messaging 模块扩展,已被 EAP_HOME/modules/system/layers/base/ 扩展模块替代。

urn:jboss:domain:messaging:3.0 子系统配置命名空间已被 urn:jboss:domain:messaging-activemq:1.0 命名空间替代。

管理模型

多数情况下,我们会尽可能地将元素和属性名称和之前版本保持一致。下表列出了其中一些修改。

表 4.3. 映射消息属性

HornetQ NameActiveMQ Name 

hornetq-server

server

hornetq-serverType

serverType

connectors

connector

discovery-group-name

discovery-group

新的 messaging-activemq 子系统上调用的管理操作已从 /subsystem=messaging/hornetq-server= 改为 /subsystem=messaging-activemq/server=

您可以调用 migrate 操作迁移现有的 JBoss EAP 6 messaging 子系统配置至 JBoss EAP 7 服务器上的 messaging-activemq 子系统。

/subsystem=messaging:migrate

Before you execute the migrate operation, you can invoke the describe-migration operation to review the list of management operations that will be performed to migrate from the existing JBoss EAP 6 messaging subsystem configuration to the messaging-activemq subsystem on the JBoss EAP 7 server.

/subsystem=messaging:describe-migration

对于无法自动迁移的资源或属性,migratedescribe-migration 也会显示一个migration-warnings 列表。

消息子系统的迁移和向前兼容性

用于 messaging 子系统的 describe-migrationmigrate 操作提供了额外的配置参数。如果您想配置消息系统以允许旧的 JBoss EAP 6 客户链接 JBoss EAP 7 服务器,您可以像下面这样添加布尔型 add-legacy-entries 参数至 describe-migrationmigrate 操作。

/subsystem=messaging:describe-migration(add-legacy-entries=true)
/subsystem=messaging:migrate(add-legacy-entries=true)

如果布尔型参数add-legacy-entries 被设置为 truemessaging-activemq 子系统将创建 legacy-connection-factory 资源并添加 legacy-entriesjms-queuejms-topic 资源。

如果布尔型参数add-legacy-entries 被设置为 falsemessaging-activemq 子系统里不会创建旧的资源,且旧的 JMS 客户不能与 JBoss EAP 7 服务器通讯。这是默认值。

For more information about forward and backward compatibility see the Backward and Forward Compatibility in Configuring Messaging for JBoss EAP.

关于管理 CLI migratedescribe-migration 操作的更多信息,请参考 Management CLI Migration Operation

Change in Behavior of forward-when-no-consumers Attribute

The behavior of the forward-when-no-consumers attribute has changed in JBoss EAP 7.

In JBoss EAP 6, when forward-when-no-consumers was set to false and there were no consumers in a cluster, messages were redistributed to all nodes in a cluster.

This behavior has changed in JBoss EAP 7. When forward-when-no-consumers is set to false and there are no consumers in a cluster, messages are not redistributed. Instead, they are kept on the original node to which they were sent.

消息子系统的 XML 配置

XML 配置已根据新的 messaging-activemq 进行了极大的修改以提供和其他 JBoss EAP 子系统更一致的 XML 模式。

It is strongly advised that you do not attempt to modify the JBoss EAP messaging subsystem XML configuration to conform to the new messaging-activemq subsystem. Instead, invoke the legacy subsystem migrate operation. This operation will write the XML configuration of the new messaging-activemq subsystem as a part of its execution.

4.8.2. 迁移消息数据

JBoss EAP 7 里由于 JMS 支持供应商从 HornetQ 变成了 ActiveMQ Artemis,消息数据的格式和位置都发生了变化。

您可以使用下列方式之一来迁移数据:

关于不同版本间消息数据文件夹名称的改动的细节,请参考映射消息文件夹名称

4.8.2.1. 用导出和导入迁移消息数据

通过这个方法,您可以用 HornetQ exporter 工具从之前的版本导出数据。然后您可以用 import-journal 操作来导入 XML 格式的输出文件。

警告

这个方法目前还有一个问题。要查看这个问题的最新情况,请参考 JBEAP-4407 - 从导入的日志读取大型消息时消费者会崩溃并抛出异常 IndexOutOfBoundsException

从之前版本导出消息数据
重要

在您导出消息数据前必须先停止JBoss EAP 6 服务器。

HornetQ 的 exporter 工具从 JBoss EAP 6 生成和导出消息数据到一个 XML 格式的文件。这个命令要求您指定附带 JBoss EAP 6 的 HornetQ JAR 的路径,并将路径作为参数传入之前版本的 messagingbindings/messagingjournal/messagingpaging/messaginglargemessages/ 文件夹,然后指定写入导出的 XML 数据的输出文件。

下面是 HornetQ exporter 工具要求的语法。

java -jar -mp MODULE_PATH org.hornetq.exporter MESSAGING_BINDINGS_DIRECTORY MESSAGING_JOURNAL_DIRECTORY MESSAGING_PAGING_DIRECTORY MESSAGING_LARGE_MESSAGES_DIRECTORY > OUTPUT_DATA.xml

创建自定义模块来确保 HornetQ JAR 的正确版本,包括打补丁或升级时安装的任何 JAR 文件,被加载并对 exporter 工具可用。用您喜欢的编辑器在 EAP6_HOME/modules/org/hornetq/exporter/main/ 目录里创建一个新的 module.xml 文件并复制下列内容:

<?xml version="1.0" encoding="UTF-8"?>
<module xmlns="urn:jboss:module:1.1" name="org.hornetq.exporter">
    <main-class name="org.hornetq.jms.persistence.impl.journal.XmlDataExporter"/>
    <properties>
        <property name="jboss.api" value="deprecated"/>
    </properties>
    <dependencies>
        <module name="org.hornetq"/>
    </dependencies>
</module>
注意

这个自定义模块在 modules/ 而不是 modules/system/layers/base/ 目录里创建。

按照下列步骤来导出数据。

  1. 停止 JBoss EAP 6 服务器。
  2. 按上述步骤创建自定义模块。
  3. 运行下列命令来导出数据。

    $ java -jar jboss-modules.jar -mp modules/ org.hornetq.exporter standalone/data/messagingbindings/ standalone/data/messagingjournal/ standalone/data/messagingpaging standalone/data/messaginglargemessages/ > OUTPUT_DIRECTORY/OldMessagingData.xml
  4. 确保执行完命令后在日志里没有错误或警告信息。
  5. 使用您的操作系统里可用的工具来检验生成的输出文件里的 XML。
导入 XML 格式的消息数据

然后您可以用 import-journal 操作来导入 XML 格式的输出文件。

/subsystem=messaging-activemq/server=default:import-journal(file=OUTPUT_DIRECTORY/OldMessagingData.xml)

4.8.2.2. 用 JMS 桥迁移消息数据

通过这个方法,您可以配置和部署 JMS 桥将消息从 JBoss EAP 6 HornetQ 队列迁移到 JBoss EAP 7 ActiveMQ Artemis 队列。

JMS 桥消费源 JMS 队列或主题里的消息并发送到目标 JMS 队列或主题(通常位于不同的服务器上)。它可以用于桥接 任何 JMS 服务器间的消息,只要这些消息是兼容 JMS 1.1 的。源和目的 JMS 资源通过 JNDI 查找,用于 JNDI 查找的客户类必须捆绑在模块里。然后在 JMS 桥配置里声明模块名。

本节描述了如何配置服务器和部署 JMS 桥来将消息数据从 JBoss EAP 6 迁移到 JBoss EAP 7。

配置 JBoss EAP 6 服务器
  1. 停止 JBoss EAP 6 服务器。
  2. 备份 HornetQ 日志和配置文件

    • 在默认情况下,HornetQ 日志位于 EAP6_HOME/standalone/data/ 目录里。
    • 关于不同版本的默认消息文件夹,请参考映射消息文件夹名称
  3. 确保在 JBoss EAP 6 服务器上定义了包含 JMS 消息的 InQueue JMS 队列。
  4. 确保 messaging 子系统配置包含用于 RemoteConnectionFactory 的条目,类似于:

    <connection-factory name="RemoteConnectionFactory">
        <entries>
            <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
        </entries>
        ...
    </connection-factory>

    如果它没有包含这个条目,请用下列管理 CLI 命令创建:

    /subsystem=messaging/hornetq-server=default/connection-factory=RemoteConnectionFactory:add(factory-type=XA_GENERIC, connector=[netty], entries=[java:jboss/exported/jms/RemoteConnectionFactory],ha=true,block-on-acknowledge=true,retry-interval=1000,retry-interval-multiplier=1.0,reconnect-attempts=-1)
配置 JBoss EAP 7 服务器
  1. 在以前的版本里,JMS 桥配置需要 org.hornetq 模块来连接 HornetQ 服务器。JBoss EAP 7 里这个模块和直接依赖关系已不再出现,所以您必须从之前的版本复制下列模块。

    • 复制 org.hornetq 模块至 JBoss EAP 7 EAP_HOME/modules/org/ 目录。

      • If you did not apply patches to this module, copy this folder from the JBoss EAP 6.4 server: EAP6_HOME/modules/system/layers/base/org/hornetq/
      • If you did apply patches to this module, copy this folder from the JBoss EAP 6.4 server: EAP6_HOME/modules/system/layers/base/.overlays/layer-base-jboss-eap-6.4.x.CP/org/hornetq/
    • Remove the <resource-root> for the HornetQ lib path from the JBoss EAP 7 EAP_HOME/modules/org/hornetq/main/module.xml file.

      • If you did not apply patches to the JBoss EAP 6.4 org.hornetq module, remove the following line from the file:

        <resource-root path="lib"/>
      • If you did apply patches to the JBoss EAP 6.4 org.hornetq module, remove the following lines from the file:

        <resource-root path="lib"/>
        <resource-root path="../../../../../org/hornetq/main/lib"/>
        警告

        Failure to remove the HornetQ lib path resource-root will cause the bridge to fail with the following error in the log file.

        2016-07-15 09:32:25,660 ERROR [org.jboss.as.controller.management-operation] (management-handler-thread - 2) WFLYCTL0013: Operation ("add") failed - address: ([
            ("subsystem" => "messaging-activemq"),
            ("jms-bridge" => "myBridge")
        ]) - failure description: "WFLYMSGAMQ0086: Unable to load module org.hornetq"
    • Copy the org.jboss.netty module into the JBoss EAP 7 EAP_HOME/modules/org/jboss/ directory.

      • If you did not apply patches to this module, copy this folder from the JBoss EAP 6.4 server: EAP6_HOME/modules/system/layers/base/org/jboss/netty/
      • If you did apply patches to this module, copy this folder from the JBoss EAP 6.4 server: EAP6_HOME/modules/system/layers/base/.overlays/layer-base-jboss-eap-6.4.x.CP/org/jboss/netty
  2. 创建 JMS 队列以包含从 JBoss EAP 6 服务器接收的消息。下面是创建 MigratedMessagesQueue JMS 队列以接收消息的管理 CLI 命令的示例。

    jms-queue add --queue-address=MigratedMessagesQueue --entries=[jms/queue/MigratedMessagesQueue java:jboss/exported/jms/queue/MigratedMessagesQueue]

    这会为 JBoss EAP 7 服务器的 messaging-activemq 子系统的默认服务器创建下列 jms-queue 配置。

    <jms-queue name="MigratedMessagesQueue" entries="jms/queue/MigratedMessagesQueue java:jboss/exported/jms/queue/MigratedMessagesQueue"/>
  3. 确保 messaging-activemq 子系统的 default 服务器包含用于 InVmConnectionFactory connection-factory 的配置,类似于:

    <connection-factory name="InVmConnectionFactory" factory-type="XA_GENERIC" entries="java:/ConnectionFactory" connectors="in-vm"/>

    如果它没有包含这个条目,请用下列管理 CLI 命令创建:

    /subsystem=messaging-activemq/server=default/connection-factory=InVmConnectionFactory:add(factory-type=XA_GENERIC, connectors=[in-vm], entries=[java:/ConnectionFactory])
  4. 创建和部署从 JBoss EAP 6 服务器上配置的 InQueue JMS 队列读取消息的 JMS 桥并将其转换为 JBoss EAP 7 上的 MigratedMessagesQueue

    /subsystem=messaging-activemq/jms-bridge=myBridge:add(add-messageID-in-header=true,max-batch-time=100,max-batch-size=10,max-retries=-1,failure-retry-interval=1000,quality-of-service=AT_MOST_ONCE,module=org.hornetq,source-destination=jms/queue/InQueue,source-connection-factory=jms/RemoteConnectionFactory,source-context=[("java.naming.factory.initial"=>"org.jboss.naming.remote.client.InitialContextFactory"),("java.naming.provider.url"=>"remote://127.0.0.1:4447")],target-destination=jms/queue/MigratedMessagesQueue,target-connection-factory=java:/ConnectionFactory)

    这会在 JBoss EAP 7 服务器上的 messaging-activemq 子系统里创建下列 jms-bridge 配置。

    <jms-bridge name="myBridge" add-messageID-in-header="true" max-batch-time="100" max-batch-size="10" max-retries="-1" failure-retry-interval="1000" quality-of-service="AT_MOST_ONCE" module="org.hornetq">
        <source destination="jms/queue/InQueue" connection-factory="jms/RemoteConnectionFactory">
            <source-context>
                <property name="java.naming.factory.initial" value="org.jboss.naming.remote.client.InitialContextFactory"/>
                <property name="java.naming.provider.url" value="remote://127.0.0.1:4447"/>
            </source-context>
        </source>
        <target destination="jms/queue/MigratedMessagesQueue" connection-factory="java:/ConnectionFactory"/>
    </jms-bridge>
  5. 如果为JBoss EAP 6 配置了安全性,你也必须配置 JMS 桥配置 <source> 元素,使其包含指定正确用户名和密码的 source-context,从而在创建连接时用于 JNDI 查找。
迁移数据
  1. 检验您为下列配置提供的信息是否正确。

    • 任何的队列和主题名称
    • 用于 JNDI 查找的 java.naming.provider.url
  2. 确保您已部署了目标 JMS 目的地至 JBoss EAP 7 服务器。
  3. 启动JBoss EAP 6 及 JBoss EAP 7 服务器。

4.8.2.3. 映射消息文件夹位置

下表展示了之前版本使用的消息目录名和本版本里对应的名称。这些目录是相对于 jboss.server.data.dir 的,如果没有指定,它的默认值是 EAP_HOME/standalone/data/

JBoss EAP 6 的目录名称JBoss EAP 7 的目录名称

messagingbindings/

activemq/bindings/

messagingjournal/

activemq/journal/

messaginglargemessages/

activemq/largemessages/

messagingpaging/

activemq/paging/

注意

The messaginglargemessages/ and messagingpaging/ directories might not be present if there are no large messages or if paging is disabled.

4.8.3. 迁移 JMS 目的地

在以前的 JBoss EAP 版本里,JMS 目的地队列是在 messaging 子系统的 <hornetq-server> 元素下的 <jms-destinations> 里配置的。

<hornetq-server>
  ...
  <jms-destinations>
     <jms-queue name="testQueue">
        <entry name="queue/test"/>
         <entry name="java:jboss/exported/jms/queue/test"/>
      </jms-queue>
  </jms-destinations>
  ...
</hornetq-server>

在 JBoss EAP 7 里,JMS 目的地队列是在 messaging-activemq 子系统的默认 <server> 元素里配置的。

<server name="default">
  ...
  <jms-queue name="testQueue" entries="queue/test java:jboss/exported/jms/queue/test"/>
  ...
</server>

4.8.4. 迁移消息拦截器

JBoss EAP 7 里消息拦截器已发生了重大改变,JMS 消息提供者由 HornetQ 替换为 ActiveMQ Artemis。

之前版本里的 HornetQ 的 messaging 子系统要求您将 HornetQ 拦截器添加至 JAR 并修改 module.xml 文件来安装 HornetQ 拦截器。

The messaging-activemq subsystem included in JBoss EAP 7 does not require modification of a module.xml file. User interceptor classes, which now implement the Apache ActiveMQ Artemis Interceptor interface, can now be loaded from any server module. You specify the module from which the interceptor should be loaded in the messaging-activemq subsystem of the server configuration file.

拦截器配置示例

<subsystem xmlns="urn:jboss:domain:messaging-activemq:1.0">
  <server name="default">
    ...
    <incoming-interceptors>
      <class name="com.mycompany.incoming.myInterceptor" module="com.mycompany" />
      <class name="com.othercompany.incoming.myOtherInterceptor" module="com.othercompany" />
    </incoming-interceptors>
    <outgoing-interceptors>
      <class name="com.mycompany.outgoing.myInterceptor" module="com.mycompany" />
      <class name="com.othercompany.outgoing.myOtherInterceptor" module="com.othercompany" />
    </outgoing-interceptors>
  </server>
</subsystem>

4.8.5. 替代 Netty Servlet 配置

在 JBoss EAP 6 里,你可以配置一个 Servlet 引擎与 Netty Servlet 传输一起使用。因为在 JBoss EAP 7 里内置的消息供应商由 ActiveMQ Artemis 替代了 HornetQ,这样的配置不再可用。您必须替换 Servlet 配置以使用新的内置消息 HTTP 连接器和 HTTP 接收器。

4.9. JMX Management Changes

The HornetQ component in JBoss EAP 6 provided its own JMX management; however, it was not recommended and is now deprecated and no longer supported. If you relied on this feature in JBoss EAP 6, you must migrate your management tooling to use either the JBoss EAP management CLI or the JMX management provided with JBoss EAP 7.

You must also upgrade your client libraries to use the jboss-client.jar that ships with JBoss EAP 7.

The following is an example of HornetQ JMX management code that was used in JBoss EAP 6.

JMXConnector connector = null;
try {
    HashMap environment = new HashMap();
    String[] credentials = new String[]{"admin", "Password123!"};
    environment.put(JMXConnector.CREDENTIALS, credentials);

    // HornetQ used the protocol "remoting-jmx" and port "9999"
    JMXServiceURL beanServerUrl = new JMXServiceURL("service:jmx:remoting-jmx://127.0.0.1:9999");

    connector = JMXConnectorFactory.connect(beanServerUrl, environment);
    MBeanServerConnection mbeanServer = connector.getMBeanServerConnection();

    // The JMX object name pointed to the HornetQ JMX management
    ObjectName objectName = new ObjectName("org.hornetq:type=Server,module=JMS");

    // The invoked method name was "listConnectionIDs"
    String[] connections = (String[]) mbeanServer.invoke(objectName, "listConnectionIDs", new Object[]{}, new String[]{});
    for (String connection : connections) {
        System.out.println(connection);
    }
} finally {
    if (connector != null) {
      connector.close();
   }
}

The following is an example of the equivalent code needed for ActiveMQ Artemis in JBoss EAP 7.

JMXConnector connector = null;
try {
    HashMap environment = new HashMap();
    String[] credentials = new String[]{"admin", "Password123!"};
    environment.put(JMXConnector.CREDENTIALS, credentials);

    // ActiveMQ Artemis uses the protocol "remote+http" and port "9990"
    JMXServiceURL beanServerUrl = new JMXServiceURL("service:jmx:remote+http://127.0.0.1:9990");

    connector = JMXConnectorFactory.connect(beanServerUrl, environment);
    MBeanServerConnection mbeanServer = connector.getMBeanServerConnection();

    // The JMX object name points to the new JMX management in the `messaging-activemq` subsystem
    ObjectName objectName = new ObjectName("jboss.as:subsystem=messaging-activemq,server=default");

    // The invoked method name is now "listConnectionIds"
    String[] connections = (String[]) mbeanServer.invoke(objectName, "listConnectionIds", new Object[]{}, new String[]{});
    for (String connection : connections) {
        System.out.println(connection);
    }
} finally {
    if (connector != null) {
      connector.close();
   }
}

Notice that the method names and parameters have changed in the new implementation. You can find the new method names in the JConsole by following these steps.

  1. Connect to the JConsole using the following command.

    EAP_HOME/bin/jconsole.sh
  2. Connect to JBoss EAP local process. Note that it should start with "jboss-modules.jar".
  3. In the MBeans tab, choose jboss.asmessaging-activemqdefaultOperations to display the list of method names and attributes.

4.10. ORB 服务器配置的修改

在 JBoss EAP 7 里 JacORB 实现已用 OpenJDK ORB 的一个下游分支代替。

位于 EAP_HOME/modules/system/layers/base/ 里的 org.jboss.as.jacorb 扩展模块,已被 org.wildfly.iiop-openjdk 扩展模块所替代。

服务器配置文件里的 urn:jboss:domain:jacorb:1.4 子系统配置命名空间已被 urn:jboss:domain:iiop-openjdk:1.0 命名空间替代。

下面是 JBoss EAP 6 里默认的 jacorb 系统配置示例。

<subsystem xmlns="urn:jboss:domain:jacorb:1.4">
    <orb socket-binding="jacorb" ssl-socket-binding="jacorb-ssl">
        <initializers security="identity" transactions="spec"/>
    </orb>
</subsystem>

下面是 JBoss EAP 7 里默认的 iiop-openjdk 子系统配置示例。

<subsystem xmlns="urn:jboss:domain:iiop-openjdk:1.0">
    <orb socket-binding="jacorb" ssl-socket-binding="jacorb-ssl" />
    <initializers security="identity" transactions="spec" />
</subsystem>

新的 iiop-openjdk 子系统配置只接受旧的元素和属性的一个子集。下面是之前 JBoss EAP 版本里的 jacorb 子系统配置,它包含所有的有效元素和属性:

<subsystem xmlns="urn:jboss:domain:jacorb:1.4">
   <orb name="JBoss" print-version="off" use-imr="off" use-bom="off"  cache-typecodes="off"
       cache-poa-names="off" giop-minor-version="2" socket-binding="jacorb" ssl-socket-binding="jacorb-ssl">
       <connection retries="5" retry-interval="500" client-timeout="0" server-timeout="0"
           max-server-connections="500" max-managed-buf-size="24" outbuf-size="2048"
           outbuf-cache-timeout="-1"/>
       <initializers security="off" transactions="spec"/>
   </orb>
   <poa monitoring="off" queue-wait="on" queue-min="10" queue-max="100">
       <request-processors pool-size="10" max-threads="32"/>
   </poa>
   <naming root-context="JBoss/Naming/root" export-corbaloc="on"/>
   <interop sun="on" comet="off" iona="off" chunk-custom-rmi-valuetypes="on"
       lax-boolean-encoding="off" indirection-encoding-disable="off" strict-check-on-tc-creation="off"/>
   <security support-ssl="off" add-component-via-interceptor="on" client-supports="MutualAuth"
       client-requires="None" server-supports="MutualAuth" server-requires="None"/>
   <properties>
       <property name="some_property" value="some_value"/>
   </properties>
</subsystem>

下面的元素和属性不再被支持且必须删除。

表 4.4. 要删除的属性

Element不支持的属性

<orb>

  • client-timeout
  • max-managed-buf-size
  • max-server-connections
  • outbuf-cache-timeout
  • outbuf-size
  • connection retries
  • retry-interval
  • name
  • server-timeout

<poa>

  • queue-min
  • queue-max
  • pool-size
  • max-threads

下面的 on/off 属性不再被支持,在运行管理 CLI migrate 操作迁移时也不会被迁移。如果它们被设置为 on,您将看到迁移警告。这个表里提及的其他 on/off 属性(如 <security support-ssl="on|off">)仍被支持且可以成功迁移。唯一的区别是它们的值将从 on/off 改为 true/false

表 4.5. 要关闭或删除的属性

Element要设置为 off 的属性

<orb>

  • cache-poa-names
  • cache-typecodes
  • print-version
  • use-bom
  • use-imr

<interop>

(all except sun)

  • comet
  • iona
  • chunk-custom-rmi-valuetypes
  • indirection-encoding-disable
  • lax-boolean-encoding
  • strict-check-on-tc-creation

<poa/>

  • monitoring
  • queue-wait

4.11. 迁移 Threads 子系统配置

JBoss EAP 6 服务器配置包含了一个 threads 子系统,它用来管理服务器里不同子系统的线程池。

JBoss EAP 7 里不再有 threads 子系统,相反,每个子系统都负责管理自己的线程池。

For information about how to configure thread pools for the infinispan subsystem, see Configure Infinispan Thread Pools in the JBoss EAP Configuration Guide.

For information about how to configure thread pools for the jgroups subsystem, see Configure JGroups Thread Pools in the JBoss EAP Configuration Guide.

In JBoss EAP 6, you configured thread pools for connectors and listeners for the web subsystem by referencing an executor that was defined in the threads subsystem. In JBoss EAP 7, you now configure thread pools for the undertow subsystem by referencing a worker that is defined in the io subsystem. For more information, see Configuring the IO Subsystem in the JBoss EAP Configuration Guide.

For information about about changes to thread pool configuration in the remoting subsystem, see Migrate the Remoting Subsystem Configuration in this guide, and Configuring the Endpoint in the JBoss EAP Configuration Guide.

4.12. 迁移 Remoting 子系统配置

在 JBoss EAP 6 里,您通过设置 worker-* 属性为 remoting 子系统配置线程池。而 JBoss EAP 7 不再在 remoting 子系统里配置工作节点线程池,如果您试图修改现有的配置,你会看到下面的信息。

WFLYRMT0022: Worker configuration is no longer used, please use endpoint worker configuration

在 JBoss EAP 7 里,工作节点线程池被引用 io 子系统里定义的 worker 的端点配置所替代。

For information about how to configure the endpoint, see Configuring the Endpoint in the JBoss EAP Configuration Guide.

4.13. WebSocket 服务器配置的修改

要在 JBoss EAP 里使用 WebSocket,您需要通过下面的命令行为 JBoss EAP 服务器配置文件里 web 子系统的 http 连接器启用非阻塞式的 JAVA NIO2 连接器协议。

/subsystem=web/connector=http/:write-attribute(name=protocol,value=org.apache.coyote.http11.Http11NioProtocol)

要在应用程序里使用 WebSockets,您也需要在应用程序的 WEB-INF/jboss-web.xml 文件里创建一个 <enable-websockets> 元素并设置其为 true

在 JBoss EAP 7 里,您不再需要配置服务器默认支持 WebSocket 或配置应用程序使用它。WebSocket 是 Java EE 7 规格所要求的,也是默认配置的必需协议。多数复杂的 WebSocket 配置都是在 undertow 子系统的 servlet-container 里完成的。您可以用下列命令查看可用的设置。

/subsystem=undertow/servlet-container=default/setting=websockets:read-resource(recursive=true)
{
   "outcome" => "success",
   "result" => {
       "buffer-pool" => "default",
       "dispatch-to-worker" => true,
       "worker" => "default"
   }
}

JBoss EAP 附带的 quickstarts 里也有关于 WebSocket 的代码示例。

4.14. 单点登录服务器的修改

The infinispan subsystem still provides distributed caching support for HA services in the form of Infinispan caches in JBoss EAP 7; however the caching and distribution of authentication information is handled differently than in previous releases.

在 JBoss EAP 6 里,如果 Infinispan 缓存没有提供单点登录(SSO),那么这个缓存不能是分布式的。

而在 JBoss EAP 7 里,当您选择 HA 配置集时,SSO 是自动分布的。当用 HA 配置集运行时,每台主机都有自己的基于 Web 缓存容器默认缓存的 Infinispan 缓存。这个缓存存储相关的会话和主机的 SSO cookie 信息。JBoss EAP 处理单独的缓存信息向所有主机的传播。 在 JBoss EAP 7 里无法专门分配某个 Infinispan 缓存给 SSO。

在 JBoss EAP 7 里,SSO 是在服务器配置的 undertow 子系统里进行配置的。

SSO 迁移到 JBoss EAP 7 时不需要修改代码。

4.15. 数据源配置的修改

4.15.1. JDBC 数据源驱动名称

当您在以前的 JBoss EAP 版本里配置数据源时,为驱动名指定的值取决于 JDBC 驱动 JAR 里包含的 META-INF/services/java.sql.Driver 文件里列出的类的数量。

包含单个类的驱动

如果 META-INF/services/java.sql.Driver 文件只指定了一个类,驱动名将是 JDBC 驱动 JAR 的名称。JBoss EAP 7 没有改变这一点。

包含多个类的驱动

在 JBoss EAP 6 里,如果 META-INF/services/java.sql.Driver 文件列出了多个类,您可以指定哪个类将其名称附加到 JAR 名称,之后是主要和次要版本号。例如:

JAR_NAME + DRIVER_CLASS_NAME + "_" + MAJOR_VERSION + "_" + MINOR_VERSION

而 JBoss EAP 7 里的命名有所不同,现在您用下列格式指定驱动名称。

JAR_NAME + "_" + DRIVER_CLASS_NAME + "_" + MAJOR_VERSION + "_" + MINOR_VERSION
注意

JAR_NAME 和 DRIVER_CLASS_NAME 之间多了一个下划线。

MySQL 5.1.31 JDBC 驱动是一个包含两个类的例子。其驱动类名是 com.mysql.jdbc.Driver。下面的例子展示了之前版本和当前版本的 JBoss EAP 指定驱动名的不同之处。

JBoss EAP 6 驱动名称示例

mysql-connector-java-5.1.31-bin.jarcom.mysql.jdbc.Driver_5_1

JBoss EAP 7 驱动名称示例

mysql-connector-java-5.1.31-bin.jar_com.mysql.jdbc.Driver_5_1

4.16. 安全服务器配置的修改

For information about Java Security Manager server configuration changes, see Considerations Moving from Previous Versions in How To Configure Server Security for JBoss EAP.

4.17. Transactions 子系统的修改

JBoss EAP 6 的 transactions 子系统里的一些事务管理者配置属性在 JBoss EAP 7 里进行了修改。

Removed Transactions Subsystem Attributes

下表列出了JBoss EAP 7 里删除的 JBoss EAP 6 transactions 子系统属性及其替代属性。

JBoss EAP 6 里的属性JBoss EAP 7 里的接替者

path

object-store-path

relative-to

object-store-relative-to

已舍弃的 Transactions 子系统属性

The following attributes that were available in the transactions subsystem in JBoss EAP 6 are deprecated in JBoss EAP 7. The deprecated attributes might be removed in a future release of the product. The following table lists the equivalent replacement attributes.

JBoss EAP 6 里的属性JBoss EAP 7 里的接替者

use-hornetq-store

use-journal-store

hornetq-store-enable-async-io-to

journal-store-enable-async-io

enable-statistics

statistics-enabled

4.18. mod_cluster 配置的修改

JBoss EAP 7 已修改了 mod_cluster 里的静态代理列表的配置。

在 JBoss EAP 6 里,您会配置 proxy-list 属性,它是一个用逗号隔开的格式为 hostname:port 的 HTTPS 代理地址列表。

JBoss EAP 7 里已舍弃了 proxy-list 属性。它被作为转出套接字绑定名称列表的 proxies 属性替代。

This change impacts how you define a static proxy list, for example, when disabling advertising for mod_cluster. For information about how to disable advertising for mod_cluster, see Disable Advertising for mod_cluster in the JBoss EAP Configuration Guide.

For more information about mod_cluster attributes, see ModCluster Subsystem Attributes in the JBoss EAP Configuration Guide.