Class PipeLine

java.lang.Object
org.springframework.core.io.DefaultResourceLoader
org.springframework.context.support.AbstractApplicationContext
org.springframework.context.support.GenericApplicationContext
All Implemented Interfaces:
Closeable, AutoCloseable, ICacheEnabled<String,String>, ConfigurationAware, FrankElement, HasApplicationContext, HasName, HasTransactionAttribute, IConfigurable, IScopeProvider, ConfigurableLifecycle, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactory, org.springframework.beans.factory.HierarchicalBeanFactory, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.ListableBeanFactory, org.springframework.beans.factory.support.BeanDefinitionRegistry, org.springframework.context.ApplicationContext, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationEventPublisher, org.springframework.context.ConfigurableApplicationContext, org.springframework.context.Lifecycle, org.springframework.context.MessageSource, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, org.springframework.core.AliasRegistry, org.springframework.core.env.EnvironmentCapable, org.springframework.core.io.ResourceLoader, org.springframework.core.io.support.ResourcePatternResolver

Required in each Adapter to transform incoming messages. A pipeline is a sequence of pipes. A pipeline also defines its allowed end states using the <Exits> tag.

The pipes in a PipeLine may not be executed in sequential order, see PipeForward.

A pipeline gathers statistics about the messages it processes.

In the AppConstants there may be a property named log.logIntermediaryResults (true/false) which indicates whether the intermediary results (between calling pipes) have to be logged.

Transaction control

THE FOLLOWING TO BE UPDATED, attribute 'transacted' replaced by 'transactionAttribute' If
invalid reference
transacted
is set to true, messages will be processed under transaction control. Processing by XA-compliant pipes (i.e. Pipes that implement the IXAEnabled-interface, set their transacted-attribute to true and use XA-compliant resources) will then either be committed or rolled back in one transaction. If
invalid reference
transacted
is set to true, either an existing transaction (started by a transactional receiver) is joined, or new one is created (if the message processing request is not initiated by a receiver under transaction control. Messages are only committed or rolled back by the Pipeline if it started the transaction itself. If the pipeline joined an existing transaction, the commit or rollback is left to the object that started the transaction, i.e. the receiver. In the latter case the pipeline can indicate to the receiver that the transaction should be rolled back (by calling UserTransaction.setRollBackOnly()). The choice whether to either commit (by Pipeline or Receiver) or rollback (by Pipeline or Receiver) is made as follows: If the processing of the message concluded without exceptions and the status of the transaction is STATUS_ACTIVE (i.e. normal) the transaction will be committed. Otherwise it will be rolled back, or marked for roll back by the calling party.
Author:
Johan Verrips
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
     

    Nested classes/interfaces inherited from class org.springframework.core.io.DefaultResourceLoader

    org.springframework.core.io.DefaultResourceLoader.ClassPathContextResource
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    static final String
     

    Fields inherited from class org.springframework.context.support.AbstractApplicationContext

    APPLICATION_EVENT_MULTICASTER_BEAN_NAME, LIFECYCLE_PROCESSOR_BEAN_NAME, logger, MESSAGE_SOURCE_BEAN_NAME

    Fields inherited from interface org.springframework.beans.factory.BeanFactory

    FACTORY_BEAN_PREFIX, FACTORY_BEAN_PREFIX_CHAR

    Fields inherited from interface org.springframework.context.ConfigurableApplicationContext

    APPLICATION_STARTUP_BEAN_NAME, BOOTSTRAP_EXECUTOR_BEAN_NAME, CONFIG_LOCATION_DELIMITERS, CONVERSION_SERVICE_BEAN_NAME, ENVIRONMENT_BEAN_NAME, LOAD_TIME_WEAVER_BEAN_NAME, SHUTDOWN_HOOK_THREAD_NAME, SYSTEM_ENVIRONMENT_BEAN_NAME, SYSTEM_PROPERTIES_BEAN_NAME

    Fields inherited from interface org.springframework.core.io.ResourceLoader

    CLASSPATH_URL_PREFIX

    Fields inherited from interface org.springframework.core.io.support.ResourcePatternResolver

    CLASSPATH_ALL_URL_PREFIX

    Fields inherited from interface org.springframework.context.SmartLifecycle

    DEFAULT_PHASE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Deprecated.
    void
    addPipe(IPipe pipe)
    Register a Pipe at this pipeline.
    void
    Deprecated.
    void
     
    void
    Configures the pipes of this Pipeline and does some basic checks.
    void
     
     
    @Nullable PipeForward
     
     
    org.springframework.context.ApplicationContext
     
    long
     
    int
     
    getPipe(int index)
     
    getPipe(String pipeName)
     
    int
     
    @NonNull io.micrometer.core.instrument.DistributionSummary
     
    @NonNull io.micrometer.core.instrument.DistributionSummary
     
    @NonNull io.micrometer.core.instrument.DistributionSummary
     
    @NonNull io.micrometer.core.instrument.DistributionSummary
     
    boolean
     
    process(@NonNull String messageId, @NonNull Message message, @NonNull PipeLineSession pipeLineSession)
    The process method does the processing of a message.
    It retrieves the first pipe to execute from the firstPipe field, the call results in a PipRunResult, containing the next pipe to activate.
    protected void
    registerBeanPostProcessors(@NonNull org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
    Enables the Autowired annotation and ConfigurationAware objects.
    Find the destination of the forward, i.e. the object (Pipe or PipeLineExit) where the forward points to.
    void
    Deprecated.
    void
    Cache of results
    void
    setExpectsSessionKeys(String expectsSessionKeys)
    The pipeline of this adapter expects to use the following session keys to be set on call.
    void
    setFirstPipe(String pipeName)
    Name of the first pipe to execute when a message is to be processed.
    void
    Optional global forwards that will be added to every pipe, when the forward name has not been explicitly set.
    void
    setInputValidator(IValidator inputValidator)
    Request validator, or combined validator for request and response
    void
    Optional pipe to extract the request message from its envelope
    void
    setLocker(Locker locker)
    Optional Locker, to avoid parallel execution of the PipeLine by multiple threads on multiple servers.
    void
    setMaxThreads(int newMaxThreads)
    Maximum number of threads that may execute this Pipeline simultaneously, use 0 to disable limit
    void
    If messageSizeWarn>=0 and the size of the input or result pipe message exceeds the value specified a warning message is logged.
    void
    setOutputValidator(IValidator outputValidator)
    Optional pipe to validate the response.
    void
    Optional pipe to wrap the response message in an envelope
    void
    PipeLine exits.
    void
    If set true the original message without namespaces (and prefixes) is stored under the session key originalMessageWithoutNamespaces
    void
    setTransactionTimeout(int transactionTimeoutSeconds)
    Set transactionTimeout in seconds.
    void
    when specified and null is received as a message the message is changed to the specified value
    void
    Configure and start, managed through the Spring Lifecyle
    protected void
    startPipe(String type, IPipe pipe)
     
    void
    Close the pipeline.
    protected void
    stopPipe(String type, IPipe pipe)
     
     

    Methods inherited from class org.springframework.context.support.GenericApplicationContext

    cancelRefresh, closeBeanFactory, getAutowireCapableBeanFactory, getBeanDefinition, getBeanFactory, getClassLoader, getDefaultListableBeanFactory, getResource, getResources, isAlias, isBeanDefinitionOverridable, isBeanNameInUse, refreshBeanFactory, refreshForAotProcessing, register, registerAlias, registerBean, registerBean, registerBean, registerBean, registerBean, registerBean, registerBeanDefinition, removeAlias, removeBeanDefinition, setAllowBeanDefinitionOverriding, setAllowCircularReferences, setApplicationStartup, setClassLoader, setParent, setResourceLoader

    Methods inherited from class org.springframework.context.support.AbstractApplicationContext

    addApplicationListener, addBeanFactoryPostProcessor, assertBeanFactoryActive, clearResourceCaches, containsBean, containsBeanDefinition, containsLocalBean, createEnvironment, destroyBeans, doClose, findAllAnnotationsOnBean, findAnnotationOnBean, findAnnotationOnBean, finishBeanFactoryInitialization, finishRefresh, getAliases, getApplicationListeners, getApplicationName, getApplicationStartup, getBean, getBean, getBean, getBean, getBean, getBeanDefinitionCount, getBeanDefinitionNames, getBeanFactoryPostProcessors, getBeanNamesForAnnotation, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanNamesForType, getBeanProvider, getBeanProvider, getBeanProvider, getBeanProvider, getBeanProvider, getBeansOfType, getBeansOfType, getBeansWithAnnotation, getDisplayName, getEnvironment, getId, getInternalParentBeanFactory, getInternalParentMessageSource, getMessage, getMessage, getMessage, getParent, getParentBeanFactory, getResourcePatternResolver, getStartupDate, getType, getType, initApplicationEventMulticaster, initMessageSource, initPropertySources, invokeBeanFactoryPostProcessors, isActive, isClosed, isPrototype, isSingleton, isTypeMatch, isTypeMatch, obtainFreshBeanFactory, onClose, onRefresh, pause, postProcessBeanFactory, prepareBeanFactory, prepareRefresh, publishEvent, publishEvent, publishEvent, refresh, registerListeners, registerShutdownHook, removeApplicationListener, resetCommonCaches, restart, setDisplayName, setEnvironment, setId

    Methods inherited from class org.springframework.core.io.DefaultResourceLoader

    addProtocolResolver, getProtocolResolvers, getResourceByPath, getResourceCache

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.springframework.core.AliasRegistry

    getAliases

    Methods inherited from interface org.springframework.context.ApplicationContextAware

    setApplicationContext

    Methods inherited from interface org.springframework.beans.factory.support.BeanDefinitionRegistry

    containsBeanDefinition, getBeanDefinitionCount, getBeanDefinitionNames

    Methods inherited from interface org.springframework.context.ConfigurableApplicationContext

    addProtocolResolver

    Methods inherited from interface ConfigurableLifecycle

    isConfigured

    Methods inherited from interface ConfigurationAware

    setConfiguration

    Methods inherited from interface FrankElement

    addConfigWarning

    Methods inherited from interface HasApplicationContext

    getConfigurationClassLoader

    Methods inherited from interface ICacheEnabled

    getCache

    Methods inherited from interface org.springframework.context.SmartLifecycle

    isPauseable, stop
  • Field Details

  • Constructor Details

    • PipeLine

      public PipeLine()
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Overrides:
      afterPropertiesSet in class ConfigurableApplicationContext
      Throws:
      Exception
    • registerBeanPostProcessors

      protected void registerBeanPostProcessors(@NonNull org.springframework.beans.factory.config.ConfigurableListableBeanFactory beanFactory)
      Description copied from class: ConfigurableApplicationContext
      Enables the Autowired annotation and ConfigurationAware objects.
      Overrides:
      registerBeanPostProcessors in class ConfigurableApplicationContext
    • getApplicationContext

      public org.springframework.context.ApplicationContext getApplicationContext()
      Specified by:
      getApplicationContext in interface HasApplicationContext
    • getName

      public String getName()
      Used by MetricsInitializer and ConfigurationWarnings. When null either the ClassName or nothing is used. See PipeLineTest#testDuplicateExits, which right now does not add a name to the ConfigurationWarnings. Ideally it copies over the adapter name.
      Specified by:
      getName in interface HasName
    • getPipe

      public IPipe getPipe(String pipeName)
    • getPipe

      public IPipe getPipe(int index)
    • configure

      public void configure() throws ConfigurationException
      Configures the pipes of this Pipeline and does some basic checks. It also registers the PipeLineSession object at the pipes.
      Specified by:
      configure in interface IConfigurable
      Overrides:
      configure in class ConfigurableApplicationContext
      Throws:
      ConfigurationException - in case it was not able to configure the component.
      See Also:
    • configure

      public void configure(IPipe pipe) throws ConfigurationException
      Throws:
      ConfigurationException
    • findExitByState

      public Optional<PipeLineExit> findExitByState(PipeLine.ExitState state)
    • getPipeLineSize

      public int getPipeLineSize()
      Returns:
      the number of pipes in the pipeline
    • getPipeStatistics

      public @NonNull io.micrometer.core.instrument.DistributionSummary getPipeStatistics(IPipe pipe)
    • getPipeWaitStatistics

      public @NonNull io.micrometer.core.instrument.DistributionSummary getPipeWaitStatistics(IPipe pipe)
    • getPipeSizeInStatistics

      public @NonNull io.micrometer.core.instrument.DistributionSummary getPipeSizeInStatistics(IPipe pipe)
    • getPipeSizeOutStatistics

      public @NonNull io.micrometer.core.instrument.DistributionSummary getPipeSizeOutStatistics(IPipe pipe)
    • process

      public PipeLineResult process(@NonNull String messageId, @NonNull Message message, @NonNull PipeLineSession pipeLineSession) throws PipeRunException
      The process method does the processing of a message.
      It retrieves the first pipe to execute from the firstPipe field, the call results in a PipRunResult, containing the next pipe to activate. While processing the process method keeps statistics.
      Parameters:
      messageId - A unique id for this message, used for logging purposes.
      message - The message as received from the Listener
      Returns:
      the result of the processing.
      Throws:
      PipeRunException - when something went wrong in the pipes.
    • resolveForward

      public IForwardTarget resolveForward(IPipe pipe, PipeForward forward) throws PipeRunException
      Find the destination of the forward, i.e. the object (Pipe or PipeLineExit) where the forward points to.
      Throws:
      PipeRunException
    • start

      public void start()
      Description copied from class: ConfigurableApplicationContext
      Configure and start, managed through the Spring Lifecyle
      Specified by:
      start in interface ConfigurableLifecycle
      Specified by:
      start in interface org.springframework.context.Lifecycle
      Overrides:
      start in class ConfigurableApplicationContext
    • isRunning

      public boolean isRunning()
      Specified by:
      isRunning in interface org.springframework.context.Lifecycle
      Overrides:
      isRunning in class ConfigurableApplicationContext
    • getPhase

      public int getPhase()
      Specified by:
      getPhase in interface ConfigurableLifecycle
      Specified by:
      getPhase in interface org.springframework.context.Phased
      Specified by:
      getPhase in interface org.springframework.context.SmartLifecycle
    • startPipe

      protected void startPipe(String type, IPipe pipe)
    • stop

      public void stop()
      Close the pipeline. This will call the stop() method of all registered Pipes
      Specified by:
      stop in interface org.springframework.context.Lifecycle
      Overrides:
      stop in class ConfigurableApplicationContext
      See Also:
    • findGlobalForward

      public @Nullable PipeForward findGlobalForward(String forward)
    • getAllPipeLineExits

      public Map<String, PipeLineExit> getAllPipeLineExits()
    • stopPipe

      protected void stopPipe(String type, IPipe pipe)
    • toString

      public String toString()
      Overrides:
      toString in class org.springframework.context.support.AbstractApplicationContext
      Returns:
      an enumeration of all pipenames in the pipeline and the startpipe and endpath
      See Also:
    • setInputValidator

      public void setInputValidator(IValidator inputValidator)
      Request validator, or combined validator for request and response
    • setOutputValidator

      public void setOutputValidator(IValidator outputValidator)
      Optional pipe to validate the response. Can be specified if the response cannot be validated by the request validator
    • setInputWrapper

      public void setInputWrapper(IWrapperPipe inputWrapper)
      Optional pipe to extract the request message from its envelope
    • setOutputWrapper

      public void setOutputWrapper(IWrapperPipe outputWrapper)
      Optional pipe to wrap the response message in an envelope
    • setPipeLineExits

      public void setPipeLineExits(PipeLineExits exits)
      PipeLine exits. If no exits are specified, a default one is created with name="READY" and state="SUCCESS"
    • addPipeLineExit

      @Deprecated public void addPipeLineExit(PipeLineExit exit)
      Deprecated.
      PipeLine exits.
    • setGlobalForwards

      public void setGlobalForwards(PipeForwards forwards)
      Optional global forwards that will be added to every pipe, when the forward name has not been explicitly set. For example the <forward name="exception" path="error_exception" />, which will add the exception forward to every pipe in the pipeline.
    • addForward

      @Deprecated public void addForward(PipeForward forward)
      Deprecated.
    • setLocker

      public void setLocker(Locker locker)
      Optional Locker, to avoid parallel execution of the PipeLine by multiple threads on multiple servers. The Pipeline is NOT executed (and is considered to have ended successfully) when the lock cannot be obtained, e.g. in case another thread, may be in another server, holds the lock and does not release it in a timely manner. If only the number of threads executing this PipeLine needs to be limited, the attribute maxThreads can be set instead, avoiding the database overhead.
    • setCache

      public void setCache(ICache<String,String> cache)
      Cache of results
      Specified by:
      setCache in interface ICacheEnabled<String,String>
    • addPipe

      @Mandatory public void addPipe(IPipe pipe) throws ConfigurationException
      Register a Pipe at this pipeline. The name is also put in the globalForwards table (with forward-name=pipename and forward-path=pipename, so that pipe can look for a specific pipe-name. If already a globalForward exists under that name, the pipe is NOT added, allowing globalForwards to prevail.
      Throws:
      ConfigurationException
      See Also:
    • setFirstPipe

      public void setFirstPipe(String pipeName)
      Name of the first pipe to execute when a message is to be processed.
      Default value
      first pipe of the pipeline
    • setMaxThreads

      public void setMaxThreads(int newMaxThreads)
      Maximum number of threads that may execute this Pipeline simultaneously, use 0 to disable limit
      Default value
      0
    • setStoreOriginalMessageWithoutNamespaces

      public void setStoreOriginalMessageWithoutNamespaces(boolean b)
      If set true the original message without namespaces (and prefixes) is stored under the session key originalMessageWithoutNamespaces
      Default value
      false
    • setMessageSizeWarn

      public void setMessageSizeWarn(String s)
      If messageSizeWarn>=0 and the size of the input or result pipe message exceeds the value specified a warning message is logged. You can specify the value with the suffixes KB, MB or GB
      Default value
      application default (30MB)
    • getMessageSizeWarnNum

      public long getMessageSizeWarnNum()
    • setTransformNullMessage

      public void setTransformNullMessage(String s)
      when specified and null is received as a message the message is changed to the specified value
    • setAdapterToRunBeforeOnEmptyInput

      @Deprecated @ConfigurationWarning("Please use an XmlIf-pipe and call a sub-adapter to retrieve a new/different response") public void setAdapterToRunBeforeOnEmptyInput(String s)
      Deprecated.
      when specified and an empty message is received the specified adapter is run before passing the message (response from specified adapter) to the pipeline
    • setExpectsSessionKeys

      public void setExpectsSessionKeys(String expectsSessionKeys)
      The pipeline of this adapter expects to use the following session keys to be set on call. This is for adapters that are called as sub-adapters from other adapters. This serves both for documentation, so callers can see what session keys to set on call, and for verification that those session keys are present.
      Parameters:
      expectsSessionKeys - Session keys to set on call of the pipeline, comma-separated.
    • setTransactionTimeout

      public void setTransactionTimeout(int transactionTimeoutSeconds)
      Set transactionTimeout in seconds.
      Specified by:
      setTransactionTimeout in interface HasTransactionAttribute
      Parameters:
      transactionTimeoutSeconds - Time in seconds after which a transaction will fail.