Search in sources :

Example 1 with AssetFilter

use of org.openremote.model.asset.AssetFilter in project openremote by openremote.

the class DefaultMQTTHandler method doSubscribe.

@SuppressWarnings({ "rawtypes", "unchecked" })
@Override
public void doSubscribe(MqttConnection connection, Topic topic, InterceptSubscribeMessage msg) {
    boolean isAssetTopic = isAssetTopic(topic);
    // Use topic as subscription ID
    String subscriptionId = msg.getTopicFilter();
    AssetFilter filter = buildAssetFilter(connection, topic);
    Class subscriptionClass = isAssetTopic ? AssetEvent.class : AttributeEvent.class;
    if (filter == null) {
        LOG.fine("Invalid event filter generated for topic '" + topic + "': " + connection);
        return;
    }
    Consumer<SharedEvent> eventConsumer = getSubscriptionEventConsumer(connection, topic, msg.getRequestedQos());
    EventSubscription subscription = new EventSubscription(subscriptionClass, filter, subscriptionId, eventConsumer);
    Map<String, Object> headers = prepareHeaders(connection);
    messageBrokerService.getProducerTemplate().sendBodyAndHeaders(ClientEventService.CLIENT_EVENT_QUEUE, subscription, headers);
}
Also used : CancelEventSubscription(org.openremote.model.event.shared.CancelEventSubscription) EventSubscription(org.openremote.model.event.shared.EventSubscription) SharedEvent(org.openremote.model.event.shared.SharedEvent) AssetFilter(org.openremote.model.asset.AssetFilter)

Aggregations

AssetFilter (org.openremote.model.asset.AssetFilter)1 CancelEventSubscription (org.openremote.model.event.shared.CancelEventSubscription)1 EventSubscription (org.openremote.model.event.shared.EventSubscription)1 SharedEvent (org.openremote.model.event.shared.SharedEvent)1