public SbmpMessageBrowser(string path, Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessagingFactory messagingFactory, SbmpMessageCreator messageCreator, Lazy <SbmpMessageCreator> controlMessageCreator, Microsoft.ServiceBus.RetryPolicy retryPolicy, bool embedParentLinkId) : base(messagingFactory, retryPolicy) { this.SbmpMessagingFactory = messagingFactory; this.path = path; this.MessageCreator = messageCreator; this.ControlMessageCreator = controlMessageCreator; base.InstanceTrackingContext = TrackingContext.GetInstance(Guid.NewGuid(), this.path); }
public PumpAsyncResult(MessageReceivePump owner, BrokeredMessage firstMessage, AsyncCallback callback, object state) : base(TimeSpan.MaxValue, callback, state) { this.owner = owner; this.firstMessage = firstMessage; this.trackingContext = TrackingContext.GetInstance(Guid.NewGuid(), owner.receiver.Path); MessageReceivePump.PumpAsyncResult pumpAsyncResult = this; pumpAsyncResult.OnCompleting = (Action <AsyncResult, Exception>)Delegate.Combine(pumpAsyncResult.OnCompleting, MessageReceivePump.PumpAsyncResult.CompletingAction); }
public EventDataPumpAsyncResult(EventProcessorLifecycleManager lifeCycleManager, EventHubReceiver receiver, PartitionContext context, AsyncCallback callback, object state) : base(TimeSpan.MaxValue, callback, state) { this.context = context; this.lifeCycleManager = lifeCycleManager; this.receiver = receiver; this.trackingContext = TrackingContext.GetInstance(Guid.NewGuid(), this.receiver.Name); base.Start(); }
private Stream GetState(TrackingContext trackingContext) { if (trackingContext == null) { trackingContext = TrackingContext.GetInstance(Guid.NewGuid(), this.Path); } MessageSession.TraceGetState(EventTraceActivity.CreateFromThread(), trackingContext, this.SessionId); return(this.OnGetState(trackingContext, this.OperationTimeout)); }
private void SetState(TrackingContext trackingContext, Stream stream) { if (trackingContext == null) { trackingContext = TrackingContext.GetInstance(Guid.NewGuid(), this.Path); } MessageSession.TraceSetState(EventTraceActivity.CreateFromThread(), trackingContext, this.SessionId); this.OnSetState(trackingContext, stream, this.OperationTimeout); }
private void Initialize(MessagingExceptionDetail detail, TrackingContext currentTracker, DateTime timestamp) { this.IsTransient = true; this.Detail = detail; this.Tracker = currentTracker ?? TrackingContext.GetInstance(Guid.NewGuid()); this.Timestamp = timestamp; if (base.GetType() != typeof(MessagingException)) { this.DisablePrepareForRethrow(); } }
public GetRuntimeEntityDescriptionAsyncResult(TrackingContext trackingContext, MessageClientEntity clientEntity, string entityAddress, SbmpMessagingFactory factory, SbmpMessageCreator messageCreator, bool executeOnce, TimeSpan timeout, AsyncCallback callback, object state) : base(timeout, callback, state) { this.clientEntity = clientEntity; this.entityAddress = entityAddress; this.factory = factory; this.messageCreator = messageCreator; this.trackingContext = trackingContext ?? TrackingContext.GetInstance(Guid.NewGuid()); this.executeOnce = executeOnce; GetRuntimeEntityDescriptionAsyncResult getRuntimeEntityDescriptionAsyncResult = this; getRuntimeEntityDescriptionAsyncResult.OnCompleting = (Action <AsyncResult, Exception>)Delegate.Combine(getRuntimeEntityDescriptionAsyncResult.OnCompleting, GetRuntimeEntityDescriptionAsyncResult.onFinally); }
public EventProcessorInitializeAsyncResult(EventProcessorLifecycleManager lifeCycleManager, Lease lease, AsyncCallback callback, object state) : base(TimeSpan.MaxValue, callback, state) { this.lifeCycleManager = lifeCycleManager; this.lease = lease; this.trackingContext = TrackingContext.GetInstance(Guid.NewGuid(), lease.PartitionId); this.partitionId = lease.PartitionId; this.startingOffset = lease.Offset; this.epoch = lease.Epoch; EventProcessorLifecycleManager.EventProcessorInitializeAsyncResult eventProcessorInitializeAsyncResult = this; eventProcessorInitializeAsyncResult.OnCompleting = (Action <AsyncResult, Exception>)Delegate.Combine(eventProcessorInitializeAsyncResult.OnCompleting, EventProcessorLifecycleManager.EventProcessorInitializeAsyncResult.OnFinallyDelegate); base.Start(); }
protected override void OnEndOpen(IAsyncResult result) { if (!base.BatchingEnabled) { CompletedAsyncResult.End(result); } else { this.BatchManager.EndOpen(result); } this.SbmpMessagingFactory.ScheduleGetRuntimeEntityDescription(TrackingContext.GetInstance(Guid.NewGuid()), this, this.Path, this.MessageCreator); }
internal IEnumerable <BrokeredMessage> PeekBatch(TrackingContext trackingContext, long fromSequenceNumber, int messageCount, TimeSpan timeout) { base.ThrowIfDisposed(); TimeoutHelper.ThrowIfNegativeArgument(timeout); if (trackingContext == null) { trackingContext = TrackingContext.GetInstance(Guid.NewGuid(), this.Path); } MessageBrowser.TracePeek(EventTraceActivity.CreateFromThread(), trackingContext); if (this.openOnceManager.ShouldOpen) { this.openOnceManager.Open(); } return(this.OnPeek(trackingContext, fromSequenceNumber, messageCount, timeout)); }
protected override IAsyncResult OnBeginClose(TimeSpan timeout, AsyncCallback callback, object state) { TrackingContext instance = TrackingContext.GetInstance(Guid.NewGuid()); BatchManager <TItem> .PerformFlushAsyncResult performFlushAsyncResult = null; lock (this.syncLock) { if (this.flushTimer.Cancel()) { performFlushAsyncResult = this.BeginFlush(instance, timeout, callback, state); } } if (performFlushAsyncResult != null) { performFlushAsyncResult.StartOperation(); return(performFlushAsyncResult); } return(new CompletedAsyncResult(callback, state)); }
public void RenewLock() { base.ThrowIfDisposed(); try { TrackingContext instance = TrackingContext.GetInstance(Guid.NewGuid(), this.Path); MessageSession.TraceRenewLock(EventTraceActivity.CreateFromThread(), instance); this.LockedUntilUtc = this.OnRenewLock(instance, this.OperationTimeout); } catch (Exception exception1) { Exception exception = exception1; if (!Fx.IsFatal(exception)) { throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsError(exception, null); } throw; } }
public SendAvailabilityMessagePump(SendAvailabilityPairedNamespaceOptions options) { if (options == null) { throw Fx.Exception.AsError(new ArgumentNullException("options"), null); } if (options.PrimaryMessagingFactory == null) { throw Fx.Exception.AsError(new ArgumentNullException("options.PrimaryMessagingFactory"), null); } if (options.SecondaryMessagingFactory == null) { throw Fx.Exception.AsError(new ArgumentNullException("options.MessagingFactory"), null); } this.options = options; this.InstanceTrackingContext = TrackingContext.GetInstance(Guid.NewGuid(), this.options.SbNamespace); this.SyphonId = SendAvailabilityMessagePump.NextSyphonId(); this.timers = new IOThreadTimer[this.options.BacklogQueueCount]; this.queuesInProcess = new IAsyncResult[this.options.BacklogQueueCount]; }
private static void OnRenewLockLoopCompleted(IAsyncResult result) { MessageReceivePump asyncState = (MessageReceivePump)result.AsyncState; try { asyncState.EndRenewLockLoop(result); } catch (Exception exception1) { Exception exception = exception1; if (Fx.IsFatal(exception)) { throw; } TrackingContext instance = TrackingContext.GetInstance(Guid.NewGuid(), asyncState.receiver.Path); MessagingClientEtwProvider.TraceClient(() => MessagingClientEtwProvider.Provider.MessageReceivePumpUnexpectedException(instance.Activity, instance.TrackingId, instance.SystemTracker, exception.ToString())); throw; } }
private static void OnFlushTimerFired(object state) { BatchManager <TItem> .PerformFlushAsyncResult performFlushAsyncResult; TrackingContext instance = TrackingContext.GetInstance(Guid.NewGuid()); BatchManager <TItem> batchManager = (BatchManager <TItem>)state; if (batchManager.State == CommunicationState.Opened) { lock (batchManager.syncLock) { performFlushAsyncResult = batchManager.BeginFlush(instance, TimeSpan.MaxValue, BatchManager <TItem> .flushCompleteCallback, batchManager); } if (performFlushAsyncResult != null) { performFlushAsyncResult.StartOperation(); if (performFlushAsyncResult.CompletedSynchronously) { batchManager.EndFlush(performFlushAsyncResult); } } } }
internal IAsyncResult BeginPeekBatch(TrackingContext trackingContext, long fromSequenceNumber, int messageCount, TimeSpan timeout, AsyncCallback callback, object state) { TrackingContext instance = trackingContext; base.ThrowIfDisposed(); TimeoutHelper.ThrowIfNegativeArgument(timeout); if (instance == null) { instance = TrackingContext.GetInstance(Guid.NewGuid(), this.Path); } MessageBrowser.TracePeek(EventTraceActivity.CreateFromThread(), instance); if (!this.openOnceManager.ShouldOpen) { MessageBrowser.RetryBrowserAsyncResult retryBrowserAsyncResult1 = new MessageBrowser.RetryBrowserAsyncResult(this, instance, messageCount, fromSequenceNumber, timeout, callback, state); retryBrowserAsyncResult1.Start(); return(retryBrowserAsyncResult1); } return(this.openOnceManager.Begin <IEnumerable <BrokeredMessage> >(callback, state, (AsyncCallback c, object s) => { MessageBrowser.RetryBrowserAsyncResult retryBrowserAsyncResult = new MessageBrowser.RetryBrowserAsyncResult(this, instance, messageCount, fromSequenceNumber, timeout, c, s); retryBrowserAsyncResult.Start(); return retryBrowserAsyncResult; }, new Func <IAsyncResult, IEnumerable <BrokeredMessage> >(MessageBrowser.RetryBrowserAsyncResult.End))); }
public IAsyncResult BeginSetState(Stream stream, AsyncCallback callback, object state) { IAsyncResult asyncResult; base.ThrowIfDisposed(); try { TrackingContext instance = TrackingContext.GetInstance(Guid.NewGuid(), this.Path); MessageSession.TraceSetState(EventTraceActivity.CreateFromThread(), instance, this.SessionId); MessageSession.RetrySessionAsyncResult retrySessionAsyncResult = new MessageSession.RetrySessionAsyncResult(this, instance, MessageSession.SessionOperation.SetState, stream, this.OperationTimeout, callback, state); retrySessionAsyncResult.Start(); asyncResult = retrySessionAsyncResult; } catch (Exception exception1) { Exception exception = exception1; if (!Fx.IsFatal(exception)) { throw Microsoft.ServiceBus.Messaging.FxTrace.Exception.AsError(exception, null); } throw; } return(asyncResult); }
protected MessagingException(SerializationInfo info, StreamingContext context) : base(info, context) { this.Initialize((MessagingExceptionDetail)info.GetValue("Detail", typeof(MessagingExceptionDetail)), TrackingContext.GetInstance((string)info.GetValue("TrackingId", typeof(string)), (string)info.GetValue("SubsystemId", typeof(string)), false), (DateTime)info.GetValue("Timestamp", typeof(DateTime))); }
private int GetOverheadSize() { long length = (long)0; using (MemoryStream memoryStream = new MemoryStream(1024)) { BrokeredMessage brokeredMessage = new BrokeredMessage(); BrokeredMessage brokeredMessage1 = new BrokeredMessage(); SendCommand sendCommand = new SendCommand(); BrokeredMessage[] brokeredMessageArray = new BrokeredMessage[] { brokeredMessage, brokeredMessage1 }; sendCommand.Messages = new MessageCollection(brokeredMessageArray); sendCommand.Timeout = TimeSpan.MaxValue; sendCommand.TransactionId = new string('A', 32); SendCommand sendCommand1 = sendCommand; RequestInfo requestInfo = new RequestInfo() { ServerTimeout = new TimeSpan?(sendCommand1.Timeout), OperationTimeout = new TimeSpan?(sendCommand1.Timeout), MessageId = Guid.NewGuid().ToString(), SessionId = Guid.NewGuid().ToString(), PartitionKey = Guid.NewGuid().ToString(), ViaPartitionKey = Guid.NewGuid().ToString(), TransactionId = Guid.NewGuid().ToString(), Destination = Guid.NewGuid().ToString() }; RequestInfo requestInfo1 = requestInfo; using (Message message = this.MessageCreator.CreateWcfMessage("http://schemas.microsoft.com/netservices/2011/06/servicebus/SbmpMessageSender/Send", sendCommand1, null, base.RetryPolicy, TrackingContext.GetInstance(Guid.NewGuid(), null), requestInfo1)) { (new BinaryMessageEncodingBindingElement()).CreateMessageEncoderFactory().Encoder.WriteMessage(message, memoryStream); } memoryStream.Flush(); length = memoryStream.Length; length = length - (brokeredMessage.Size + brokeredMessage1.Size); length = length + (long)512; brokeredMessage.Dispose(); brokeredMessage1.Dispose(); } return((int)length); }