A.5. 配置 Jakarta 企业 Beans 线程池


您可以使用管理控制台或管理 CLI 创建 Jakarta Enterprise Beans 线程池。

流程

  1. 登录管理控制台。
  2. 导航到 Configuration Subsystems EJB,然后点 View
  3. 选择 Container Thread Pool
  4. 单击 Add,再指定 Name 和 Max Threads 值。
  5. Save

流程

  1. 使用 add 操作,语法如下:

    /subsystem=ejb3/thread-pool=THREAD_POOL_NAME:add(max-threads=MAX_SIZE)
    Copy to Clipboard Toggle word wrap
    1. THREAD_POOL_NAME 替换为线程池所需的名称。
    2. 使用线程池的最大大小替换 MAX_SIZE
  2. 使用 read-resource 操作来确认线程池已创建:

    /subsystem=ejb3/thread-pool=THREAD_POOL_NAME:read-resource
    Copy to Clipboard Toggle word wrap
    1. 要将 ejb3 子系统中的所有服务重新配置为使用新的线程池,请使用以下命令:

      /subsystem=ejb3/thread-pool=bigger:add(max-threads=100, core-threads=10)
      /subsystem=ejb3/service=async:write-attribute(name=thread-pool-name, value="bigger")
      /subsystem=ejb3/service=remote:write-attribute(name=thread-pool-name, value="bigger")
      /subsystem=ejb3/service=timer-service:write-attribute(name=thread-pool-name, value="bigger")
      reload
      Copy to Clipboard Toggle word wrap

      XML 配置示例:

      <subsystem xmlns="urn:jboss:domain:ejb3:5.0">
          ...
          <async thread-pool-name="bigger"/>
          ...
          <timer-service thread-pool-name="bigger" default-data-store="default-file-store">
          ...
          <remote connectors="http-remoting-connector" thread-pool-name="bigger"/>
          ...
          <thread-pools>
              <thread-pool name="default">
                  <max-threads count="10"/>
                  <core-threads count="5"/>
                  <keepalive-time time="100" unit="milliseconds"/>
              </thread-pool>
              <thread-pool name="bigger">
                  <max-threads count="100"/>
                  <core-threads count="5"/>
              </thread-pool>
          </thread-pools>
          ...
      Copy to Clipboard Toggle word wrap

A.5.3. Jakarta Enterprise Beans 线程池属性

可以利用属性配置 Jakarta Enterprise Beans 线程池,以便更高效地运行满足特定配置需求。

  • max-threads 属性决定了执行者支持的线程总数或最大数量。
/subsystem=ejb3/thread-pool=default:write-attribute(name=max-threads, value=9)
{"outcome" => "success"}
Copy to Clipboard Toggle word wrap
  • core-threads 属性决定了 executor 池中保留的线程数。这包括空闲的线程。如果未指定 core-threads 属性,它将默认为 max-threads 的值。
/subsystem=ejb3/thread-pool=default:write-attribute(name=core-threads, value=3)
{"outcome" => "success"}
Copy to Clipboard Toggle word wrap
  • keepalive-time 属性决定非核心线程可以保持空闲的时间长度。这一次后,将删除非核心线程。
/subsystem=ejb3/thread-pool=default:write-attribute(name=keepalive-time, value={time=5, unit=MINUTES})
{"outcome"=> "success"}
Copy to Clipboard Toggle word wrap
  • 要在不更改 keepalive-time 属性的时间单位的情况下更改时间,请使用以下命令:
/subsystem=ejb3/thread-pool=default:write-attribute(name=keepalive-time.time, value=10)
{"outcome"=> "success"}
Copy to Clipboard Toggle word wrap





更新于 2024-02-09

返回顶部
Red Hat logoGithubredditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。 了解我们当前的更新.

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

Theme

© 2025 Red Hat