//new message arrived. void ChannelReceivedMessage(object sender, LightSingleArgEventArgs <System.Collections.Generic.List <BaseMessage> > e) { IMessageTransportChannel <BaseMessage> msgChannel = (IMessageTransportChannel <BaseMessage>)sender; foreach (BaseMessage message in e.Target) { if (message == null) { continue; } _tracing.Info("L: {0}\r\nR: {1}\r\n{2}", msgChannel.LocalEndPoint, msgChannel.RemoteEndPoint, message.ToString()); TransactionIdentity identity; if (message.TransactionIdentity == null) { identity = msgChannel.GenerateRequestIdentity(0U); } else { identity = message.TransactionIdentity; } //response. if (!identity.IsRequest) { _transactionManager.Active(identity, message); continue; } //create transaction by IsOneway flag. IMessageTransaction <BaseMessage> transaction = new BusinessMessageTransaction(_channel) { NeedResponse = !identity.IsOneway, TransactionManager = _transactionManager, Identity = identity, Request = message }; transaction.GetLease().Change(message.ExpireTime); NewTransactionHandler(new LightSingleArgEventArgs <IMessageTransaction <BaseMessage> >(transaction)); } }
//new message arrived. void ChannelReceivedMessage(object sender, LightSingleArgEventArgs <List <MetadataContainer> > e) { IMessageTransportChannel <MetadataContainer> msgChannel = (IMessageTransportChannel <MetadataContainer>)sender; foreach (MetadataContainer message in e.Target) { if (message == null) { continue; } _tracing.Info("L: {0}\r\nR: {1}\r\n{2}", msgChannel.LocalEndPoint, msgChannel.RemoteEndPoint, message.ToString()); TransactionIdentity identity; if (!message.IsAttibuteExsits(0x01)) { identity = msgChannel.GenerateRequestIdentity(0U); } else { identity = message.GetAttribute(0x01).GetValue <TransactionIdentity>(); } //response. if (!identity.IsRequest) { _transactionManager.Active(identity, message); continue; } //create transaction by IsOneway flag. IMessageTransaction <MetadataContainer> transaction = new MetadataMessageTransaction(_channel) { NeedResponse = !identity.IsOneway, TransactionManager = _transactionManager, Identity = identity, Request = message }; transaction.GetLease().Change(message.GetAttributeAsType <DateTime>(0x02)); NewTransactionHandler(new LightSingleArgEventArgs <IMessageTransaction <MetadataContainer> >(transaction)); } }