protected TransportChannel ensureMulticastChannelIsAvailable(URI remoteLocation, TransportChannel channel, BrokerConnector brokerConnector, boolean created) throws JMSException {
if (created) {
BrokerConnectorImpl brokerImpl = (BrokerConnectorImpl) brokerConnector;
BrokerClientImpl client = new BrokerClientImpl();
client.initialize(brokerImpl, channel);
channel.start();
String brokerClientID = createMulticastClientID();
channel.setClientID(brokerClientID);
// lets spoof a consumer for topics which will replicate messages
// over the multicast transport
ConnectionInfo info = new ConnectionInfo();
info.setHostName(IdGenerator.getHostName());
info.setClientId(brokerClientID);
info.setStarted(true);
client.consumeConnectionInfo(info);
ConsumerInfo consumerInfo = new ConsumerInfo();
consumerInfo.setDestination(new ActiveMQTopic(">"));
consumerInfo.setNoLocal(true);
consumerInfo.setClientId(brokerClientID);
consumerInfo.setConsumerId(idGenerator.generateId());
consumerInfo.setStarted(true);
client.consumeConsumerInfo(consumerInfo);
consumerInfo = new ConsumerInfo();
consumerInfo.setDestination(new ActiveMQQueue(">"));
consumerInfo.setNoLocal(true);
consumerInfo.setClientId(brokerClientID);
consumerInfo.setConsumerId(idGenerator.generateId());
consumerInfo.setStarted(true);
client.consumeConsumerInfo(consumerInfo);
}
// now lets create a VM channel that the JMS client will use
// to connect to the embedded brokerConnector
URI localURI = createURI("vm", remoteLocation);