Return-Path: Delivered-To: apmail-activemq-users-archive@www.apache.org Received: (qmail 79985 invoked from network); 15 Feb 2010 18:23:26 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 15 Feb 2010 18:23:26 -0000 Received: (qmail 38914 invoked by uid 500); 15 Feb 2010 17:23:26 -0000 Delivered-To: apmail-activemq-users-archive@activemq.apache.org Received: (qmail 38867 invoked by uid 500); 15 Feb 2010 17:23:26 -0000 Mailing-List: contact users-help@activemq.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@activemq.apache.org Delivered-To: mailing list users@activemq.apache.org Received: (qmail 38848 invoked by uid 99); 15 Feb 2010 17:23:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Feb 2010 17:23:25 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of lists@nabble.com designates 216.139.236.158 as permitted sender) Received: from [216.139.236.158] (HELO kuber.nabble.com) (216.139.236.158) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 15 Feb 2010 17:23:15 +0000 Received: from isper.nabble.com ([192.168.236.156]) by kuber.nabble.com with esmtp (Exim 4.63) (envelope-from ) id 1Nh4er-00062H-MZ for users@activemq.apache.org; Mon, 15 Feb 2010 09:22:53 -0800 Message-ID: <27597050.post@talk.nabble.com> Date: Mon, 15 Feb 2010 09:22:53 -0800 (PST) From: "scot.hale" To: users@activemq.apache.org Subject: Re: How to configure 5.3 broker over KahaDB to support lots of unconsumed persistent msgs? In-Reply-To: <5EBED474-F8C6-42B9-9311-BD5878AC6302@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Nabble-From: scot.hale@gmail.com References: <69b2d60e1001221016i53aeb247lea957449895b2814@mail.gmail.com> <27277999.post@talk.nabble.com> <69b2d60e1001260103lfbe37c5ua6007304a0bc6fd5@mail.gmail.com> <27569119.post@talk.nabble.com> <5EBED474-F8C6-42B9-9311-BD5878AC6302@gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org I am trying to setup a queue with the following requirements: ActiveMQ 5.1 or 5.3 ( I have been testing with 5.3 ) 1. ) VM Transport 2. ) Persistent with KahaPersistenceAdaptor 4. ) JVM Memory usage is capped at something like 64MB - When this limit is reached the producers should continue to store incoming messages to disk (StoreBasedCursor or FileBasedCursor will work, since the former is the default that is the one I have been using.) 5. ) File System usage is capped at something like 10GB - When this limit is reached the producers should start throwing javax.jms.ResourceAllocationExceptions to the Producers Number 5 is the least important, as it will be difficult to fill up disk space in production. My current setup configures ActiveMQ programatically. I don't think this is introducing problems, let me know if there are issues with programatic configuration. Default settings: If I do not configure the SystemUsage or the Flow control, then 64MB default memory usage is reached and the producers are halted even though the queues are persistent and have much more space. Should the default StoreBasedCursor behave this way? Turn off Flow Control: When I turn off Flow Control with default SystemUseage settings, then the JVM memory is not capped. After about 5 million messages with no consumers the JVM assigned 1GB of memory starts returning OutOfMemoryErrors. So what setting do I need to cap the memory and allow the messages to be stored to disk even when the cap is reached? This is how I programtically configure my BrokerService System.setProperty("defaultBinSize", "16384");//Only way to set HashIndex bin size for KahaPersistenceAdapter try { uri = new URI("vm://"+brokerName); } catch (URISyntaxException e) { throw new RuntimeException(e); } brokerService = new BrokerService(); brokerService.setBrokerName(brokerName); brokerService.setUseJmx(true); brokerService.setUseLoggingForShutdownErrors(true); PolicyMap policyMap = new PolicyMap(); List entries = new ArrayList(); PolicyEntry policy = new PolicyEntry(); policy.setProducerFlowControl(true); policy.setQueue(">"); entries.add(policy); policyMap.setPolicyEntries(entries); brokerService.setDestinationPolicy(policyMap); //PERSISTENCE brokerService.setPersistent(true); KahaPersistenceAdapter persistenceAdapter = new KahaPersistenceAdapter(); persistenceAdapter.setDirectory(new File("/tmp/activemq-"+brokerName+"/kaha")); brokerService.setDataDirectoryFile(new File("/tmp/activemq-"+brokerName+"/data")); brokerService.setTmpDataDirectory(new File("/tmp/activemq-"+brokerName+"/temp")); persistenceAdapter.setMaxDataFileLength(500L*1024*1024); try { brokerService.setPersistenceAdapter(persistenceAdapter); } catch (IOException e) { throw new RuntimeException(e); } try { brokerService.getSystemUsage().setSendFailIfNoSpace(true); brokerService.addConnector(uri); brokerService.start(); } catch (Exception e) { throw new RuntimeException(e); } Here is a Producer: public class Producer implements Runnable{ private BrokerService brokerService; private long numberOfMessages; public Producer(BrokerService brokerService, long n){ this.brokerService = brokerService; this.numberOfMessages = n; } public void run(){ ActiveMQConnectionFactory factory = new ActiveMQConnectionFactory(brokerService.getVmConnectorURI()); try { Connection conn = factory.createConnection(); conn.start(); for (int i = 0; i < numberOfMessages; i++) { Session session = conn.createSession(false, Session.AUTO_ACKNOWLEDGE); Destination destination = session.createQueue("test-queue"); MessageProducer producer = session.createProducer(destination); producer.setDeliveryMode(DeliveryMode.PERSISTENT); BytesMessage message = session.createBytesMessage(); message.writeBytes(new byte[]{0,0,0,66,0,0,0,5,0,0,0,0,0,0,0,3,0,0,0,49,51,49,51,51,53,53,48,51,51,54,0,0,0,49,50,51,52,53,0,0,0,0,0,0,0,0,0,0,17,116,114,97,99,101,32,109,101,32,112,108,101,97,115,101,32,50,}); try { producer.send(message); } catch (ResourceAllocationException e) { e.printStackTrace(); } session.close(); } } catch (JMSException e) { throw new RuntimeException(e); } } } rajdavies wrote: > > Hi Scott, > > just change the below config to enable flow control - i.e: > > > > > in 5.3 - producerFlowControl is on by default - so just remove the > producerFlowControl entry from your configuration. > > If this all sounds double dutch - send in your config - and we'll help > with the correct settings :) > > > On 12 Feb 2010, at 20:49, scot.hale wrote: > >> >> Fred, >> >> Were you able to configure ActiveMQ to grow without surpassing the >> memory >> setting? I am trying to figure out how to do the same thing. >> >> -Scot >> >> >> Fred Moore-3 wrote: >>> >>> Hi, >>> >>> going back to Cursors and >>> http://activemq.apache.org/how-do-i-configure-activemq-to-hold-100s-of-millions-of-queue-messages-.html >>> ... >>> >>> ...can anyone shed some light on the actual role of memoryLimit in: >>> >> memoryLimit="1mb"> >>> >> memoryLimit="1mb"> >>> >>> ...moreover: *when* will producerFlowControl start slowing down >>> consumers? >>> >>> Cheers, >>> F. >>> >>> >> >> -- >> View this message in context: >> http://old.nabble.com/How-to-configure-5.3-broker-over-KahaDB-to-support-lots-of-unconsumed--persistent-msgs--tp27277849p27569119.html >> Sent from the ActiveMQ - User mailing list archive at Nabble.com. >> > > Rob Davies > http://twitter.com/rajdavies > I work here: http://fusesource.com > My Blog: http://rajdavies.blogspot.com/ > I'm writing this: http://www.manning.com/snyder/ > > > > > > > -- View this message in context: http://old.nabble.com/How-to-configure-5.3-broker-over-KahaDB-to-support-lots-of-unconsumed--persistent-msgs--tp27277849p27597050.html Sent from the ActiveMQ - User mailing list archive at Nabble.com.