Apama 10.7.2 | Connecting Apama Applications to External Components | Standard Connectivity Plug-ins | The HTTP Client Transport Connectivity Plug-in | Configuring dynamic connections to services
 
Configuring dynamic connections to services
Many applications have a single or small number of statically configured connections to services. For other applications, the connections can be configured dynamically at runtime. To configure the connections dynamically, define your chain under dynamicChains rather than staticChains with the configuration details using dynamic chain replacement variables (@{varname}):
dynamicChains:
HTTPClientChain:
- apama.eventMap
mapping rules...
- HTTPClientTransport:
host: "@{HOST}"
port: "@{PORT}"
Then you can create instances of that chain configured for specific hosts and ports using the createDynamicChain method on ConnectivityPlugins:
action connectToNewHost(string channelName, string host, integer port,
string defaultChannelTowardsHost)
returns Chain
{
return ConnectivityPlugins.createDynamicChain(
"http-"+host+":"+port.toString(), [channelName],
"http", {"HOST":host,"PORT:"port.toString()}, defaultChannelTowardsHost);
}
Events can be sent to the chain via the supplied channelName. When the connection is no longer needed, it can be destroyed via the returned Chain object.