Esempio n. 1
0
 protected void unsubscribeCSAll(BrokerState brokerState) throws ClientException {
   if (!clientConfig.detailState)
     throw new ClientException(
         "unsubscribeCSAll() 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());
   CompositeSubscriptionMessage[] csMsgArray =
       brokerState.getCSMessages().toArray(new CompositeSubscriptionMessage[0]);
   for (CompositeSubscriptionMessage csMsg : csMsgArray) {
     Uncompositesubscription unCS = new Uncompositesubscription(csMsg.getMessageID());
     UncompositesubscriptionMessage unCSMsg =
         new UncompositesubscriptionMessage(
             unCS, getNextMessageID(brokerState.getBrokerAddress().getNodeURI()), clientDest);
     try {
       msgSender.send(unCSMsg, HostType.CLIENT);
       brokerState.removeCSMsg(csMsg);
     } catch (CommunicationException e) {
       throw new ClientException(e.getMessage());
     }
   }
 }
Esempio n. 2
0
 /**
  * Returns all the composite subscription 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, CompositeSubscriptionMessage> getCompositeSubscriptions()
     throws ClientException {
   if (!clientConfig.detailState)
     throw new ClientException(
         "getCompositeSubscriptions() not supported with client.store_detail_state=OFF");
   HashMap<String, CompositeSubscriptionMessage> idMsgMap =
       new HashMap<String, CompositeSubscriptionMessage>();
   for (BrokerState brokerState : brokerStates.values()) {
     Set<CompositeSubscriptionMessage> cSubs = brokerState.getCSMessages();
     for (CompositeSubscriptionMessage csMsg : cSubs) idMsgMap.put(csMsg.getMessageID(), csMsg);
   }
   return idMsgMap;
 }
Esempio n. 3
0
 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());
   }
 }