/// <summary> /// Prepare the message for sending: add some information into the /// message headers. Broker proxy will generate endpoint of the Azure /// service host based on these information. /// </summary> /// <param name="message">request message</param> /// <param name="dispatchId">indicating the dispatch id</param> /// <param name="needBinding">add binding data to the message header or not</param> protected override void PrepareMessage(Message message, Guid dispatchId, bool needBinding) { AzureDispatcherInfo azureDispatcherInfo = this.Dispatcher.Info as AzureDispatcherInfo; if (azureDispatcherInfo != null) { message.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderMachineName, Constant.HpcHeaderNS, this.Dispatcher.Info.MachineName)); message.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderCoreId, Constant.HpcHeaderNS, azureDispatcherInfo.FirstCoreId)); message.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderJobId, Constant.HpcHeaderNS, azureDispatcherInfo.JobId)); message.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderRequeueCount, Constant.HpcHeaderNS, azureDispatcherInfo.RequeueCount)); message.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderTaskId, Constant.HpcHeaderNS, azureDispatcherInfo.TaskId)); // Always pass binding info for the HttpsAzureDispatcher. // carry backend binding info over message header message.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderBinding, Constant.HpcHeaderNS, this.backendBindingData)); // also carry serviceOperationTimeout value over message header message.Headers.Add(MessageHeader.CreateHeader(Constant.MessageHeaderServiceOperationTimeout, Constant.HpcHeaderNS, this.BackendServiceOperationTimeout)); } else { EprDispatcherInfo eprDispatcherInfo = this.Dispatcher.Info as EprDispatcherInfo; if (eprDispatcherInfo != null) { // TODO: support Azure service host in in-proc broker } } // following method must be called, otherwise the dispatcher Id is not set // to the message header and the SoaDiagUserTrace can not be recorded. base.PrepareMessage(message, dispatchId, needBinding); }
/// <summary> /// Initializes a new instance of the AzureHttpsDispatcher class. /// </summary> /// <param name="azureQueueManager">AzureQueueManager instance</param> /// <param name="info">indicating the dispatcher info</param> /// <param name="binding">binding information</param> /// <param name="sharedData">indicating the shared data</param> /// <param name="observer">indicating the observer</param> /// <param name="queueFactory">indicating the queue factory</param> /// <param name="schedulerAdapterClientFactory">SchedulerAdapterClientFactory instance</param> /// <param name="dispatcherIdle">set when the dispatcher enters idle status</param> public AzureHttpsDispatcher(AzureQueueManager azureQueueManager, DispatcherInfo info, Binding binding, SharedData sharedData, BrokerObserver observer, BrokerQueueFactory queueFactory, SchedulerAdapterClientFactory schedulerAdapterClientFactory, AutoResetEvent dispatcherIdle) : base(info, ProxyBinding.BrokerProxyBinding, sharedData, observer, queueFactory, schedulerAdapterClientFactory, dispatcherIdle) { AzureDispatcherInfo azureDispatcherInfo = info as AzureDispatcherInfo; this.azureServiceName = azureDispatcherInfo.AzureServiceName; this.azureQueueManager = azureQueueManager; this.azureQueueManager.CreateRequestStorage(this.azureServiceName); this.responseStorageName = this.azureQueueManager.Start(azureDispatcherInfo.JobId, azureDispatcherInfo.RequeueCount); // Update backend binding's maxMessageSize settings with global maxMessageSize if its enabled (> 0) int maxMessageSize = sharedData.ServiceConfig.MaxMessageSize; if (maxMessageSize > 0) { BindingHelper.ApplyMaxMessageSize(binding, maxMessageSize); } this.backendBindingData = new BindingData(binding); }