Class TransportListenerExtensions
- Namespace
- JobFlow.Core.Configuration
- Assembly
- JobFlow.Core.dll
Extension methods to ease the creation of background transport listeners.
public static class TransportListenerExtensions
- Inheritance
-
TransportListenerExtensions
Remarks
These transport listeners would be used in hosted applications, for instance. When using Functions (or similar cloud infrastructure) for workers, these are unnecessary. The listeners are created as IHostedService implementations, running as background threads in the host.
Listeners pass message processing to a class implementing either IMessageHandler<T> or IWorker<T>, depending on the overload used. These processing classes are retrieved from the IServiceCollection.
IMessageHandler<T> is intended to "fire and forget" style processing. It is up the implementor to send any response messages, if needed. Most of the time, classes implementing this interface are internal system processors (such as the implementation that processes incoming WorkResponse messages).
Instead, a user should look towards implementing IWorker<T>. This adds an additional layer that will automatically send a response message based on the return value from ProcessJob(WorkRequest<T>).
Transport configuration comes from the same configuration as the rest of the transport implementations, namely MessagingOptions.
Methods
AddScheduleListener(BaseJobFlowConfigurationBuilder, string)
Adds a listener for the Schedule queue.
public static BaseJobFlowConfigurationBuilder AddScheduleListener(this BaseJobFlowConfigurationBuilder config, string transportName = "JobSchedule")
Parameters
config
BaseJobFlowConfigurationBuildertransportName
stringThe name of the transport configuration (defaults to JobSchedule)
Returns
Remarks
This is required in order to schedule messages.
AddTransportListener<TMsg, TProc>(BaseJobFlowConfigurationBuilder, string)
Add a transport listener to the JobFlowConfigurationBuilder.
public static BaseJobFlowConfigurationBuilder AddTransportListener<TMsg, TProc>(this BaseJobFlowConfigurationBuilder config, string transportName) where TProc : IMessageHandler<TMsg>
Parameters
config
BaseJobFlowConfigurationBuildertransportName
string
Returns
Type Parameters
TMsg
Type of message to listen for.
TProc
Type of message processor - a class that implements IMessageHandler<T>.
AddTransportListener<TMsg, TProc>(IServiceCollection, string)
Add a transport listener to the IServiceCollection.
public static IServiceCollection AddTransportListener<TMsg, TProc>(this IServiceCollection services, string transportName) where TProc : IMessageHandler<TMsg>
Parameters
services
IServiceCollectiontransportName
string
Returns
Type Parameters
TMsg
Type of message to listen for.
TProc
Type of message processor - a class that implements IMessageHandler<T>.
AddWorkRequestListener<TProc>(BaseJobFlowConfigurationBuilder, string)
Add a IWorker transport listener to the JobFlowConfigurationBuilder.
public static BaseJobFlowConfigurationBuilder AddWorkRequestListener<TProc>(this BaseJobFlowConfigurationBuilder config, string transportName) where TProc : IWorker
Parameters
config
BaseJobFlowConfigurationBuildertransportName
string
Returns
Type Parameters
TProc
Type of message processor - a class that implements IWorker
AddWorkRequestListener<TProc>(IServiceCollection, string)
Add a IWorker transport listener to the IServiceCollection.
public static IServiceCollection AddWorkRequestListener<TProc>(this IServiceCollection services, string transportName) where TProc : IWorker
Parameters
services
IServiceCollectiontransportName
string
Returns
Type Parameters
TProc
Type of message processor - a class that implements IWorker
Remarks
This overload of the method adds a work processor that implements the non-generic IWorker interface.
AddWorkRequestListener<TMsg, TProc>(BaseJobFlowConfigurationBuilder, string)
Add a IWorker<T> transport listener to the JobFlowConfigurationBuilder.
public static BaseJobFlowConfigurationBuilder AddWorkRequestListener<TMsg, TProc>(this BaseJobFlowConfigurationBuilder config, string transportName) where TProc : IWorker<TMsg>
Parameters
config
BaseJobFlowConfigurationBuildertransportName
string
Returns
Type Parameters
TMsg
Type of message to listen for.
TProc
Type of message processor - a class that implements IWorker<T>
AddWorkRequestListener<TMsg, TProc>(IServiceCollection, string)
Add a IWorker<T> transport listener to the IServiceCollection.
public static IServiceCollection AddWorkRequestListener<TMsg, TProc>(this IServiceCollection services, string transportName) where TProc : IWorker<TMsg>
Parameters
services
IServiceCollectiontransportName
string
Returns
Type Parameters
TMsg
Type of message to listen for.
TProc
Type of message processor - a class that implements IWorker<T>
AddWorkResponseListener(BaseJobFlowConfigurationBuilder, string)
Adds a WorkResponse message listener to the JobFlowConfigurationBuilder.
public static BaseJobFlowConfigurationBuilder AddWorkResponseListener(this BaseJobFlowConfigurationBuilder config, string transportName = "JobResult")
Parameters
config
BaseJobFlowConfigurationBuildertransportName
string
Returns
Remarks
Essentially the same as calling AddTransportListener<WorkResponse, IMessageHandler<WorkResponse>>(transportName)
.
AddWorkResponseListener(IServiceCollection, string)
Adds a WorkResponse message listener to the IServiceCollection.
public static IServiceCollection AddWorkResponseListener(this IServiceCollection services, string transportName = "JobResult")
Parameters
services
IServiceCollectiontransportName
string
Returns
Remarks
Essentially the same as calling AddTransportListener<WorkResponse, IMessageHandler<WorkResponse>>(transportName)
.