public IBaseMessage Execute(IPipelineContext pipelineContext, IBaseMessage message) { if (message.Direction().IsInbound()) { var correlationId = message.GetProperty(SBMessagingProperties.CorrelationId); if (!correlationId.IsNullOrEmpty()) { message.PromoteCorrelationToken(correlationId); } var messageType = message.GetProperty(BrokeredProperties.MessageType); if (!messageType.IsNullOrEmpty()) { message.Promote(BtsProperties.MessageType, messageType); } } else { var correlationToken = message.GetProperty(BizTalkFactoryProperties.CorrelationToken); if (!correlationToken.IsNullOrEmpty()) { message.SetProperty(SBMessagingProperties.CorrelationId, correlationToken); } var messageType = message.GetOrProbeMessageType(pipelineContext); if (!messageType.IsNullOrEmpty()) { message.SetProperty(BrokeredProperties.MessageType, messageType); } } return(message); }
/// <summary> /// Restore the previously claimed message body's payload via a <see cref="TrackingStream"/> stream if it has been /// claimed to disk while being processed, that is if current payload is either one of the <see /// cref="Schemas.Xml.Claim.Check"/> or <see cref="Schemas.Xml.Claim.CheckOut"/> token messages. Leave the message /// body's payload stream unaltered otherwise. /// </summary> /// <param name="message"> /// The <see cref="IBaseMessage"/> token message whose message body's payload stream is going to be restored to /// the payload that has been previously claimed. /// </param> /// <param name="resourceTracker"> /// Pipeline's <see cref="IResourceTracker"/> to which to register the restored message body stream for later /// cleanup. /// </param> /// <remarks> /// The <see cref="TrackingStream"/> that will replace the <paramref name="message"/> stream with its previously /// captured original payload, will have its <see cref="TrackingStream.CaptureDescriptor"/> point to the previously /// captured-to-disk body payload, thereby providing an opportunity for the <see cref="MessagingStep"/> to share /// that already captured payload without saving it to disk again. /// </remarks> public virtual void Redeem(IBaseMessage message, IResourceTracker resourceTracker) { var messageType = message.GetOrProbeMessageType(resourceTracker); if (messageType == typeof(Claim.Check).GetMetadata().MessageType || messageType == typeof(Claim.CheckOut).GetMetadata().MessageType) { var messageBodyCaptureDescriptor = message.BodyPart.AsMessageBodyCaptureDescriptor(); if (_logger.IsDebugEnabled) { _logger.DebugFormat("Performing redeem of claim check token '{0}'.", messageBodyCaptureDescriptor.Data); } // replace claim token with actual content message.BodyPart.SetDataStream( new TrackingStream(OpenClaim(messageBodyCaptureDescriptor.Data), messageBodyCaptureDescriptor), resourceTracker); } else if (messageType == typeof(Claim.CheckIn).GetMetadata().MessageType) { throw new InvalidOperationException( string.Format( "Invalid token message, {0} token is not expected to be redeemed.", typeof(Claim.CheckIn).GetMetadata().RootElementName)); } else { if (_logger.IsDebugEnabled) { _logger.Debug("Skipping redeem of claim check token; message body stream's payload is not a token."); } } }
internal IEnumerable <PropertyExtractor> BuildPropertyExtractorCollection(IPipelineContext pipelineContext, IBaseMessage message) { var messageType = message.GetOrProbeMessageType(pipelineContext); var schemaMetadata = pipelineContext.GetSchemaMetadataByType(messageType, false); var schemaExtractors = schemaMetadata.Annotations.Extractors; return(schemaExtractors.Union(Extractors)); }
public static string GetOrProbeMessageType(this IBaseMessage message, IPipelineContext pipelineContext) { if (message == null) { throw new ArgumentNullException(nameof(message)); } if (pipelineContext == null) { throw new ArgumentNullException(nameof(pipelineContext)); } return(message.GetOrProbeMessageType(pipelineContext.ResourceTracker)); }
public IBaseMessage Execute(IPipelineContext pipelineContext, IBaseMessage message) { var customBrokeredMessagePropertyNamespace = message.GetProperty(SBMessagingProperties.CustomBrokeredMessagePropertyNamespace) ?? throw new InvalidOperationException($"{nameof(CustomBrokeredMessagePropertyNamespace)} has no value defined in SB-Messaging adapter configuration."); if (message.Direction().IsInbound()) { var correlationId = message.GetProperty(SBMessagingProperties.CorrelationId); // use the native BTS API instead of the message.PromoteCorrelationId(correlationId) to have no dependency on // BizTalk.Schemas which would reversed the desired dependency order, i.e. from an artifact component // (BizTalk.Schemas) to a runtime one (BizTalk.Pipeline.MicroComponents itself) if (!correlationId.IsNullOrEmpty()) { message.Context.Promote(nameof(SBMessagingProperties.CorrelationId), PropertySchemaNamespaces.BizTalkFactory, correlationId); } var messageType = (string)message.Context.Read(nameof(BizTalkFactoryProperties.MessageType), customBrokeredMessagePropertyNamespace); if (!messageType.IsNullOrEmpty()) { message.Promote(BtsProperties.MessageType, messageType); } } else { // use the native BTS API instead of the message.GetProperty(BizTalkFactoryProperties.CorrelationId) to have no // dependency on BizTalk.Schemas which would reversed the desired dependency order, i.e. from an artifact component // (BizTalk.Schemas) to a runtime one (BizTalk.Pipeline.MicroComponents itself) var correlationId = (string)message.Context.Read(nameof(SBMessagingProperties.CorrelationId), BizTalkFactoryProperties.MessageType.Namespace); if (!correlationId.IsNullOrEmpty()) { message.SetProperty(SBMessagingProperties.CorrelationId, correlationId); } var messageType = message.GetOrProbeMessageType(pipelineContext); if (!messageType.IsNullOrEmpty()) { message.Context.Write(nameof(BizTalkFactoryProperties.MessageType), customBrokeredMessagePropertyNamespace, messageType); } } return(message); }
public static string GetOrProbeMessageType(this IBaseMessage message, IPipelineContext pipelineContext) { return(message.GetOrProbeMessageType(pipelineContext.ResourceTracker)); }