Class PayloadConvertingQueryBusConnector

java.lang.Object
org.axonframework.messaging.queryhandling.distributed.DelegatingQueryBusConnector
org.axonframework.messaging.queryhandling.distributed.PayloadConvertingQueryBusConnector
All Implemented Interfaces:
DescribableComponent, QueryBusConnector

public class PayloadConvertingQueryBusConnector extends DelegatingQueryBusConnector
Connector implementation that converts the payload of outgoing messages into the expected format. This is generally a byte[] or another serialized form.
Since:
5.0.0
Author:
Jan Galinski
  • Constructor Details

    • PayloadConvertingQueryBusConnector

      public PayloadConvertingQueryBusConnector(@Nonnull QueryBusConnector delegate, @Nonnull MessageConverter converter, @Nonnull Class<?> targetType)
      Initialize the PayloadConvertingConnector to use given converter to convert each Message's payload into targetType before passing it to given delegate.
      Parameters:
      delegate - The delegate to pass converted messages to.
      converter - The converter to use to convert each Message's payload.
      targetType - The desired representation of forwarded Message's payload.
  • Method Details

    • query

      @Nonnull public MessageStream<QueryResponseMessage> query(@Nonnull QueryMessage query, @Nullable ProcessingContext context)
      Description copied from interface: QueryBusConnector
      Sends the given query to the remote QueryBus.
      Specified by:
      query in interface QueryBusConnector
      Overrides:
      query in class DelegatingQueryBusConnector
      Parameters:
      query - The query to send to the remote QueryBus.
      context - The context, if available, in which the query is generated
      Returns:
      the stream of responses for the query
      See Also:
    • subscriptionQuery

      @Nonnull public MessageStream<QueryResponseMessage> subscriptionQuery(@Nonnull QueryMessage query, @Nullable ProcessingContext context, int updateBufferSize)
      Description copied from interface: QueryBusConnector
      Sends the given query to the remote QueryBus.
      Specified by:
      subscriptionQuery in interface QueryBusConnector
      Overrides:
      subscriptionQuery in class DelegatingQueryBusConnector
      Parameters:
      query - The query to send to the remote QueryBus.
      context - The context, if available, in which the query is generated
      updateBufferSize - The size of the buffer used to store update for the subscription query.
      Returns:
      the stream of responses for the query
      See Also:
    • onIncomingQuery

      public void onIncomingQuery(@Nonnull QueryBusConnector.Handler handler)
      Description copied from interface: QueryBusConnector
      Registers a handler to process incoming query messages.
      Specified by:
      onIncomingQuery in interface QueryBusConnector
      Overrides:
      onIncomingQuery in class DelegatingQueryBusConnector
      Parameters:
      handler - The handler responsible for managing incoming queries.
    • describeTo

      public void describeTo(@Nonnull ComponentDescriptor descriptor)
      Description copied from interface: DescribableComponent
      Describe the properties of this DescribableComponent with the given descriptor.

      Components should call the appropriate describeProperty methods 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 DescribableComponent implementation 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 the describeTo method, 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:
      describeTo in interface DescribableComponent
      Overrides:
      describeTo in class DelegatingQueryBusConnector
      Parameters:
      descriptor - The component descriptor to describe this DescribableComponentn its properties in.