• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

how to handle memory in active mq queue

 
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 7582
176
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Define "more". You're probably underestimating how many messages a mature product like ActiveMQ can handle.
 
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
shawn peter
Ranch Hand
Posts: 1325
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Saloon Keeper
Posts: 27752
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic