Class JavascriptSender

All Implemented Interfaces:
ICacheEnabled<String,String>, AdapterAware, IConfigurable, IConfigurationAware, INamedObject, IScopeProvider, ISender, ISenderWithParameters, IWithParameters, org.springframework.beans.factory.Aware, org.springframework.context.ApplicationContextAware

@Category("Advanced") public class JavascriptSender extends SenderSeries
Sender used to run JavaScript code using J2V8

This sender can execute a function of a given javascript file, the result of the function will be the output of the sender. The parameters of the javascript function to run are given as parameters by the adapter configuration The sender doesn't accept nor uses the given input, instead for each argument for the jsFunctionName method, you will need to create a parameter on the sender.

The result of the javascript function should be of type String, or directly convertible to String from a primitive type or an array of primitive types / strings, as the output of the sender will be of type String.

Failure to ensure the output is a string may mean the result will look like [Object object].

Since:
7.4
  • Constructor Details

    • JavascriptSender

      public JavascriptSender()
  • Method Details

    • isSenderConfigured

      protected boolean isSenderConfigured()
      Overrides:
      isSenderConfigured in class SenderSeries
    • open

      public void open() throws SenderException
      Description copied from interface: ISender
      This method will be called to start the sender. After this method is called the sendMessage method may be called. Purpose of this method is to reduce creating connections to databases etc. in the sendMessage() method.
      Specified by:
      open in interface ISender
      Overrides:
      open in class SenderSeries
      Throws:
      SenderException
    • sendMessage

      public SenderResult sendMessage(Message message, PipeLineSession session) throws SenderException
      Description copied from interface: ISender
      Send a message to some destination (as configured in the Sender object). This method may only be called after the configure() method is called.

      The following table shows the difference between synchronous and a-synchronous senders:

       synchronousa-synchronous
      ISender.isSynchronous() returnstruefalse
      return value of sendMessage() isthe reply-messagethe messageId of the message sent
      the correlationID specified with sendMessage()may be ignoredis sent with the message
      a {link TimeOutException}may be thrown if a timeout occurs waiting for a replyshould not be expected

      Multiple objects may try to call this method at the same time, from different threads. Implementations of this method should therefore be thread-safe, or synchronized.

      Specified by:
      sendMessage in interface ISender
      Overrides:
      sendMessage in class SenderWrapperBase
      Throws:
      SenderException
    • registerSender

      @Optional public void registerSender(ISender sender)
      Description copied from class: SenderSeries
      one or more specifications of senders that will be executed one after another. Each sender will get the result of the preceding one as input.
      Overrides:
      registerSender in class SenderSeries
    • setJsFileName

      public void setJsFileName(String jsFileName)
      the name of the javascript file containing the functions to run
    • setJsFunctionName

      public void setJsFunctionName(String jsFunctionName)
      the name of the javascript function that will be called (first)
      Default value
      main
    • setEngineName

      public void setEngineName(JavascriptSender.JavaScriptEngines engineName)
      the name of the JavaScript engine to be used.
      Default value
      J2V8
    • getJsFileName

      public String getJsFileName()
    • getJsFunctionName

      public String getJsFunctionName()
    • getEngine