Click here to Skip to main content
15,885,216 members
Articles / Programming Languages / C#

A generic and typed way to transfer .NET objects to COM+ queued components

Rate me:
Please Sign up or sign in to vote.
3.63/5 (7 votes)
21 Apr 20045 min read 50.2K   519   19  
Article describes a way to pass any .NET managed object as a parameter to a COM+ queued component in an easy way
using System;
using System.EnterpriseServices;
using System.Diagnostics;
using QCUtil;
using Orders;

// Make this a server COM+ application.
[assembly: ApplicationActivation(ActivationOption.Server)]
// Enable queueing and listener, only one thread will be processing object messages.
[assembly: ApplicationQueuing(Enabled=true, QueueListenerEnabled=true, MaxListenerThreads=1)]
[assembly: ApplicationAccessControl(false)]

namespace QCSolution
{
	// COM+ Queued Component Interface
	[InterfaceQueuing(Enabled=true)]
	public interface IShipOrderRequestHandler
	{
		// Test simple transfer to check basic configuration.
		void testMessage(String message);
		// Non typed object transfer
		void shipOrderRequestGeneric(QCTransferObject to);
		// Typed object transfer, specific to Orders
		void shipOrderRequest(OrderTransfer ot);
	}

	// COM+ Queued Component Implementation
	[InterfaceQueuing(Interface = "IShipOrderRequestHandler")]
	[Transaction]
	public class ShipOrderRequestHandler : ServicedComponent, IShipOrderRequestHandler
	{
		public ShipOrderRequestHandler() {}

		[AutoComplete]
		public void testMessage(String message) {
			EventLog.WriteEntry("ShippingApp", "Message received, msg="+message,EventLogEntryType.Information);
		}
		[AutoComplete]
		public void shipOrderRequestGeneric(QCTransferObject to) {
			EventLog.WriteEntry("ShippingApp", "QCTranserferObject received, ToString="+to.ToString(),EventLogEntryType.Information);
		}
		[AutoComplete]
		public void shipOrderRequest(OrderTransfer ot) {
			EventLog.WriteEntry("ShippingApp", "OrderTransfer received, order="+ot.orderDto.ToString(),EventLogEntryType.Information);
		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Belgium Belgium
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions