Class 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
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_EVENTMetaItems,
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
FieldsModifier and TypeFieldDescriptionprotected AgentServiceprotected AttributeLinkingServiceprotected AssetDatapointServiceprotected AssetStorageServicestatic final Stringstatic final Stringprotected ClientEventServiceprotected final List<AttributeEventInterceptor> protected io.micrometer.core.instrument.Timerprotected ExecutorServiceprotected GatewayServiceprotected ManagerIdentityServiceprotected longprotected org.openremote.container.message.MessageBrokerServiceprotected io.micrometer.core.instrument.MeterRegistryprotected org.openremote.container.persistence.PersistenceServicestatic final intprotected RulesServiceprotected org.openremote.container.timer.TimerServiceFields inherited from class org.apache.camel.builder.RouteBuilder
logFields inherited from interface org.openremote.model.ContainerService
DEFAULT_PRIORITY, HIGH_PRIORITY, LOW_PRIORITY, MED_PRIORITYFields inherited from interface org.apache.camel.Ordered
HIGHEST, LOWEST -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddEventInterceptor(AttributeEventInterceptor eventInterceptor) voidprotected io.micrometer.core.instrument.CountergetEventCounter(String source) intvoidinit(org.openremote.model.Container container) protected booleanprocessAttributeEvent(org.openremote.model.attribute.AttributeEvent event) TheAttributeEventis passed to each registeredAttributeEventInterceptorand if no interceptor handles the event then theAttributevalue is updated in the DB with the new event value and timestamp.voidsendAttributeEvent(org.openremote.model.attribute.AttributeEvent attributeEvent) Send internal attribute change events into theATTRIBUTE_EVENT_PROCESSOR.voidsendAttributeEvent(org.openremote.model.attribute.AttributeEvent attributeEvent, String source) Send internal attribute change events into theATTRIBUTE_EVENT_PROCESSOR.voidstart(org.openremote.model.Container container) voidstop(org.openremote.model.Container container) toString()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, validatorMethods 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
-
Field Details
-
ATTRIBUTE_EVENT_ROUTE_CONFIG_ID
- See Also:
-
PRIORITY
public static final int PRIORITY- See Also:
-
ATTRIBUTE_EVENT_PROCESSOR
- See Also:
-
eventInterceptors
-
timerService
protected org.openremote.container.timer.TimerService timerService -
identityService
-
persistenceService
protected org.openremote.container.persistence.PersistenceService persistenceService -
rulesService
-
agentService
-
gatewayService
-
assetStorageService
-
assetDatapointService
-
assetAttributeLinkingService
-
messageBrokerService
protected org.openremote.container.message.MessageBrokerService messageBrokerService -
clientEventService
-
lastProcessedEventTimestamp
protected long lastProcessedEventTimestamp -
executorService
-
meterRegistry
protected io.micrometer.core.instrument.MeterRegistry meterRegistry -
eventTimer
protected io.micrometer.core.instrument.Timer eventTimer -
eventCounters
-
-
Constructor Details
-
AssetProcessingService
public AssetProcessingService()
-
-
Method Details
-
getPriority
public int getPriority()- Specified by:
getPriorityin interfaceorg.openremote.model.ContainerService
-
init
- Specified by:
initin interfaceorg.openremote.model.ContainerService- Throws:
Exception
-
start
- Specified by:
startin interfaceorg.openremote.model.ContainerService- Throws:
Exception
-
stop
- Specified by:
stopin interfaceorg.openremote.model.ContainerService- Throws:
Exception
-
configure
- Specified by:
configurein classorg.apache.camel.builder.RouteBuilder- Throws:
Exception
-
getEventCounter
-
addEventInterceptor
-
sendAttributeEvent
public void sendAttributeEvent(org.openremote.model.attribute.AttributeEvent attributeEvent) Send internal attribute change events into theATTRIBUTE_EVENT_PROCESSOR. -
sendAttributeEvent
public void sendAttributeEvent(org.openremote.model.attribute.AttributeEvent attributeEvent, String source) Send internal attribute change events into theATTRIBUTE_EVENT_PROCESSOR. -
processAttributeEvent
protected boolean processAttributeEvent(org.openremote.model.attribute.AttributeEvent event) throws AssetProcessingException TheAttributeEventis passed to each registeredAttributeEventInterceptorand if no interceptor handles the event then theAttributevalue is updated in the DB with the new event value and timestamp.- Throws:
AssetProcessingException
-
toString
- Overrides:
toStringin classorg.apache.camel.builder.RouteBuilder
-