protected async Task ExecuteJob(Schedule state, CancellationToken token) { int currentJob = mCurrentExecutionId++; //mCollector?.Log(LogLevel.Info, "DelayedProcessingJob - Executing schedule " + currentJob); state.Context = currentJob; var payload = new TransmissionPayload("interserv", "do", "something", options: ProcessOptions.RouteExternal); Outgoing.Process(payload); //await Task.Delay(TimeSpan.FromSeconds(40), token); //mCollector?.Log(LogLevel.Info, "DelayedProcessingJob - Finished executing schedule " + currentJob); }
/// <summary> /// This method is used to send requests to a remote command and wait for a response. /// </summary> /// <typeparam name="I">The contract interface.</typeparam> /// <typeparam name="RQ">The request object type.</typeparam> /// <typeparam name="RS">The response object type.</typeparam> /// <param name="rq">The request object.</param> /// <param name="settings">The request settings. Use this to specifically set the timeout parameters, amongst other settings, or to pass meta data to the calling party.</param> /// <param name="routing">The routing options by default this will try internal and then external endpoints.</param> /// <param name="principal">This is the principal that you wish the command to be executed under. /// By default this is taken from the calling thread if not passed.</param> /// <returns>Returns the async response wrapper.</returns> public virtual async Task <ResponseWrapper <RS> > Process <I, RQ, RS>( RQ rq , RequestSettings settings = null , ProcessOptions?routing = default(ProcessOptions?) , IPrincipal principal = null ) where I : IMessageContract { return(await Outgoing.Process <I, RQ, RS>(rq , settings , routing , principal : principal ?? Thread.CurrentPrincipal )); }
/// <summary> /// This method is used to send requests to a remote command and wait for a response. /// </summary> /// <typeparam name="RQ">The request object type.</typeparam> /// <typeparam name="RS">The response object type.</typeparam> /// <param name="channelId"></param> /// <param name="messageType"></param> /// <param name="actionType"></param> /// <param name="rq">The request object.</param> /// <param name="settings">The request settings. Use this to specifically set the timeout parameters, amongst other settings, or to pass meta data to the calling party.</param> /// <param name="routing">The routing options by default this will try internal and then external endpoints.</param> /// <param name="principal">This is the principal that you wish the command to be executed under. /// By default this is taken from the calling thread if not passed.</param> /// <returns>Returns the async response wrapper.</returns> public virtual async Task <ResponseWrapper <RS> > Process <RQ, RS>( string channelId, string messageType, string actionType , RQ rq , RequestSettings settings = null , ProcessOptions?routing = default(ProcessOptions?) , IPrincipal principal = null ) { return(await Outgoing.Process <RQ, RS>( channelId, messageType, actionType , rq , settings , routing , principal : principal ?? Thread.CurrentPrincipal)); }
/// <summary> /// This method is used to send requests to a remote command and wait for a response. /// </summary> /// <typeparam name="RQ">The request object type.</typeparam> /// <typeparam name="RS">The response object type.</typeparam> /// <param name="header">The message header object that defines the remote endpoint.</param> /// <param name="rq">The request object.</param> /// <param name="settings">The request settings. Use this to specifically set the timeout parameters, amongst other settings, or to pass meta data to the calling party.</param> /// <param name="routing">The routing options by default this will try internal and then external endpoints.</param> /// <param name="principal">This is the principal that you wish the command to be executed under. /// By default this is taken from the calling thread if not passed.</param> /// <returns>Returns the async response wrapper.</returns> public virtual async Task <ResponseWrapper <RS> > Process <RQ, RS>( ServiceMessageHeader header , RQ rq , RequestSettings settings = null , ProcessOptions?routing = default(ProcessOptions?) , IPrincipal principal = null ) { return(await Outgoing.Process <RQ, RS>( header , rq , settings , routing , principal : principal ?? Thread.CurrentPrincipal)); }
/// <summary> /// This method transmits the notification message to the other instances. /// The message is specified to be processed externally so to ensure that we can determine whether /// the comms are active. /// </summary> /// <param name="action">The master job action to transmit.</param> protected virtual Task NegotiationTransmit(string action) { var payload = TransmissionPayload.Create(Policy.TransmissionPayloadTraceEnabled); payload.TraceWrite("Create", $"{FriendlyName}/NegotiationTransmit"); payload.Options = ProcessOptions.RouteExternal; var message = payload.Message; //Note: historically there was only one channel, so we use the incoming channel if the outgoing has //not been specified. These should all be lower case so that Service Bus can match accurately. message.ChannelId = (Policy.MasterJobNegotiationChannelIdOutgoing ?? Policy.MasterJobNegotiationChannelIdIncoming).ToLowerInvariant(); message.MessageType = Policy.MasterJobNegotiationChannelMessageType.ToLowerInvariant(); message.ActionType = action.ToLowerInvariant(); message.ChannelPriority = Policy.MasterJobNegotiationChannelPriority; //Go straight to the dispatcher as we don't want to use the tracker for this job //as it is transmit only. Only send messages if the service is in a running state. switch (Status) { case ServiceStatus.Running: Outgoing.Process(payload); FireAndDecorateEventArgs(OnMasterJobCommunication , () => new MasterJobCommunicationEventArgs( MasterJobCommunicationDirection.Outgoing , mMasterJobContext.State , action , mMasterJobContext.StateChangeCounter) , (args, ex) => payload.TraceWrite($"Error: {ex.Message}", $"{FriendlyName}/NegotiationTransmit/OnMasterJobCommunication")); break; } return(Task.FromResult(0)); }