acquire lock

Acquire Lock

Version: 17.07

Supported Since: 17.07

What is an Acquire Lock Processor?

Acquire Lock processing element can be used to acquire a lock in the message flow to gain access to a resource. Depending on the environment, scope of a lock you obtain from this processing element may vary. If you use this processing element in a clustered environment, you will get a cluster lock which makes sure that you are given with a lock through out the cluster. If you use this in a non clustered environment, you will obtain a process level lock which only provides the lock inside your running UltraESB-X process.

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.

acquire lock

Sample Use Case

In the following use case, the requirement is to create a web service which will accept http requests and respond the content of a file stored in server. However this file should be served only once 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 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
acquire lock flow

To implement above use case, first let’s create our integration flow named “integrate-for-acquire-lock". 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 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.

Out Ports

Acquired

Message will be emitted from this port if the lock can be acquired for given lock path

Not Acquired

Message will be emitted from this port if the lock can not be acquired for given lock path

On Exception

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

Parameters

Lock Path *

Basic

Path of the lock that should be acquired

Set a Timeout

Basic

This should be enabled if a waiting timeout is required. If enabled and if lock can not be acquired at the moment message come into the processor, it will wait specified milliseconds to check whether lock can be obtained, otherwise message will be send to Not Acquired Out Port without further waiting.

Timeout (ms)

Basic

Specify number of milliseconds to wait and try if lock can not be acquired

In this topic
In this topic
Contact Us