Scripting in ConnectPlaza

Why scripting in ConnectPlaza?

We built scripting in our environment because we wanted to give the developer a simple tool for building all the components needed. Just like User defined services, but much more simple. Scripting in ConnectPlaza is done in Javascript. A very powerful scripting language with a lot of followers in their community. Javascript is easy to learn and very flexible to use. The advantage over Java programming, as user defined services do, is that you do not have to compile the code and to not have to write a bean to add to let it work with the other components. Another advantage is that with the way we implemented the Javascript engine, you have access to all components in our framework. 

Using scripts, you can develop more rapidly. 

Our Javascript engine is based on the Nashorn Javascript API.

Which components can we use

Scripting can be added to several different components. For example:

  • Header enricher
  • Filter
  • Router
  • Nominate
  • Generic consumer / Producer
  • FileNameGenerator
  • Message enricher
  • Aggregator strategies
  • etc......

These components have the option of scripting. Like the Filter Strategy in the filter component or the Router Strategy Bean or Script Reference in the router producer. 

What do I need to know 

First of all you need to know the following:

  • The script will be executed as part of the component
  • The script will have direct access to ConnectMessages and Properties
  • The script will have direct access to the log of the interface
  • The script will be able to access all Java classes the agent uses

As you write a script, you have to think about the return type. This return type is defined per component, i.e.:

  • Generic Message expects a ConnectMessage object or a ConnectMessagePart object
  • A Header enricher returns an object which will become a header value
  • A Filter will return a boolean
  • A Router will return a Mapping key or ChannelName

Adding scripts

Create a new script with the Scripts option at your business connector. The next screen will open: 

Write your script and save it. The script will be added to the scripts list.

Using the scripts

There are a number of components, as described above, where you can use scripts. You can only use scripts available in the selection box. This can also be Java Beans or other resources. The system knows which resources to put into your selection box. 

The possibilities

What can you do with scripting? What are the possibilities? Because you get access to all Java classes within the ConnectAgent and you get access to the message itself, the possibilities are endless. For instance, you can influence the ConnectMessage. You can transform, modify or delete parts. You can influence properties, add or modify dynamic headers based on part content. You can create dynamic filter and router strategies. 

As you can see, you can do a lot of things with scripting, which could, in the past, only be done by using User defined services created by Java developers. Now you can add them yourself with scripting. 

Scripting documentation

You can find the documentation for scripting in the JAVADOC documentation via the URL: