public CompositeSubscriptionMessage subscribeCS(CompositeSubscription cs, String brokerURI) throws ClientException { if (!isConnected()) throw new ClientException("Not connected to any broker"); try { if (brokerURI == null || brokerURI.trim().equals("")) brokerURI = defaultBrokerAddress.getNodeURI(); BrokerState brokerState = getBrokerState(brokerURI); if (brokerState == null) { throw new ClientException("Not connected to broker " + brokerURI); } MessageDestination clientDest = MessageDestination.formatClientDestination( clientID, brokerState.getBrokerAddress().getNodeURI()); CompositeSubscriptionMessage newCSMsg = new CompositeSubscriptionMessage( cs, getNextMessageID(brokerState.getBrokerAddress().getNodeURI()), clientDest); String msgID = brokerState.getMsgSender().send(newCSMsg, HostType.CLIENT); newCSMsg.setMessageID(msgID); if (clientConfig.detailState) brokerState.addCSSubMsg(newCSMsg); return newCSMsg; } catch (CommunicationException e) { throw new ClientException(e.getMessage()); } }