Click here to Skip to main content
15,891,184 members
Articles / Desktop Programming / Win32

Routing Manager for WCF4

Rate me:
Please Sign up or sign in to vote.
5.00/5 (38 votes)
29 Apr 2010CPOL18 min read 108.2K   2.5K   92  
This article describes a design, implementation and usage of the Custom Routing Manager for managing messages via Routing Service built-in .Net 4 Technology.
<configuration>
	<system.webServer>
		<directoryBrowse enabled="true" />
	</system.webServer>
	<system.web>
		<compilation>
			<assemblies>
				<add assembly="System.ServiceModel.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
			</assemblies>
		</compilation>
	</system.web>
	
	
	<startup useLegacyV2RuntimeActivationPolicy="true">
		<supportedRuntime version="v4.0.30319" />
		<requiredRuntime version="v4.0.30319" safemode="true" />
	</startup>

	<!--<system.diagnostics>
    <sources>
      <source name="System.ServiceModel.Routing" switchValue="Warning">
        <listeners>
          <add type="System.Diagnostics.DefaultTraceListener" name="Default" />
          <add name="RouterTraceListener" />
        </listeners>
      </source>
    </sources>
    <sharedListeners>
      <add initializeData="c:\logs\RoutingService_tracelog.svclog"
			type="System.Diagnostics.XmlWriterTraceListener, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
			name="RouterTraceListener" traceOutputOptions="Timestamp, ThreadId, Callstack" />
    </sharedListeners>
    <trace autoflush="true" />
   </system.diagnostics>-->
		
	<system.serviceModel>
		<serviceHostingEnvironment>
			<serviceActivations>
				<add relativeAddress="~/Pilot.svc"
					 service="System.ServiceModel.Routing.RoutingService, System.ServiceModel.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 " />
				<add relativeAddress="~/PilotManager.svc"
					 service="RKiss.RoutingManager.RoutingManager, RKiss.RoutingManager" />
			</serviceActivations>
		</serviceHostingEnvironment>

		<extensions>
			<behaviorExtensions>
				<add name="routingManager"
					 type="RKiss.RoutingManager.RoutingManagerExtensionElement, RKiss.RoutingManager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" />
			</behaviorExtensions>
		</extensions>
		
		<client>
			<endpoint name="RepositoryEP"
					  address="http://localhost:8981/Repository/Routing"
					  binding="basicHttpBinding"
					  contract="RKiss.RoutingManager.IRepository" />
		</client>
		
		<services>
			<service name="System.ServiceModel.Routing.RoutingService" 
					 behaviorConfiguration="extBehavior">
				<host>
					<baseAddresses>
						<add baseAddress="http://localhost/Routing/" />
					</baseAddresses>
				</host>
				<endpoint name="endpointNotify"
						  address="Notify"
						  binding="basicHttpBinding"
						  contract="System.ServiceModel.Routing.ISimplexDatagramRouter" />
				<endpoint name="endpointRR"
						  address=""
						  binding="basicHttpBinding"
						  contract="System.ServiceModel.Routing.IRequestReplyRouter" />
			</service>
			<service name="RKiss.RoutingManager.RoutingManager" 
					 behaviorConfiguration="extBehaviorRM">
				<host>
					<baseAddresses>
						<add baseAddress="http://localhost/RoutingManager/" />
					</baseAddresses>
				</host>
				<endpoint name="endpointRM"
						  address="RM"
						  binding="basicHttpBinding"
						  contract="RKiss.RoutingManager.IRoutingManager" />			
				<endpoint contract="IMetadataExchange" 
						  binding="mexHttpBinding" 
						  address="mex"/>
			</service>
		</services>

		<behaviors>
			<serviceBehaviors>
				<behavior name="extBehavior">
					<routing />
					<routingManager filterTableName="routingTable1" 
									repositoryEndpointName="RepositoryEP" />					
				</behavior>
				<behavior name="extBehaviorRM">
					<routingManager filterTableName="routingTable1" 
									repositoryEndpointName="RepositoryEP" />
					<serviceMetadata httpGetEnabled="true" />
				</behavior>
			</serviceBehaviors>
		</behaviors>
	</system.serviceModel>
</configuration>


<!--<bindings>
			<basicHttpBinding>
				<binding name="basicHttpCustom" maxReceivedMessageSize="2000000" />
			</basicHttpBinding>
		</bindings>-->

<!--<routing>
      <filters>
        <clear />
        <filter name="ForwardMessage" filterType="EndpointName" filterData="endpointRR" filter1="" filter2="" customType="" />
      </filters>
      <filterTables>
        <clear />
        <filterTable name="routingTable1">
          <clear />
          <add filterName="ForwardMessage" endpointName="TE_Service1" priority="2" backupList="backup_ForwardMessage" />
        </filterTable>
      </filterTables>
      <backupLists>
        <clear />
        <backupList name="backup_ForwardMessage">
          <clear />
          <add endpointName="TE_Service2" />
        </backupList>
      </backupLists>
      <namespaceTable>
        <clear />
      </namespaceTable>
    </routing>-->

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, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer (Senior)
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions