<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>CounterLocalService does not work properly.</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121133723" />
  <subtitle>CounterLocalService does not work properly.</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=121133723</id>
  <updated>2026-04-05T17:30:13Z</updated>
  <dc:date>2026-04-05T17:30:13Z</dc:date>
  <entry>
    <title>RE: CounterLocalService does not work properly.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121163481" />
    <author>
      <name>Mohammed Yasin</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121163481</id>
    <updated>2021-09-23T07:41:13Z</updated>
    <published>2021-09-23T07:36:47Z</published>
    <summary type="html">&lt;p&gt;As the counter, by default uses 100 as increment count for DB update
  , once your incremented value crosses 100 it will create new set of
  counter values. This is the reason why your getting 150 instead of 130.&lt;/p&gt;
&lt;p&gt;If you need contineous counter you can set below value in your
  portal-ext.properties file.&lt;/p&gt;
&lt;p&gt;counter.increment.[$COUNTER_NAME$]=1&lt;/p&gt;
&lt;p&gt;In your case,you can use&lt;/p&gt;
&lt;p&gt;counter.increment.test=1&lt;/p&gt;</summary>
    <dc:creator>Mohammed Yasin</dc:creator>
    <dc:date>2021-09-23T07:36:47Z</dc:date>
  </entry>
  <entry>
    <title>RE: RE: CounterLocalService does not work properly.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121158350" />
    <author>
      <name>ali forghani</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121158350</id>
    <updated>2021-09-20T16:15:49Z</updated>
    <published>2021-09-20T16:15:48Z</published>
    <summary type="html">&lt;p&gt;hi&lt;/p&gt;
&lt;p&gt;if i explain it in simple way:&lt;/p&gt;
&lt;p&gt;1- try to deploy module that incloude this component:&lt;/p&gt;
&lt;p&gt;
  &lt;img alt="" src="/documents/14/0/counter-ali-forghani-1.png/0d70b9e0-34f5-b8a5-dfa7-f20a6a779d92?t=1632153751291&amp;amp;imagePreview=1" /&gt;
  &lt;br /&gt; ​​​​​​​so we except this output:&lt;/p&gt;
&lt;p&gt;- hi its a test&lt;/p&gt;
&lt;p&gt;- new value: 1&lt;/p&gt;
&lt;p&gt;- new value: 10&lt;/p&gt;
&lt;p&gt;- new value: 80&lt;/p&gt;
&lt;p&gt;- new value: 130&lt;/p&gt;
&lt;p&gt;-end&lt;/p&gt;
&lt;p&gt;but actually we got this:&lt;/p&gt;
&lt;p&gt;- hi its a test&lt;/p&gt;
&lt;p&gt;- new value: 1&lt;/p&gt;
&lt;p&gt;- new value: 10&lt;/p&gt;
&lt;p&gt;- new value: 80&lt;/p&gt;
&lt;p&gt;- new value: 150&lt;/p&gt;
&lt;p&gt;-end&lt;/p&gt;
&lt;p&gt;may be liferay has some special mathemathic rules. but as i know
  50+80 equals 130. its NOT 150.&lt;/p&gt;
&lt;p&gt;    &lt;/p&gt;</summary>
    <dc:creator>ali forghani</dc:creator>
    <dc:date>2021-09-20T16:15:48Z</dc:date>
  </entry>
  <entry>
    <title>RE: CounterLocalService does not work properly.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121136650" />
    <author>
      <name>Olaf Kock</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121136650</id>
    <updated>2021-09-09T12:37:10Z</updated>
    <published>2021-09-09T12:37:10Z</published>
    <summary type="html">&lt;p&gt;You're linking to a full repository with multiple modules, and
  probably refer to some random class in there.&lt;/p&gt;
&lt;p&gt;Please condense your code so much that you can include it in the
  question, describe the expected vs actual outcome. It's a lot of work
  to figure out what you do/see/expect otherwise, and you probably want
  to make answering as easy as possible...&lt;/p&gt;</summary>
    <dc:creator>Olaf Kock</dc:creator>
    <dc:date>2021-09-09T12:37:10Z</dc:date>
  </entry>
  <entry>
    <title>RE: CounterLocalService does not work properly.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121136370" />
    <author>
      <name>Mohammed Yasin</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121136370</id>
    <updated>2021-09-09T12:05:04Z</updated>
    <published>2021-09-09T12:04:33Z</published>
    <summary type="html">&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;The next step is calculated from the last incremented value saved in
  memory  and not the size which is in DB, so  you  may need reset the
  counter completely  and then set the size as below .&lt;/p&gt;
&lt;pre&gt;
&lt;code class="language-java"&gt;counterLocalService.reset(name);
counterLocalService.reset(name, 80);
counterLocalService.increment(name, 70);
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You are getting 180 instead of 150 is because the counter value saved
  in memory may be 110&lt;/p&gt;</summary>
    <dc:creator>Mohammed Yasin</dc:creator>
    <dc:date>2021-09-09T12:04:33Z</dc:date>
  </entry>
  <entry>
    <title>CounterLocalService does not work properly.</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121133722" />
    <author>
      <name>ali forghani</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=121133722</id>
    <updated>2021-09-16T20:13:20Z</updated>
    <published>2021-09-08T09:26:43Z</published>
    <summary type="html">&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;I'm ali and try to understand how counter is working.&lt;/p&gt;
&lt;p&gt;As i undertood, counter increment a varialble and retrive value. by
  default its increment one by one. but we can change step. problem is
  here. i increase counter number to 80 and at next a call increment
  method with size =70. basically i should get 150 but in practice i get 180.&lt;/p&gt;
&lt;p&gt;i shared my codes on github&lt;/p&gt;
&lt;p&gt;
  &lt;a href="https://github.com/a-forghani-y79/7.3ga8"&gt;https://github.com/a-forghani-y79/7.3ga8&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;liferay version : 7.3ga8&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;</summary>
    <dc:creator>ali forghani</dc:creator>
    <dc:date>2021-09-08T09:26:43Z</dc:date>
  </entry>
</feed>
