Пример #1
0
 private void advertiseHeartbeat() {
   String advStr =
       "[class,eq,"
           + HeartbeatSubscriber.MESSAGE_CLASS
           + "],"
           + "[brokerID,isPresent,'TEXT'],"
           + "[fromID,eq,'"
           + m_BrokerCore.getBrokerID()
           + "'],"
           + "[type,isPresent,'TEXT'],"
           + "[handle,isPresent,'TEXT']";
   Advertisement adv;
   try {
     adv = MessageFactory.createAdvertisementFromString(advStr);
   } catch (ParseException e) {
     exceptionLogger.error(e.getMessage());
     return;
   }
   AdvertisementMessage msg =
       new AdvertisementMessage(
           adv, m_BrokerCore.getNewMessageID(), MessageDestination.HEARTBEAT_MANAGER);
   msg.setTTL(1);
   heartbeatLogger.debug("Sending initial advertisement for heartbeat.");
   m_BrokerCore.routeMessage(msg, MessageDestination.INPUTQUEUE);
 }
Пример #2
0
 /**
  * Send an advertisement to a broker. The advertisemnet is given as a String comforming the PADRES
  * message format. The broker is specified with its URI.
  *
  * @param advStr The advertisement string conforming PADRES message format.
  * @param brokerURI The URI of the broker to send the advertisement to.
  * @return The {@link AdvertisementMessage} produced by the given advertisement string. The
  *     message ID of the message is returned by the broker.
  * @throws ClientException Either their is a syntax error the advertisement string or other error
  *     during advertisement.
  * @throws ParseException
  * @see #advertise(Advertisement, String)
  */
 public AdvertisementMessage advertise(String advStr, String brokerURI)
     throws ClientException, ParseException {
   Advertisement newAdv = MessageFactory.createAdvertisementFromString(advStr);
   if (newAdv.getClassVal() == null) {
     throw new ClientException("Advertisement syntax error");
   }
   return advertise(newAdv, brokerURI);
 }