congrats Icon
New! Tabnine Pro 14-day free trial
Start a free trial
Tabnine Logo
Topic.getTopic
Code IndexAdd Tabnine to your IDE (free)

How to use
getTopic
method
in
org.springframework.data.redis.listener.Topic

Best Java code snippets using org.springframework.data.redis.listener.Topic.getTopic (Showing top 20 results out of 315)

origin: spring-projects/spring-data-redis

ByteArrayWrapper holder = new ByteArrayWrapper(serializer.serialize(topic.getTopic()));
    logger.trace("Adding listener '" + listener + "' on channel '" + topic.getTopic() + "'");
    logger.trace("Adding listener '" + listener + "' for pattern '" + topic.getTopic() + "'");
origin: spring-projects/spring-data-redis

ByteArrayWrapper holder = new ByteArrayWrapper(serializer.serialize(topic.getTopic()));
    logger.trace("Removing " + msg + " from channel '" + topic.getTopic() + "'");
    logger.trace("Removing " + msg + " from pattern '" + topic.getTopic() + "'");
origin: sentilo/sentilo

private String buildPattern(final Topic topic) {
 if (topic instanceof ChannelTopic) {
  return topic.getTopic();
 } else {
  // Convert topic pattern in a valid regular expression, i.e., replace the last * character
  // with .*
  return topic.getTopic().replaceAll("\\*", ".*");
 }
}
origin: sentilo/sentilo

public void removeSubscription(final Topic topic) {
 if (subscriptions.containsKey(topic.getTopic())) {
  subscriptions.remove(topic.getTopic());
 }
}
origin: sentilo/sentilo

public void addSubscription(final Topic topic, final NotificationParams params) {
 // If listener is already subscribe to topic, override its notification params
 subscriptions.put(topic.getTopic(), params);
}
origin: sentilo/sentilo

private boolean unsubscribeMonitor() {
 boolean unsubscriptionDone = true;
 try {
  LOGGER.debug("Removing subscription from topic {}", monitorTopic.getTopic());
  listenerContainer.removeMessageListener(monitorListener, monitorTopic);
 } catch (final RedisInvalidSubscriptionException rise) {
  LOGGER.error("An error occurred while unsubscribing from topic {}", monitorTopic.getTopic(), rise);
  unsubscriptionDone = false;
 }
 return unsubscriptionDone;
}
origin: sentilo/sentilo

private boolean subscribeMonitor() {
 boolean subscriptionDone = true;
 try {
  LOGGER.debug("Adding subscription to topic {}", monitorTopic.getTopic());
  listenerContainer.addMessageListener(monitorListener, monitorTopic);
 } catch (final RedisInvalidSubscriptionException rise) {
  LOGGER.error("An error occurred while subscribing to topic {}", monitorTopic.getTopic(), rise);
  subscriptionDone = false;
 }
 return subscriptionDone;
}
origin: sentilo/sentilo

public void publishPing() {
 redisTemplate.convertAndSend(monitorTopic.getTopic(), "PING SUBSCRIPTION");
 lock.lock();
 try {
  countPendingEvents++;
 } finally {
  lock.unlock();
 }
}
origin: sentilo/sentilo

private void removeSubscription(final Subscription subscription) {
 final Topic topic = ChannelUtils.getChannel(subscription);
 LOGGER.debug("Removing subscription to channel {} for listener {} ", topic.getTopic(), subscription.getSourceEntityId());
 final MessageListenerImpl listener = listeners.get(subscription.getSourceEntityId());
 if (listener != null) {
  listenerContainer.removeMessageListener(listener, topic);
  listener.removeSubscription(topic);
 }
 // Finally, the subscription to the topic is removed from Redis
 jedisTemplate.hDel(keysBuilder.getSubscriptionKey(subscription.getSourceEntityId()), topic.getTopic());
 LOGGER.debug("Removed subscription from listener {} to channel {}", subscription.getSourceEntityId(), topic.getTopic());
}
origin: org.springframework.data/spring-data-redis

ByteArrayWrapper holder = new ByteArrayWrapper(serializer.serialize(topic.getTopic()));
    logger.trace("Adding listener '" + listener + "' on channel '" + topic.getTopic() + "'");
    logger.trace("Adding listener '" + listener + "' for pattern '" + topic.getTopic() + "'");
origin: sentilo/sentilo

private void activateSubscription(final String listenerName, final Topic topic, final NotificationParams notificationParams) {
 MessageListenerImpl listener = listeners.get(listenerName);
 if (listener == null) {
  listener = addNewListener(listenerName);
 }
 LOGGER.info("Subscribing listener {} to channel {}", listener.getName(), topic.getTopic());
 listenerContainer.addMessageListener(listener, topic);
 listener.addSubscription(topic, notificationParams);
}
origin: org.springframework.data/spring-data-redis

ByteArrayWrapper holder = new ByteArrayWrapper(serializer.serialize(topic.getTopic()));
    logger.trace("Removing " + msg + " from channel '" + topic.getTopic() + "'");
    logger.trace("Removing " + msg + " from pattern '" + topic.getTopic() + "'");
origin: sentilo/sentilo

private void publish(final AlarmInputMessage message) {
 LOGGER.debug("Publish alarm event message [{}] associated with alert [{}]", message.getMessage(), message.getAlertId());
 final Topic topic = ChannelUtils.buildTopic(PubSubChannelPrefix.alarm, message.getAlertId());
 jedisTemplate.publish(topic.getTopic(), PublishMessageUtils.buildContentToPublish(message, topic));
}
origin: sentilo/sentilo

 private void publish(final OrderInputMessage message) {
  LOGGER.debug("Publish order event [{}] related to provider [{}] and sensor [{}]", message.getOrder(), message.getProviderId(),
    message.getSensorId());
  final Topic topic = ChannelUtils.buildTopic(PubSubChannelPrefix.order, message.getProviderId(), message.getSensorId());
  jedisTemplate.publish(topic.getTopic(), PublishMessageUtils.buildContentToPublish(message, topic));
  LOGGER.debug("Order published");
 }
}
origin: sentilo/sentilo

private void publishSensorData(final Observation data) {
 final Topic topic = ChannelUtils.buildTopic(PubSubChannelPrefix.data, data.getProvider(), data.getSensor());
 jedisTemplate.publish(topic.getTopic(), PublishMessageUtils.buildContentToPublish(data, topic));
}
origin: sentilo/sentilo

@Override
public void subscribe(final Subscription subscription) {
 // The first step is to validate that the resource to which the subscription refers exists in
 // Sentilo. Otherwise an error is thrown
 checkTargetResourceState(subscription);
 // Al subscribirse, no sólo se debe habilitar el listener correspondiente, sino que tb se debe
 // persistir en Redis la subscripcion para la entidad de turno. De esta manera se podrán
 // iniciar los listeners asociados a las subscripciones ya existentes cuando se arranque
 // este modulo.
 // Estos registros en Redis serán del tipo Hash y habrá uno para cada entidad.
 // Es decir, para cada entidad que este subscrita a algun canal tendremos en Redis
 // una Hash con key igual a subs:<entityId> y N entradas <field, value> donde:
 // - field: cada campo de la hash corresponderá a una subscripcion , por lo que el nombre del
 // campo identificará el canal al cual se está subscrito <event_type>/element_id, donde
 // element_id es el identificador del recurso al cual se esta subscrito.
 // - value: el value del campo contiene la informacion necesaria para realizar la notificacion
 // via HTTP Callback (estos datos son el endpoint, la secretKey a utilizar, politica de
 // reintentos, ...)
 final Topic topic = ChannelUtils.getChannel(subscription);
 // Habilitamos listener
 activateSubscription(subscription.getSourceEntityId(), topic, subscription.getNotificationParams());
 // Persistimos en Redis la subscripcion
 jedisTemplate.hSet(keysBuilder.getSubscriptionKey(subscription.getSourceEntityId()), topic.getTopic(),
   converter.marshal(subscription.getNotificationParams()));
 LOGGER.info("Listener {} subscribed to channel {}", subscription.getSourceEntityId(), topic.getTopic());
}
origin: sentilo/sentilo

public static String buildContentToPublish(final OrderInputMessage message, final Topic topic) {
 final Long timestamp = System.currentTimeMillis();
 final EventMessage event = new EventMessage();
 event.setProvider(message.getProviderId());
 event.setSensor(message.getSensorId());
 event.setMessage(message.getOrder());
 event.setTimestamp(DateUtils.timestampToString(timestamp));
 event.setTime(timestamp);
 event.setType(EventType.ORDER.name());
 event.setTopic(topic.getTopic());
 setCustomsFields(event);
 return converter.marshal(event);
}
origin: sentilo/sentilo

private void publishGhostSensorAlarm(final Observation data) {
 final String ghostSensorKey = data.getProvider() + "." + data.getSensor();
 if (ghostSensors.get(ghostSensorKey) == null) {
  final String ghost_message_template = "Detected ghost sensor %s belonging to provider %s";
  final Topic topic = ChannelUtils.buildTopic(PubSubChannelPrefix.alarm, data.getProvider(), data.getSensor());
  final AlarmInputMessage aim = new AlarmInputMessage();
  aim.setProviderId(data.getProvider());
  aim.setSensorId(data.getSensor());
  aim.setAlertType("INTERNAL");
  aim.setAlertId(SentiloConstants.GHOST_SENSOR_ALERT);
  aim.setSender(SentiloConstants.GHOST_SENSOR_SENDER);
  aim.setMessage(String.format(ghost_message_template, data.getSensor(), data.getProvider()));
  jedisTemplate.publish(topic.getTopic(), PublishMessageUtils.buildContentToPublish(aim, topic));
  ghostSensors.put(ghostSensorKey, ghost_message_template);
  LOGGER.info("Published new ghost sensor alarm related to sensor [{}] from provider [{}]", data.getSensor(), data.getProvider());
 }
}
origin: sentilo/sentilo

public static String buildContentToPublish(final AlarmInputMessage message, final Topic topic) {
 final Long timestamp = System.currentTimeMillis();
 final EventMessage event = new EventMessage();
 event.setAlert(message.getAlertId());
 event.setAlertType(message.getAlertType());
 event.setProvider(message.getProviderId());
 event.setSensor(message.getSensorId());
 event.setMessage(message.getMessage());
 event.setTimestamp(DateUtils.timestampToString(timestamp));
 event.setTime(timestamp);
 event.setType(EventType.ALARM.name());
 event.setTopic(topic.getTopic());
 event.setPublisher(message.getSender());
 setCustomsFields(event);
 return converter.marshal(event);
}
origin: sentilo/sentilo

public static String buildContentToPublish(final Observation message, final Topic topic) {
 final EventMessage event = new EventMessage();
 event.setProvider(message.getProvider());
 event.setSensor(message.getSensor());
 event.setMessage(message.getValue());
 event.setTimestamp(DateUtils.timestampToString(message.getTimestamp()));
 event.setTime(message.getTimestamp());
 event.setLocation(message.getLocation());
 event.setType(EventType.DATA.name());
 event.setTopic(topic.getTopic());
 setCustomsFields(event);
 return converter.marshal(event);
}
org.springframework.data.redis.listenerTopicgetTopic

Javadoc

Returns the topic (as a String).

Popular methods of Topic

    Popular in Java

    • Finding current android device location
    • onCreateOptionsMenu (Activity)
    • putExtra (Intent)
    • scheduleAtFixedRate (Timer)
    • BufferedInputStream (java.io)
      A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the i
    • BufferedWriter (java.io)
      Wraps an existing Writer and buffers the output. Expensive interaction with the underlying reader is
    • BigInteger (java.math)
      An immutable arbitrary-precision signed integer.FAST CRYPTOGRAPHY This implementation is efficient f
    • HttpURLConnection (java.net)
      An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
    • Enumeration (java.util)
      A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
    • DataSource (javax.sql)
      An interface for the creation of Connection objects which represent a connection to a database. This
    • Top 17 Plugins for Android Studio
    Tabnine Logo
    • Products

      Search for Java codeSearch for JavaScript code
    • IDE Plugins

      IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
    • Company

      About UsContact UsCareers
    • Resources

      FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
    Get Tabnine for your IDE now