public IBaseMessage Execute(IPipelineContext pipelineContext, IBaseMessage message)
        {
            if (TrackingModes != ActivityTrackingModes.None)
            {
                var messageDirection  = message.Direction();
                var isSolicitResponse = message.PortType().IsSolicitResponse();

                // tracking context can only be restored for the inbound message of a Solicit-Response MEP, i.e. when BizTalk was
                // the initiator of the 2-way MEP
                if (messageDirection.IsInbound() && isSolicitResponse)
                {
                    RestoreCachedTrackingContext(message);
                }

                var context            = new Context(pipelineContext, message, TrackingModes);
                var activityTracker    = Activity.Tracking.Messaging.ActivityTracker.Create(context);
                var messageBodyTracker = MessageBodyTracker.Create(context);

                // try to replace a claim token message with its original body's payload stream
                messageBodyTracker.TryCheckOutMessageBody();
                // ensure a TrackingStream has been setup and ascertain TrackingModes
                messageBodyTracker.SetupTracking();
                // perform the necessary setup to ensure TrackingContext is initiated early but information is collected at
                // stream's end
                activityTracker.TrackActivity();
                // try to replace message body's original payload with a claim token, this will drain the stream and, hence, ensure
                // activity tracking is completed
                messageBodyTracker.TryCheckInMessageBody();

                // tracking context can only be cached for the outbound message of a Solicit-Response MEP, i.e. when BizTalk is the
                // initiator of the 2-way MEP
                if (messageDirection.IsOutbound() && isSolicitResponse)
                {
                    CacheTrackingContext(message, message.ResolveTrackingContextCacheDuration(TrackingContextCacheDuration));
                }
            }
            return(message);
        }
 public static bool IsInitiatingMessageExchangePattern(this IBaseMessage message)
 {
     return((message.PortType().IsRequestResponse() && message.Direction().IsInbound()) ||
            (message.PortType().IsSolicitResponse() && message.Direction().IsOutbound()) ||
            message.PortType().IsOneWay());
 }