* @throws JMSException
*/
public BrokerConnector getEmbeddedBrokerConnector() throws JMSException {
try {
if (brokerConnector == null) {
BrokerContainer container = new BrokerContainerImpl(brokerName, serviceName);
NetworkConnector networkConnector = null;
if (doDiscovery) {
networkConnector = new DiscoveryNetworkConnector(container);
MulticastDiscoveryAgent agent = new MulticastDiscoveryAgent(serviceName);
container.setDiscoveryAgent(agent);
}
if (peerURIs != null && peerURIs.length() > 0) {
URIHelper peers = new URIHelper(peerURIs);
networkConnector = createNetworkConnector(container);
while (peers.hasNext()) {
String peerURL = peers.getNext();
networkConnector.addNetworkChannel(peerURL);
}
}
container.addNetworkConnector(networkConnector);
URIHelper helper = new URIHelper(brokerConnectorURI);
brokerConnector = new BrokerConnectorImpl(container, helper.getNext(), wireFormat);
while (helper.hasNext()) {
new BrokerConnectorImpl(container, helper.getNext(), wireFormat);
}
container.start();
}
return brokerConnector;
}
catch (Exception e) {
e.printStackTrace();