Class QueryChannelImpl
- java.lang.Object
-
- io.axoniq.axonserver.connector.impl.AbstractAxonServerChannel<QueryProviderOutbound>
-
- io.axoniq.axonserver.connector.query.impl.QueryChannelImpl
-
- All Implemented Interfaces:
QueryChannel
public class QueryChannelImpl extends AbstractAxonServerChannel<QueryProviderOutbound> implements QueryChannel
QueryChannelimplementation, serving as the query connection between AxonServer and a client application.
-
-
Constructor Summary
Constructors Constructor Description QueryChannelImpl(ClientIdentification clientIdentification, String context, int permits, int permitsBatch, ScheduledExecutorService executor, AxonServerManagedChannel channel)Constructs aQueryChannelImpl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect()Connect this channel with AxonServer.voiddisconnect()Disconnect this channel from AxonServer.booleanisReady()Validate whether this channel has all required streams connected with AxonServer.CompletableFuture<Void>prepareDisconnect()Prepares thisQueryChannelto disconnect, by unsubscribing all registered query handlers.ResultStream<QueryResponse>query(QueryRequest query)Sends the givenqueryto AxonServer for routing to the appropriate handlers.voidreconnect()Reconnect this channel with AxonServer.RegistrationregisterQueryHandler(QueryHandler handler, QueryDefinition... queryDefinitions)Registers the givenhandlerto handle incoming queries defined through the givenqueryTypes.SubscriptionQueryResultsubscriptionQuery(QueryRequest query, int bufferSize, int fetchSize)Sends out a subscriptionqueryto AxonServer for routing to the appropriate handler.-
Methods inherited from class io.axoniq.axonserver.connector.impl.AbstractAxonServerChannel
processAck, scheduleImmediateReconnect, scheduleReconnect, sendInstruction
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.axoniq.axonserver.connector.query.QueryChannel
subscriptionQuery
-
-
-
-
Constructor Detail
-
QueryChannelImpl
public QueryChannelImpl(ClientIdentification clientIdentification, String context, int permits, int permitsBatch, ScheduledExecutorService executor, AxonServerManagedChannel channel)
Constructs aQueryChannelImpl.- Parameters:
clientIdentification- client information identifying whom has connected. This information is used to pass on to messagepermits- anintdefining the number of permits this channel haspermitsBatch- anintdefining the number of permits to be consumed from prior to requesting additional permits for this channelexecutor- aScheduledExecutorServiceused to schedule reconnects of this channelchannel- theAxonServerManagedChannelused to form the connection with AxonServer
-
-
Method Detail
-
connect
public void connect()
Description copied from class:AbstractAxonServerChannelConnect this channel with AxonServer.- Specified by:
connectin classAbstractAxonServerChannel<QueryProviderOutbound>
-
registerQueryHandler
public Registration registerQueryHandler(QueryHandler handler, QueryDefinition... queryDefinitions)
Description copied from interface:QueryChannelRegisters the givenhandlerto handle incoming queries defined through the givenqueryTypes. Duplicatehandlers can be registered.- Specified by:
registerQueryHandlerin interfaceQueryChannel- Parameters:
handler- the handler to handle incoming queries withqueryDefinitions- theQueryDefinitions to register the handler for- Returns:
- a registration which allows the query handler to be deregistered
-
query
public ResultStream<QueryResponse> query(QueryRequest query)
Description copied from interface:QueryChannelSends the givenqueryto AxonServer for routing to the appropriate handlers.- Specified by:
queryin interfaceQueryChannel- Parameters:
query- theQueryRequestto send- Returns:
- a
ResultStreamproviding the results of query execution
-
subscriptionQuery
public SubscriptionQueryResult subscriptionQuery(QueryRequest query, int bufferSize, int fetchSize)
Description copied from interface:QueryChannelSends out a subscriptionqueryto AxonServer for routing to the appropriate handler. Allows for receiving an initial query result followed by a stream of updates.- Specified by:
subscriptionQueryin interfaceQueryChannel- Parameters:
query- the subscriptionQueryRequestto sendbufferSize- the number of updates to be buffered by the update result streamfetchSize- the number of updates to be consumed from the update stream prior to refilling it- Returns:
- the
SubscriptionQueryResultcontaining the initial result and update stream
-
disconnect
public void disconnect()
Description copied from class:AbstractAxonServerChannelDisconnect this channel from AxonServer.- Specified by:
disconnectin classAbstractAxonServerChannel<QueryProviderOutbound>
-
reconnect
public void reconnect()
Description copied from class:AbstractAxonServerChannelReconnect this channel with AxonServer.- Specified by:
reconnectin classAbstractAxonServerChannel<QueryProviderOutbound>
-
prepareDisconnect
public CompletableFuture<Void> prepareDisconnect()
Description copied from interface:QueryChannelPrepares thisQueryChannelto disconnect, by unsubscribing all registered query handlers. Will wait with a certain cut off until all acknowledgments of unsubscribing have been received.This method should be used if a connected client wants to disconnect from AxonServer.
- Specified by:
prepareDisconnectin interfaceQueryChannel- Returns:
- a
CompletableFutureofVoidto react when all query handlers have been unsubscribed
-
isReady
public boolean isReady()
Description copied from class:AbstractAxonServerChannelValidate whether this channel has all required streams connected with AxonServer. If the state of the channel does not require any active streams, it is considered ready and will returntrue.- Specified by:
isReadyin classAbstractAxonServerChannel<QueryProviderOutbound>- Returns:
trueif this channel is connected with AxonServer or does not require any active connections,falseotherwise
-
-