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);
}
Aggregations