How can an EJB parallelize a long, CPU intensive process?

前端 未结 6 751
礼貌的吻别
礼貌的吻别 2020-12-05 11:51

The application has a CPU intensive long process that currently runs on one server (an EJB method) serially when the client requests it.

It’s theoretically possible

6条回答
  •  离开以前
    2020-12-05 12:44

    An EJB is a ultimately a transactional component for a client-server system providing request/reply semantics. If you find yourself in the position that you need to pigeonhole a long-running transaction within the bounds of a request/reply cycle, then somewhere your system architect(ure) has taken the wrong turn.

    The situation you describe is cleanly and correctly handled by an event based architecture with a messaging back end. Initial event initiates the process (which can then be trivially parallelized by having the workers subscribe to the event topic) and the aggregating process itself raises an event on its completion. You can still squeeze these sequence within the bounds of a request/reply cycle, but you will by necessity violate the letter and spirit of the Java EE system architecture specs.

提交回复
热议问题