protected void unAdvertiseAll(BrokerState brokerState) throws ClientException { if (!clientConfig.detailState) throw new ClientException("unAdertiseAll() not supported with client.store_detail_state=OFF"); MessageDestination clientDest = MessageDestination.formatClientDestination( clientID, brokerState.getBrokerAddress().getNodeURI()); MessageSender msgSender = brokerState.getMsgSender(); if (msgSender == null) throw new ClientException( "Connection not found for broker " + brokerState.getBrokerAddress()); AdvertisementMessage[] advMsgArray = brokerState.getAdvMessages().toArray(new AdvertisementMessage[0]); for (AdvertisementMessage advMsg : advMsgArray) { Unadvertisement unAdv = new Unadvertisement(advMsg.getMessageID()); UnadvertisementMessage unAdvMsg = new UnadvertisementMessage( unAdv, getNextMessageID(brokerState.getBrokerAddress().getNodeURI()), clientDest); try { msgSender.send(unAdvMsg, HostType.CLIENT); brokerState.removeAdvMsg(advMsg); } catch (CommunicationException e) { throw new ClientException(e.getMessage()); } } }
/** * Returns all the advertisement messages the client has sent in the past. This method is * operational only when the store_detail_state option is switched ON. * * @return * @throws ClientException If the client.store_detail_state option is OFF */ public Map<String, AdvertisementMessage> getAdvertisements() throws ClientException { if (!clientConfig.detailState) throw new ClientException( "getAdvertisements() not supported with client.store_detail_state=OFF"); HashMap<String, AdvertisementMessage> idMsgMap = new HashMap<String, AdvertisementMessage>(); for (BrokerState brokerState : brokerStates.values()) { Set<AdvertisementMessage> advs = brokerState.getAdvMessages(); for (AdvertisementMessage advMsg : advs) idMsgMap.put(advMsg.getMessageID(), advMsg); } return idMsgMap; }