Hi Ami, that article seems a bit obsolete (I just updated it). You should use xbean: to try to load xml file from either classpath or file system. So try something like
BrokerService service = BrokerFactory.createBroker(new URI("xbean:/workspace/apache-activemq-5.3.0/conf/activemq.xml")); Cheers -- Dejan Bosanac - http://twitter.com/dejanb Open Source Integration - http://fusesource.com/ ActiveMQ in Action - http://www.manning.com/snyder/ Blog - http://www.nighttale.net On Wed, Mar 17, 2010 at 10:15 AM, ami.rozen <a...@peer39.com> wrote: > > We are using activemq 5.1 and running a broker embedded in our java > application (a standard one). > Currently we are configuring the broker using java code. > The problems we have are: > 1.We don't seem to be able to make the broker use the temp storage (the > configuration is below) > 2.When using persistent = true storage files seems to always grow and are > never being deleted. > 3. We can't start the embedded broker using an external xml configuration > file. We tried understanding how to do it from > http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html > using the BrokerFactory with a url in the format of > file:foo/bar/activemq.xml but we get the following error: > Caused by: java.io.IOException: Could not find factory class for resource: > META-INF/services/org/apache/activemq/broker/file > at > > org.apache.activemq.util.FactoryFinder.doFindFactoryProperies(FactoryFinder.java:92) > at > org.apache.activemq.util.FactoryFinder.newInstance(FactoryFinder.java:52) > at > org.apache.activemq.util.FactoryFinder.newInstance(FactoryFinder.java:42) > at > > org.apache.activemq.broker.BrokerFactory.createBrokerFactoryHandler(BrokerFactory.java:41) > ... 11 more > > The java configuration of the broker is as follows: > > URI serviceUrl = new URI( brokerUri + "?jms.prefetchPolicy.all=" + > jmsMaxMessages + "&wireFormat.maxInactivityDuration=0" + "?useJmx=true" ); > > broker = new BrokerService(); > broker.setUseJmx( true ); > broker.addConnector( serviceUrl ); > broker.setPersistent( false ); > ManagementContext managementContext = new ManagementContext(); > managementContext.setConnectorPort( 1098 ); > broker.setManagementContext( managementContext ); > > SystemUsage memoryManager = new SystemUsage(); > MemoryUsage memoryUsage = new MemoryUsage(); > memoryUsage.setLimit( 512000000 ); > memoryManager.setMemoryUsage( memoryUsage ); > > TempUsage tempDiskUsage = new TempUsage(); > tempDiskUsage.setLimit( 100000000); > memoryManager.setTempUsage( tempDiskUsage ); > > StoreUsage storeUsage = new StoreUsage(); > storeUsage.setLimit( 999999999 ); > storeUsage.setName( "foo" ); > memoryManager.setStoreUsage( storeUsage ); > > broker.setSystemUsage( memoryManager ); > > broker.setTempDataStore( tempDataStore ); > broker.setTmpDataDirectory( new File( dataDirectory ) ); > > { > PersistenceAdapter adapter = broker.getPersistenceAdapter(); > adapter.setUsageManager( memoryManager ); > if( adapter instanceof AMQPersistenceAdapter ) > { > AMQPersistenceAdapter amqPersistenceAdapter = (AMQPersistenceAdapter) > adapter; > > if( persistent ) > amqPersistenceAdapter.setPersistentIndex( true ); > else > amqPersistenceAdapter.setPersistentIndex( false ); > } > } > broker.start(); > > We have tried to change the configuration in so many ways, none seems to > work ... > > Thank you for your help > Ami > -- > View this message in context: > http://old.nabble.com/Loading-embedded-broker-with-an-xml-configuration-tp27928619p27928619.html > Sent from the ActiveMQ - User mailing list archive at Nabble.com. > >