Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Delaying ActiveMQ messages

 
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a question based on the information listed here:

https://activemq.apache.org/delay-and-schedule-message-delivery



1) Why time is written in this format 60 * 1000 ?


2) Can't I write it like this?



3) Is there a limit of delay I can introduce?

For example, if I want to introduce 5 mins delay,is it allowed?


 
Saloon Keeper
Posts: 22289
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's for clarity. The time unit is in milliseconds, so 60 * 1000 milliseconds is 60 seconds. Easier to read.

You can certainly set 5 minutes as 300 * 1000L, or as 5 * 60 * 1000L or as 300000L. Whether ActiveMQ allows a delay to be that long depends on what its internal limits are and should be indicated in their documentation.
 
Marshal
Posts: 3156
466
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jack Tauson wrote:Why time is written in this format 60 * 1000 ?


To make it (more) obvious that the time period is milliseconds.


Jack Tauson wrote:Can't I write it like this?


Of course you can, but I would probably code it as 60_000 to make it easier to read.


Jack Tauson wrote:Is there a limit of delay I can introduce?

For example, if I want to introduce 5 mins delay,is it allowed?


Why not?  Try it if you want to be certain.
 
Ron McLeod
Marshal
Posts: 3156
466
Android Eclipse IDE TypeScript Redhat MicroProfile Quarkus Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you haven't done it already, you will need to enable scheduled message support for ActiveMQ.

Tim Bish wrote:Scheduler support is disabled by default in ActiveMQ.

In order to use it you must set the property 'schedulerSupport' to true which means you will need to modify the default broker configuration, no way around that.


Posting at: ActiveMQ forum - Enabling scheduleSupport
 
Jack Tauson
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ron McLeod wrote:If you haven't done it already, you will need to enable scheduled message support for ActiveMQ.

Tim Bish wrote:Scheduler support is disabled by default in ActiveMQ.

In order to use it you must set the property 'schedulerSupport' to true which means you will need to modify the default broker configuration, no way around that.


Posting at: ActiveMQ forum - Enabling scheduleSupport



Good point. I think that's the reason when I attempted to introduce delays and I was playing around with the documentation, it wasn't showing any different behavior. I am going to check if this thing is enabled or not.

However, in the post you shared above, they have mentioned to configure these things in Tomcat, I am wondering why? Quoting the post content below:

I managed to solve the problem, so I write it here to document it:

To configure ActiveMQ broker in TomEE, and turn on schedulerSupport with KahaDB, we should put these lines into tomee.xml:

<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
   BrokerXmlConfig = broker:(tcp://127.0.0.1:61616)?usekahadb=true&persistent=true&schedulerSupport=true
</Resource>

<Resource id="MyJmsConnectionFactory" type="javax.jms.ConnectionFactory">
   ResourceAdapter = MyJmsResourceAdapter
</Resource>

One more thing is necessary to make this work:
ActiveMQ puts some folders for KahaDB into tomee's bin folder, so this folder must be writeable for tomee process at least for the first run. After necessary subfolders are created, bin folder can be changed back to not writeable.





I am wondering where to put the configuration. If inside conf/activemq.xml, then where?


Also, is this question appropriate for Tomcat forum?

Thanks !
 
Tim Holloway
Saloon Keeper
Posts: 22289
151
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jack Tauson wrote:
Also, is this question appropriate for Tomcat forum?



No, but in its original form it wasn't even especially specific to ActiveMQ. :shrug:
 
Jack Tauson
Ranch Hand
Posts: 221
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Jack Tauson wrote:

Ron McLeod wrote:If you haven't done it already, you will need to enable scheduled message support for ActiveMQ.

Tim Bish wrote:Scheduler support is disabled by default in ActiveMQ.

In order to use it you must set the property 'schedulerSupport' to true which means you will need to modify the default broker configuration, no way around that.


Posting at: ActiveMQ forum - Enabling scheduleSupport



Good point. I think that's the reason when I attempted to introduce delays and I was playing around with the documentation, it wasn't showing any different behavior. I am going to check if this thing is enabled or not.

However, in the post you shared above, they have mentioned to configure these things in Tomcat, I am wondering why? Quoting the post content below:

I managed to solve the problem, so I write it here to document it:

To configure ActiveMQ broker in TomEE, and turn on schedulerSupport with KahaDB, we should put these lines into tomee.xml:

<Resource id="MyJmsResourceAdapter" type="ActiveMQResourceAdapter">
   BrokerXmlConfig = broker:(tcp://127.0.0.1:61616)?usekahadb=true&persistent=true&schedulerSupport=true
</Resource>

<Resource id="MyJmsConnectionFactory" type="javax.jms.ConnectionFactory">
   ResourceAdapter = MyJmsResourceAdapter
</Resource>

One more thing is necessary to make this work:
ActiveMQ puts some folders for KahaDB into tomee's bin folder, so this folder must be writeable for tomee process at least for the first run. After necessary subfolders are created, bin folder can be changed back to not writeable.





I am wondering where to put the configuration. If inside conf/activemq.xml, then where?


Also, is this question appropriate for Tomcat forum?

Thanks !




I updated the following like in activemq.xml to include scheduler like this:

<broker xmlns="http://activemq.apache.org/schema/core"; brokerName="localhost" dataDirectory="${activemq.data} " schedulerSupport="true">

However, now my activemq is stuck at the following line and the UI access is not available anymore:

INFO | Database C:\jack\my_softwares\apache-activemq-5.15.11\bin\..\data \localhost\scheduler\lock is locked by another server. This broker is now in slave mode waiting a lock to be acquired



And it works fine when I put it back to in original form:

<broker xmlns="http://activemq.apache.org/schema/core"; brokerName="localhost" dataDirectory="${activemq.data} ">





 
Bring me the box labeled "thinking cap" ... and then read this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic