release lock

Release Lock

Version: 17.07

Supported Since: 17.07

What is an Release Lock Processor?

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.

release lock

Sample Use Case

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.

Prerequisite

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

Implementation
release lock flow

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.

http ingress connector config

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.

acquire lock config

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.

payload setter config

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).

time task config

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.

release lock config

As there is no response path, end the flow with an End processing element

Now run your integration flow and send a request message to the configured request URL to test your integration flow. Once you send a request, you should get the content of the file which is in the configured path as the response for your request for the first request you send and then you will receive the same payload you send as the response. After 10 seconds you will again receive the file content once.

Out Ports

Released

Message will be emitted from this port once the lock has been released

On Exception

The message context will be sent to this outport if any exception occurred while releasing the lock with given name

Parameters

Lock Path *

Basic

Path of the lock that should be released

In this topic
In this topic
Contact Us