Do ESB Actions need to be threadsafe?

Solution Verified - Updated -

Environment

  • Red Hat JBoss SOA Platform (SOA-P)

    • 4.x
    • 5.x
  • Red Hat JBoss Fuse Service Works (FSW)

    • 6.x

Issue

  • Are ESB action classes in the Action Processing Pipeline thread-safe? That is to say, are action classes singular (like the servlet model) or are they pooled (like the ejb model). It is very critical because the former means that the developer must code the actions in a thread-safe manner.
  • Is a new instance of my Action class created for each call?

Resolution

  • It depends on how the action class is written. If the class extends one of the provided interfaces (ActionLifecyle or ActionPipelineProcessor) then there is a single instance that has to be thread safe. If these interfaces are not implemented , directly or indirectly, then the pipeline will create a new instance for every message passing through. Using the @Process annotation to create your action will also result in a single instance which must be thread safe.

  • For Red Hat JBoss Fuse Service Works(SwitchYard based ESB), the situation is similar. Bean instances(@Service for example) are application-scoped and therefore it is not safe to use the instance variables in them.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Comments