On 3/8/07, Javier Leyba <[EMAIL PROTECTED]> wrote:
On 3/7/07, James Strachan <[EMAIL PROTECTED]> wrote:
>
> The Spring jars are not mandatory, you can use ActiveMQ just fine
> without it. Currently main use of Spring is along with xbean to deal
> with the XML configuration. If you prefer you could just use Java code
> to initialise your broker...
> http://activemq.apache.org/how-do-i-embed-a-broker-inside-a-connection.html
>


Hi

After some problems I decided to erase Spring from my service and
configure ActiveMQ in my java code but I found that docs show the
obvious and help nothing with the rest.

In my xml I have:

----------------
<broker xmlns="http://activemq.org/config/1.0";
brokerName="MASTERUBUNTU" persistent="true" useJmx="true">

        <!-- Use the following to configure how ActiveMQ is exposed in JMX -->
        <managementContext>
           <managementContext connectorPort="2011"
jmxDomainName="org.apache.activemq"/>
        </managementContext>


    <persistenceAdapter>
          <journaledJDBC journalLogFiles="5" dataDirectory="activemq-data"/>
    </persistenceAdapter>

    <transportConnectors>
       <transportConnector  uri="tcp://172.31.112.9:62002" />
    </transportConnectors>

    <networkConnectors>
        <networkConnector
uri="static://(tcp://172.31.112.9:62003,tcp://172.31.27.1:62012,tcp://172.30.27.1:62014)"
failover="true" dynamicOnly="true" />
    </networkConnectors>

  </broker>
---------------

Then I did a properties file as follows:

---------------
brokerName=MASTERUBUNTU
transportConnector=tcp://172.31.112.9:62002
networkConnector=static://(tcp://172.31.112.9:62003,tcp://172.31.27.1:62012,tcp://172.30.27.1:62014)


BTW it would be pretty useful to have a pure properties files based
way to configure the broker! Fancy starting it off and we can improve
it?


that I load when my service init and try to configure my broker as follows:


service = new BrokerService();
                service.setBrokerName(masterBrokerProps.
                                getProperty("brokerName"));
                service.setPersistent(true);
                service.addConnector(masterBrokerProps.
                                getProperty("transportConnector"));

Now, first problem:

                service.addNetworkConnector(masterBrokerProps.
                                getProperty("networkConnector"));

Is this ok or should I define many adds for each network connection ?

One add for each <networkConnector> element (or URI). Ditto for each
transport connector.But in your XML you only have one of each


How could I define failover and dynamicOnly ?

The same as in XML, just pass the entire URI into the
add*Connector(String) method.


Next problem, I want to define the persistence adapter:

After reading docs I know that can make it with something like this

                PersistenceAdapter pa = new JournalPersistenceAdapter();
                service.setPersistenceAdapter(pa);


Why not just reuse the defaults?



Also, how should I set my xml management context settings ?

Again the defaults are fine - only configure stuff if you really need
to change something.


I guess there are few explanations in docs for the quantity of
settings needed in a real broker definition.

Javadoc is your friend (though we could use some help filling out some
more detail in them :)
http://activemq.apache.org/maven/activemq-core/apidocs/org/apache/activemq/broker/BrokerService.html

--

James
-------
http://radio.weblogs.com/0112098/

Reply via email to