public AdapterConfiguration(string adapterName, string gatewayName, string adapterTypeName) { AdapterName = adapterName; GatewayName = gatewayName; AdapterTypeName = adapterTypeName; Configuration = new SerializableXDocument(XDocument.Parse("<objectConfig />")); }
public AdapterConfiguration(string adapterName, string gatewayName, string adapterTypeName, XDocument config) { AdapterName = adapterName; GatewayName = gatewayName; AdapterTypeName = adapterTypeName; if (config == null) { throw new ArgumentNullException("config"); } if (config.Root.Name != XName.Get("objectConfig")) { throw new ArgumentException("config"); } Configuration = new SerializableXDocument(config); }
public void AddMessageToToken(string updatingProcessorName, Token targetToken, string messageName, SerializableXDocument message) { lock (syncLock) { storage.UpdateToken(targetToken, delegate(Token token) { MessageFlowState messageflowState = token.GetMessageFlowState(); if (messageflowState.AssignedProcessor == updatingProcessorName) { token.UpdateMessageFlowState(mfs => { mfs.LastResponseFromProcessor = DateTime.Now; }); token.AddMessage(messageName, message); } }); } }
public ApplicationConfiguration(XDocument content) { Content = new SerializableXDocument(content); }
public SerializableXDocument SendMessage(EndpointAddress address, SerializableXDocument message, SerializableXDocument metadata) { if (!AdaptersByName.ContainsKey(address.AdapterName)) { throw new ArgumentException(string.Format( "There is no adapter named '{0}' in gateway '{1}'.", address.AdapterName, Name), "address"); } Adapter adapter = AdaptersByName[address.AdapterName]; XDocument result = adapter.SendMessage(address.EndpointName, message.XDocument, metadata.XDocument); return new SerializableXDocument(result); }
public void ReceiveReturn(Guid tokenGuid, SerializableXDocument resultMessage, SerializableXDocument sourceMetadata) { ResultHandlingInfo resultHandlingInfo; if (waitingResultMessageHandlers.TryRemove(tokenGuid, out resultHandlingInfo)) { resultHandlingInfo.ResultHandler(tokenGuid, resultMessage.XDocument, sourceMetadata.XDocument, resultHandlingInfo.Context); } }
public void FinishToken(string updatingProcessorName, Token targetToken, SerializableXDocument resultMessage) { lock (syncLock) { MessageFlowState messageflowState = targetToken.GetMessageFlowState(); if (messageflowState.AssignedProcessor == updatingProcessorName) { storage.UpdateToken(targetToken, delegate(Token token) { token.UpdateMessageFlowState(mfs => { mfs.LastResponseFromProcessor = DateTime.Now; }); }); XDocument sourceMetadata = targetToken.GetSourceMetadata(); var sourceAdress = targetToken.GetSourceAddress(); if (sourceAdress != null) { string sourceGatewayName = sourceAdress.GatewayName; GatewayAccessor sourceGateway = componentsAccessors.Values.OfType<GatewayAccessor>().SingleOrDefault(gwa => gwa.ComponentName == sourceGatewayName); sourceGateway.ReceiveReturn(targetToken.Guid, resultMessage, new SerializableXDocument(sourceMetadata)); } storage.UpdateToken(targetToken, delegate(Token token) { token.State = TokenState.Finished; }); } } }
public SerializableXDocument SendMessageToOutputEndPoint(EndpointAddress address, SerializableXDocument message, SerializableXDocument metadata) { SerializableXDocument result = gateway.SendMessage(address, message, metadata); return result; }
public SerializableXDocument SendMessage(EndpointAddress address, SerializableXDocument message, SerializableXDocument metadata) { ComponentAccessor component; if (componentsAccessors.TryGetValue(address.GatewayName, out component)) { if (component is GatewayAccessor) { GatewayAccessor gateway = (GatewayAccessor)component; SerializableXDocument result = gateway.SendMessageToOutputEndPoint(address, message, metadata); return result; } } throw new ArgumentException(string.Format( "Cannot find target gateway of endpoint address '{0}'.", address)); }
public void ReceiveReturn(Guid tokenGuid, SerializableXDocument resultMessage, SerializableXDocument sourceMetadata) { gateway.ReceiveReturn(tokenGuid, resultMessage, sourceMetadata); }
/// <summary> /// Creates a new instance of Token from given content and GUID. /// </summary> /// <param name="guid">token GUID; replaces any GUID in contentXml</param> /// <param name="contentXml">initial token content</param> public Token(Guid guid, string contentXml) { Guid = guid; Content = new SerializableXDocument(XDocument.Parse(contentXml)); Content.XDocument.Root.SetAttributeValue(XName.Get("guid"), guid.ToString()); }
/// <summary> /// Creates a new instance of Token from given content including a /// GUID. /// </summary> /// <param name="contentXml">initial token content</param> public Token(string contentXml) { Content = new SerializableXDocument(XDocument.Parse(contentXml)); Guid = Guid.Parse(Content.XDocument.Root.Attribute(XName.Get("guid")).Value); }
/// <summary> /// Replaces the whole XML content of the token with a new one. /// </summary> /// <remarks> /// <para> /// This can be useful for updating the token without /// creating a new instance. /// </para> /// <para>NOTE: It could be dangerous to replace the contents with /// arbitrary XML because it can damage the internal invariants of a /// token instance. Use with care! /// </para> /// <para> /// This method is synchronized and can block. /// </para> /// </remarks> /// <param name="content">new content of the token</param> public void UpdateContent(XDocument content) { lock (SyncLock) { Content = new SerializableXDocument(content); } }
/// <summary> /// Finishes the token processing. It changes only the token state, not /// the message flow. Also it might send a reply message back to the /// source gateway. /// </summary> /// <param name="token">token to be finished</param> /// <param name="resultMessage">reply message going back the the original /// gateway; can be null</param> public void FinishToken(Token token, XDocument resultMessage) { SerializableXDocument serializableResultMessage = new SerializableXDocument(resultMessage); BrokerService.FinishToken(ProcessorName, token, serializableResultMessage); }