Supported Since: 17.07
Release Lock processing element can be used to release a lock that is acquired by Acquire Lock processing element. Others can re-acquire an already acquired lock if the lock is released by this processing element
In order to use this processing element, you must first select the Cluster Management dependency from the processor list when you are creating an empty Ultra project. If you have already created a project, you can add this dependency via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Processors list, select the Cluster Management dependency.
In the following use case, the requirement is to create a web services and time task. Web service will accept http requests and respond the content of a file stored in server. However this file should be served only once within 10 seconds although multiple requests come into this service.
In order to implement above use case you must first select following dependencies when you are creating an empty Ultra project
HTTP NIO Connector and Timer Task Connector from the connector list.
Clustering Manager Processors and Payload Manipulation Processors dependency from the processor list.
If you have already created a project, you can add above dependencies via Component Registry. From Tools menu, select Ultra Studio → Component Registry and from the Connectors list and Processors list, select above dependencies
To implement above use case, first let’s create our integration flow named “integrate-for-acquire-lock-data". Then add an NIO HTTP Ingress Connector and configure the request receiving service path and port.
Then Acquire Lock processing element should be added to acquire lock to access the file from server. From the property pane, a lock path for the lock that is entered.
If the Acquire Lock processing element can acquire the lock from given lock path, Payload Setter processing element is triggered. File Payload Setter processing element is configured to read the content from the file and set the content as the payload of the message.
Then updated payload will be sent as the response of the HIO HTTP Ingress Connector. If the Acquire Lock processing element can not acquire the lock from given lock path, then request payload will be sent back as the response with no modification
Now we want a mechanism to reset the lock once a 10 seconds in order to serve the file content in next 10 seonds. To do that add a Timer Task Listener and configure its Polling Repeat Interval to 10 seconds (10000 ms).
Add a Release Lock processing element as the next element of Timer Task Listener and configure the lock path same as the Acquire Lock processing element.