activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian Reinhold <>
Subject How to configure embedded SSL broker using just Java code
Date Fri, 22 Nov 2013 17:11:55 GMT
This question was asked a while ago and the answers involved links and APIs
that no longer exist. I am unable to find any documentation to figure out
what classes correspond to what xml options, and if one is able to guess at
the classes, how to link them to the broker.

In the binary distributions an embedded example is given. It uses the Broker
class and not the BrokerService (as shown in the ActiveMQ FAQ). However, in
the context of an Apollo distribution, using the BrokerService as shown in
the ActiveMQ FAQ fails due to missing administrative classes.

In the example of the distribution, the Broker.setConfig(BrokerDTO) method
is used. 

The main method creates the embedded broker as follows:

        System.out.println("Starting the Broker.");
        broker = new Broker();
        broker.start(new Runnable()
                        public void run()
                            System.out.println("The broker has now

calling the createBrokerConfig method which creates the BrokerDTO object:

    private static BrokerDTO createBrokerConfig()
        BrokerDTO broker = new BrokerDTO();

        // Brokers support multiple virtual hosts.
        VirtualHostDTO host = new VirtualHostDTO(); = "localhost";

        // The message store is configured on the virtual host.
        LevelDBStoreDTO store = new LevelDBStoreDTO(); = new File("./data"); = store;


        // Control which ports and protocols the broker binds and accepts
        AcceptingConnectorDTO connector = new AcceptingConnectorDTO(); = "tcp";
        connector.bind = mqttServerUrl;


        // Fires up the web admin console on HTTP.
        WebAdminDTO webadmin = new WebAdminDTO();
        webadmin.bind = "";

        return broker;

This simple code does create an unsecure broker.

I cannot for the life of me figure out how to place SSL configuration
information into the broker. I see this class:

        // From
        SslDTO sslDto = new SslDTO();
        sslDto.client_auth = "NEED";
        sslDto.version = "TLSv1";

but I have no idea how to link it to the BrokerDTO object. What I then
really need to do is to link the javax SslContextFactory to the
configuration info. But I have no idea how to do that.

I see some older posts that used the BrokerService class which used to have
an SslBrokerContext that could use the SslContextFactory but that class no
longer exists.

Though there is oodles of xml configuration information, there is almost no
documentation of information on using code to control/configure the embedded
option. Would really appreciate some help here!



View this message in context:
Sent from the ActiveMQ - User mailing list archive at

View raw message