Class AssetProcessingService

java.lang.Object
org.apache.camel.builder.BuilderSupport
org.apache.camel.builder.RouteBuilder
org.openremote.manager.asset.AssetProcessingService
All Implemented Interfaces:
org.apache.camel.builder.ModelRoutesBuilder, org.apache.camel.CamelContextAware, org.apache.camel.Ordered, org.apache.camel.RoutesBuilder, org.apache.camel.spi.HasCamelContext, org.apache.camel.spi.ResourceAware, org.openremote.model.ContainerService

public class AssetProcessingService extends org.apache.camel.builder.RouteBuilder implements org.openremote.model.ContainerService
Receives AttributeEvent from various sources (clients and services) and processes them. An AttributeEventInterceptor can register to intercept the events using addEventInterceptor(org.openremote.manager.event.AttributeEventInterceptor) at which point they can decide whether or not to allow the event to continue being processed or not.

Any AttributeEvents that fail to be processed will generate an AssetProcessingException which will be logged; there is currently no dead letter queue or retry processing.

Rules Service processing logic

Checks if attribute has MetaItemType.RULE_STATE and/or

invalid reference
MetaItemType#RULE_EVENT
MetaItems, and if so the message is passed through the rule engines that are in scope for the asset.

Asset Storage Service processing logic

Always tries to persist the attribute value in the database and allows the message to continue if the commit was successful.

Asset Datapoint Service processing logic

Checks if attribute has MetaItemType.STORE_DATA_POINTS set to false or if the attribute does not have an AgentLink meta, and if so the AttributeEvent is not stored in a time series DB of historical data, otherwise the value is stored. Then allows the message to continue if the commit was successful.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected AgentService
     
     
     
     
    static final String
     
    static final String
     
     
    protected Map<String,io.micrometer.core.instrument.Counter>
     
     
    protected io.micrometer.core.instrument.Timer
     
    protected ExecutorService
     
    protected GatewayService
     
     
    protected long
     
    protected org.openremote.container.message.MessageBrokerService
     
    protected io.micrometer.core.instrument.MeterRegistry
     
    protected org.openremote.container.persistence.PersistenceService
     
    static final int
     
    protected RulesService
     
    protected org.openremote.container.timer.TimerService
     

    Fields inherited from class org.apache.camel.builder.RouteBuilder

    log

    Fields inherited from interface org.openremote.model.ContainerService

    DEFAULT_PRIORITY, HIGH_PRIORITY, LOW_PRIORITY, MED_PRIORITY

    Fields inherited from interface org.apache.camel.Ordered

    HIGHEST, LOWEST
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
     
    protected io.micrometer.core.instrument.Counter
     
    int
     
    void
    init(org.openremote.model.Container container)
     
    protected boolean
    processAttributeEvent(org.openremote.model.attribute.AttributeEvent event)
    The AttributeEvent is passed to each registered AttributeEventInterceptor and if no interceptor handles the event then the Attribute value is updated in the DB with the new event value and timestamp.
    void
    sendAttributeEvent(org.openremote.model.attribute.AttributeEvent attributeEvent)
    Send internal attribute change events into the ATTRIBUTE_EVENT_PROCESSOR.
    void
    sendAttributeEvent(org.openremote.model.attribute.AttributeEvent attributeEvent, String source)
    Send internal attribute change events into the ATTRIBUTE_EVENT_PROCESSOR.
    void
    start(org.openremote.model.Container container)
     
    void
    stop(org.openremote.model.Container container)
     
     

    Methods inherited from class org.apache.camel.builder.RouteBuilder

    addLifecycleInterceptor, addRoutes, addRoutesToCamelContext, addTemplatedRoutesToCamelContext, bindToRegistry, bindToRegistry, checkInitialized, configuration, configureRest, configureRests, configureRoute, configureRouteConfiguration, configureRoutes, configureRouteTemplate, configureTemplatedRoute, customize, customize, dataFormat, errorHandler, errorHandler, expression, from, from, from, fromF, fromV, fromV, getBeans, getOrder, getResource, getRestCollection, getRestConfiguration, getRests, getRouteCollection, getRoutes, getRouteTemplateCollection, getTemplatedRouteCollection, initializeCamelContext, intercept, interceptFrom, interceptFrom, interceptSendToEndpoint, loadRoutesBuilder, loadRoutesBuilder, onCompletion, onException, onException, populateBeans, populateOrUpdateRoutes, populateRests, populateRoutes, populateRouteTemplates, populateTemplatedRoutes, populateTransformers, populateValidators, prepareModel, property, propertyInject, removeLifecycleInterceptor, rest, rest, restConfiguration, routeTemplate, setErrorHandlerFactory, setResource, setRestCollection, setRouteTemplateCollection, setTemplatedRouteCollection, templatedRoute, tokenizer, transformer, updateRoutesToCamelContext, validator

    Methods inherited from class org.apache.camel.builder.BuilderSupport

    body, bodyAs, constant, constant, constant, createErrorHandlerBuilder, csimple, csimple, datasonnet, datasonnet, datasonnet, deadLetterChannel, deadLetterChannel, defaultErrorHandler, endpoint, endpoint, exceptionMessage, exchangeProperty, expression, getCamelContext, getContext, getErrorHandlerFactory, hasErrorHandlerFactory, header, java, java, joor, joor, jq, jq, jsonpath, jsonpath, jtaTransactionErrorHandler, jtaTransactionErrorHandler, jtaTransactionErrorHandler, method, method, method, method, noErrorHandler, regexReplaceAll, regexReplaceAll, setCamelContext, simple, simple, simpleF, simpleF, springTransactionErrorHandler, springTransactionErrorHandler, springTransactionErrorHandler, systemProperty, systemProperty, variable, xpath, xpath, xpath, xpath

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • ATTRIBUTE_EVENT_ROUTE_CONFIG_ID

      public static final String ATTRIBUTE_EVENT_ROUTE_CONFIG_ID
      See Also:
    • PRIORITY

      public static final int PRIORITY
      See Also:
    • ATTRIBUTE_EVENT_PROCESSOR

      public static final String ATTRIBUTE_EVENT_PROCESSOR
      See Also:
    • eventInterceptors

      protected final List<AttributeEventInterceptor> eventInterceptors
    • timerService

      protected org.openremote.container.timer.TimerService timerService
    • identityService

      protected ManagerIdentityService identityService
    • persistenceService

      protected org.openremote.container.persistence.PersistenceService persistenceService
    • rulesService

      protected RulesService rulesService
    • agentService

      protected AgentService agentService
    • gatewayService

      protected GatewayService gatewayService
    • assetStorageService

      protected AssetStorageService assetStorageService
    • assetDatapointService

      protected AssetDatapointService assetDatapointService
    • assetAttributeLinkingService

      protected AttributeLinkingService assetAttributeLinkingService
    • messageBrokerService

      protected org.openremote.container.message.MessageBrokerService messageBrokerService
    • clientEventService

      protected ClientEventService clientEventService
    • lastProcessedEventTimestamp

      protected long lastProcessedEventTimestamp
    • executorService

      protected ExecutorService executorService
    • meterRegistry

      protected io.micrometer.core.instrument.MeterRegistry meterRegistry
    • eventTimer

      protected io.micrometer.core.instrument.Timer eventTimer
    • eventCounters

      protected Map<String,io.micrometer.core.instrument.Counter> eventCounters
  • Constructor Details

    • AssetProcessingService

      public AssetProcessingService()
  • Method Details

    • getPriority

      public int getPriority()
      Specified by:
      getPriority in interface org.openremote.model.ContainerService
    • init

      public void init(org.openremote.model.Container container) throws Exception
      Specified by:
      init in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • start

      public void start(org.openremote.model.Container container) throws Exception
      Specified by:
      start in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • stop

      public void stop(org.openremote.model.Container container) throws Exception
      Specified by:
      stop in interface org.openremote.model.ContainerService
      Throws:
      Exception
    • configure

      public void configure() throws Exception
      Specified by:
      configure in class org.apache.camel.builder.RouteBuilder
      Throws:
      Exception
    • getEventCounter

      protected io.micrometer.core.instrument.Counter getEventCounter(String source)
    • addEventInterceptor

      public void addEventInterceptor(AttributeEventInterceptor eventInterceptor)
    • sendAttributeEvent

      public void sendAttributeEvent(org.openremote.model.attribute.AttributeEvent attributeEvent)
      Send internal attribute change events into the ATTRIBUTE_EVENT_PROCESSOR.
    • sendAttributeEvent

      public void sendAttributeEvent(org.openremote.model.attribute.AttributeEvent attributeEvent, String source)
      Send internal attribute change events into the ATTRIBUTE_EVENT_PROCESSOR.
    • processAttributeEvent

      protected boolean processAttributeEvent(org.openremote.model.attribute.AttributeEvent event) throws AssetProcessingException
      The AttributeEvent is passed to each registered AttributeEventInterceptor and if no interceptor handles the event then the Attribute value is updated in the DB with the new event value and timestamp.
      Throws:
      AssetProcessingException
    • toString

      public String toString()
      Overrides:
      toString in class org.apache.camel.builder.RouteBuilder