Exemplo n.º 1
0
		private void __HostInboundMessageEventHandler(IInboundAdapter sender, InboundMessageEventArgs e)
		{
			if ((object)sender == null)
				throw new ArgumentNullException("sender");

			if ((object)e == null)
				throw new ArgumentNullException("e");

			Console.WriteLine("ENGINE: Inbound message notification on thread {0}.", Thread.CurrentThread.ManagedThreadId);
			Thread.Sleep(1000);
			e.IntegrationMessage.Dispose();
		}
Exemplo n.º 2
0
		private void HostInboundMessageEventHandler(IInboundAdapter sender, InboundMessageEventArgs e)
		{
			IIntegrationFactory integrationFactory;
			IIntegrationMessageStore integrationMessageStore;
			IIntegrationMessage originalIntegrationMessage;
			IEnumerable<IIntegrationMessage> integrationMessages;

			if ((object)sender == null)
				throw new ArgumentNullException("sender");

			if ((object)e == null)
				throw new ArgumentNullException("e");

			//System.Console.WriteLine("ENGINE: Inbound message notification on thread {0}.", Thread.CurrentThread.ManagedThreadId);

			integrationFactory = AssemblyLoaderContainerContext.TheOnlyAllowedInstance.DependencyManager.ResolveDependency<IIntegrationFactory>(string.Empty, false);
			integrationMessageStore = AssemblyLoaderContainerContext.TheOnlyAllowedInstance.DependencyManager.ResolveDependency<IIntegrationMessageStore>(string.Empty, false);

			// get the message
			originalIntegrationMessage = e.IntegrationMessage;

			if ((object)originalIntegrationMessage == null)
				throw new InvalidOperationException("Inbound message was invalid.");

			using (originalIntegrationMessage)
			{
				// get receive pipeline
				using (IReceivePipeline receivePipeline = integrationFactory.CreateReceivePipeline())
				{
					// inbound pipeline processing
					using (IPipeliningContext pipeliningContext = receivePipeline.CreateContext())
						integrationMessages = receivePipeline.Execute(pipeliningContext, originalIntegrationMessage);

					if ((object)integrationMessages == null)
						throw new InvalidOperationException("Inbound messages were invalid.");

					// persist to dropbox
					foreach (IIntegrationMessage integrationMessage in integrationMessages)
					{
						if ((object)integrationMessage.DataStream != null)
						{
							using (integrationMessage.DataStream)
								integrationMessageStore.DropMessage(integrationMessage);
						}
					}
				}
			}
		}