This week's giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Production-Ready Serverless (Operational Best Practices) and have Yan Cui on-line!
See this thread for details.
Win a copy of Production-Ready Serverless (Operational Best Practices) this week in the Cloud/Virtualization 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

how to handle memory in active mq queue  RSS feed

 
Ranch Hand
Posts: 1312
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using activemq queue to send messages. I need to know when queue getting more messages it may get memoryout of error?
what are the ways to handle this issue ?
 
Saloon Keeper
Posts: 5327
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Define "more". You're probably underestimating how many messages a mature product like ActiveMQ can handle.
 
Bartender
Posts: 20562
120
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A full-blown OutOfMemoryException (or, as we like to call it, an "OOM") can only be handled by either coding the application to ensure it doesn't run away with memory allocation requests or by expanding the memory allocated at startup to the JVM (the -Xmx parameter on the "java" command). Any attempt to catch and handle an OOM will probably fail because the exception handler itself will probably end up trying to allocate memory to handle the exception. Plus since an OOM can happen at random places, there's not much you can safely do to repair things. So an OOM normally just bounces up and out of the application to the core JVM which gives up and terminates.

I can't speak for MQ, but in the Tomcat server, resources that might run out of buffers are tuneable and usually have a defined upper limit. When the upper limit is exceeded, Tomcat will simply stop accepting new requests until there are free resources available. So there's no OOM, since no attempt is made to allocate more buffers. Unless, of course, the Tomcat JVM's mx setting was too low to allow for the maximum number of buffers.

This is very definitely something that you can expect to be settable in different ways depending on which server product you are using. So I'd check the documentation for your MQ server.
 
sam liya
Ranch Hand
Posts: 1312
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i need to know what happens queue getting millions of messages withing few seconds. Does mq capable of handling these kind of situation ?
 
Tim Holloway
Bartender
Posts: 20562
120
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As I said, if it receives more requests than it can handle, they probably bounce back to the sender. Certainly if you get that many you risk running out of network reply port numbers, and at that point the OS network software itself will refuse to allow any more connections.
 
Sheriff
Posts: 24282
55
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's possible that the MQ server can store unprocessed messages in a database. I've worked with JMS servers which do that -- storing messages in persistent storage also helps to deal with the issue of what happens to unprocessed messages when the server crashes.

So far you're assuming that it can only store unprocessed messages in memory; you might want to find out if that's actually the case.
 
author
Posts: 23820
140
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

sam liya wrote:i need to know what happens queue getting millions of messages withing few seconds. Does mq capable of handling these kind of situation ?



ActiveMQ, as with many other  messaging environments, implements producer side flow control. It means that if your producer sends millions of message per second, then it should work. If it wouldn't work, then your producer will be prevented from sending that fast.

Henry
 
Tim Holloway
Bartender
Posts: 20562
120
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Technical note: When you open a TCP/IP connection to a server, the connection process is a negotiation. The server has the right to refuse the connection attempt as part of that negotiation. It's not simply a case that the client can blast a message to the server and expect the server to accept it automatically. If the server rejects the connection attempt, the client should understand that as a failure to send and handle it in whatever manner it thinks is appropriate.

Full details on how TCP/IP connection process works are outside the scope of this discussion, but you can find plenty of information in just about any book on networking.
 
Police line, do not cross. Well, this tiny ad can go through:
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!