Class SimpleQueryHandlingComponent
- All Implemented Interfaces:
DescribableComponent,MessageHandler,QueryHandler,QueryHandlerRegistry<SimpleQueryHandlingComponent>,QueryHandlingComponent
QueryHandlingComponent interface, allowing for easy registration of
QueryHandlers and other QueryHandlingComponents.
Registered subcomponents are preferred over registered query handlers when handling a query.
- Since:
- 5.0.0
- Author:
- Steven van Beelen
-
Method Summary
Modifier and TypeMethodDescriptionstatic SimpleQueryHandlingComponentInstantiates a simpleQueryHandlingComponentthat is able to handle query and delegate them to subcomponents.voiddescribeTo(ComponentDescriptor descriptor) Describe the properties ofthis DescribableComponentwith the givendescriptor.handle(QueryMessage query, ProcessingContext context) Handles the givenquerywithin the givencontext.subscribe(QualifiedName queryName, QueryHandler handler) subscribe(QueryHandlingComponent handlingComponent) Subscribe the givenhandlingComponentwith this registry.All supportedqueries, referenced through aQualifiedName.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.axonframework.messaging.queryhandling.QueryHandlerRegistry
subscribe
-
Method Details
-
create
Instantiates a simpleQueryHandlingComponentthat is able to handle query and delegate them to subcomponents.- Parameters:
name- The name of the component, used fordescribingthe component.- Returns:
- A simple
QueryHandlingComponentinstance with the givenname.
-
subscribe
public SimpleQueryHandlingComponent subscribe(@Nonnull QualifiedName queryName, @Nonnull QueryHandler handler) Description copied from interface:QueryHandlerRegistrySubscribe the givenqueryHandlerforqueriesandresponseof the givenqueryName.If a subscription already exists for the
queryName, the behavior is undefined. Implementations may throw an exception to refuse duplicate subscription or alternatively decide whether the existing or newhandlergets the subscription.- Specified by:
subscribein interfaceQueryHandlerRegistry<SimpleQueryHandlingComponent>- Parameters:
queryName- The fully qualified name of the queryhandler- The handler instance that handlesqueriesfor the given queryName.- Returns:
- This registry for fluent interfacing.
-
subscribe
Description copied from interface:QueryHandlerRegistrySubscribe the givenhandlingComponentwith this registry.Typically invokes
QueryHandlerRegistry.subscribe(Set, QueryHandler), using theQueryHandlingComponent.supportedQueries()as the set of compatiblehandler namesthe component in question can deal with.- Specified by:
subscribein interfaceQueryHandlerRegistry<SimpleQueryHandlingComponent>- Parameters:
handlingComponent- The query handling component instance to subscribe with this registry.- Returns:
- This registry for fluent interfacing.
-
handle
@Nonnull public MessageStream<QueryResponseMessage> handle(@Nonnull QueryMessage query, @Nonnull ProcessingContext context) Description copied from interface:QueryHandlerHandles the givenquerywithin the givencontext.The resulting
streammay contain zero, one, or Nresponse messages.- Specified by:
handlein interfaceQueryHandler- Parameters:
query- The query to handle.context- The context to the givencommandis handled in.- Returns:
- A
MessagesStreamof zero, one, or Nresponse messages.
-
supportedQueries
Description copied from interface:QueryHandlingComponentAll supportedqueries, referenced through aQualifiedName.- Specified by:
supportedQueriesin interfaceQueryHandlingComponent- Returns:
- All supported
queries, referenced through aQualifiedName.
-
describeTo
Description copied from interface:DescribableComponentDescribe the properties ofthis DescribableComponentwith the givendescriptor.Components should call the appropriate
describePropertymethods on the descriptor to register their properties. The descriptor is responsible for determining how these properties are formatted and structured in the final output.Best Practices: As a general rule, all relevant fields of a
DescribableComponentimplementation should be described in this method. However, developers have discretion to include only the fields that make sense in the context. Not every field may be meaningful for description purposes, especially internal implementation details. Furthermore, components might want to expose different information based on their current state. The final decision on what properties to include lies with the person implementing thedescribeTomethod, who should focus on providing information that is useful for understanding the component's configuration and state.Example implementation:
public void describeTo(ComponentDescriptor descriptor) { descriptor.describeProperty("name", this.name); descriptor.describeProperty("enabled", this.enabled); descriptor.describeProperty("configuration", this.configuration); // A nested component descriptor.describeProperty("handlers", this.eventHandlers); // A collection }- Specified by:
describeToin interfaceDescribableComponent- Parameters:
descriptor- The component descriptor to describethis DescribableComponentn its properties in.
-