<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Ashutosh Verma</title>
    <description>The latest articles on DEV Community by Ashutosh Verma (@ashutosh_verma_4686d6ab6a).</description>
    <link>https://dev.to/ashutosh_verma_4686d6ab6a</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3593291%2Fa9396419-1b7b-43ca-bbb8-7b23e7faf230.png</url>
      <title>DEV Community: Ashutosh Verma</title>
      <link>https://dev.to/ashutosh_verma_4686d6ab6a</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ashutosh_verma_4686d6ab6a"/>
    <language>en</language>
    <item>
      <title>Are redisson locks jvm locks as well - HELP needed</title>
      <dc:creator>Ashutosh Verma</dc:creator>
      <pubDate>Sun, 02 Nov 2025 16:40:34 +0000</pubDate>
      <link>https://dev.to/ashutosh_verma_4686d6ab6a/are-redisson-locks-jvm-locks-as-well-help-needed-20hl</link>
      <guid>https://dev.to/ashutosh_verma_4686d6ab6a/are-redisson-locks-jvm-locks-as-well-help-needed-20hl</guid>
      <description>&lt;p&gt;I am using &lt;code&gt;RLockReactive&lt;/code&gt; from redisson to get the redis distributed lock, then performing a &lt;code&gt;Supplier&lt;/code&gt; operation.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;Supplier&lt;/code&gt; runs 2 steps in sequence, but I am seeing that while the lock is kept acquired on one key, the 2 steps in my input &lt;code&gt;Supplier&lt;/code&gt; do not run sequentially.&lt;/p&gt;

&lt;p&gt;I really am in doubt, if the redisson locks are ONLY DISTRIBUTED LOCKS, and not as well LOCKS IN A SINGLE JVM???&lt;/p&gt;

&lt;p&gt;Here are my code snippets:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public Mono&amp;lt;Boolean&amp;gt; withLockReturnsBoolean(String lockKey, Supplier&amp;lt;Mono&amp;lt;Boolean&amp;gt;&amp;gt; supplier) {
    return Mono.defer(() -&amp;gt;
            RLockReactive lock = redisson.getLock(lockKey);
            return lock.lock()
                    .doOnSuccess(__ -&amp;gt; log.debug("Reactive lock acquired for: '{}'", lockKey))
                    .then(supplier.get())
                    .doFinally(signal -&amp;gt; lock.isLocked()
                            .flatMap(res -&amp;gt; {
                                if (res) {
                                    return lock.unlock()
                                            .doOnSuccess(__ -&amp;gt; log.debug("Reactive lock released for: '{}'", lockKey))
                                            .doOnError(e -&amp;gt; log.error("Exception occurred while releasing lock for: '{}', error = {}", lockKey, e.getMessage()));
                                }
                                return Mono.empty();
                            })
                    );
            );
}

    // CALLING HERE
    return withLockReturnsBoolean(
        lockKey,
        () -&amp;gt; {
            // 1. read from cache
            return budgetInvoker.validateBudget(promo, order)
                    .flatMap(isValid -&amp;gt; {
                        if (!isValid) return Mono.just(false);

                        // 2. update in cache
                        return budgetInvoker.cacheUpdate(discountDetail, order)
                                .thenReturn(true)
                                .onErrorReturn(false);
                    });
        });
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>backend</category>
      <category>help</category>
      <category>java</category>
    </item>
  </channel>
</rss>
