Ejemplo n.º 1
0
 public PublicationMessage publish(Publication pub, String brokerURI) throws ClientException {
   if (!isConnected()) throw new ClientException("Not connected to any broker");
   try {
     if (brokerURI == null || brokerURI.trim().length() == 0)
       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());
     PublicationMessage pubMsg =
         new PublicationMessage(
             pub, getNextMessageID(brokerState.getBrokerAddress().getNodeURI()), clientDest);
     pubCount++;
     String msgID = brokerState.getMsgSender().send(pubMsg, HostType.CLIENT);
     pubMsg.setMessageID(msgID);
     return pubMsg;
   } catch (CommunicationException e) {
     throw new ClientException(e.getMessage());
   }
 }
Ejemplo n.º 2
0
 public Publication getCurrentPub() {
   if (receivedPubMsg != null) return receivedPubMsg.getPublication();
   return null;
 }