Adding service bus topic queue to a WCF Service
-
2011년 8월 8일 월요일 오후 1:04
I have a WCF Service which has one service reference to a 'consumer' service bus queue. This works as expected with the WCF service acting as a 'host' and receives messages off this queue I call the 'orders' queue. Now I want to add a second service reference (to this same WCF service) and add a different service bus topic queue to act as a client proxy here. When deploying out to the appfabric emulator, I get this exception in the trace log:
Fail to resolve import 'ProcessingQueue', System.InvalidOperationException: Failed to generate proxies for import 'ProcessingQueue' as none of the matching exports 'ProcessingQueue,' generated proxy. Please check that a valid partition key is passed and there is a valid constraint on the import.
at Microsoft.ApplicationServer.ApplicationModel.ServiceExtension.ResolveComponentImport(ServiceImportDefinition importDefinition, String partitionKey, IDictionary`2 contextProperties, Type expectedProxyType, Boolean throwOnError)
at Microsoft.ApplicationServer.ApplicationModel.ServiceExtension.ResolveImport[TProxy](String importName, String partitionKey, IDictionary`2 contextProperties, Boolean throwOnError)
at Microsoft.ApplicationServer.ServiceModel.Runtime.WcfServiceHost.PopulateMessagingEndpoint()Is there a restriction or issue adding both a host and client proxy queue references to a WCF service? I have also seen that you can not have more than one 'host' in WCF service as well (hosting a HTTP endpoint and service bus queue listening endpoint on the same WCF service doesn't work). Is there a better or proper way to create these client proxies and host services without have to write them yourself?
Darryl
모든 응답
-
2011년 8월 11일 목요일 오후 5:32
After some more trial and error, it appears that adding a 'consumer' (queue export type) service bus queue to WCF service is the only option supported in this CTP (none of the topic or subscription type queue work). As a work around, I have created the client queue proxy in code under the WCF service. This is not ideal as settings need to be hard coded (no config file support) and goes against the 'grain' of wiring up the references you want to use. I am trying to use WCF service to read a queue, then write to another queue without having to write alot of 'host/proxy' related code. I am leveraging Castle Windsor WCF facility to achieve this goal, plus the benefits of DI (see other posts). For interest, here is some of the code used to create the client proxy to another service bus queue using the Castle Windsor WCF facility. Now if I add the <IProcessing> interface to a class constructor, it will be populated with client proxy ready to use. Hopingfully we will see better support for WCF and topic/subscription type queues in future CTPs. This kinda explains why June CTP SBOrderSystemSample (messaging sample) uses a code service to read/write to these topic/subscription queues under a appfabric application.
Darryl
Trace.WriteLine("*********** Container ServiceHost Constructor Called *****************", "Information");
//Create a new container without reading a configuration file
_container = new WindsorContainer();
//add the facility support
_container.AddFacility<FactorySupportFacility>();
_container.AddFacility<WcfFacility>();
//add a reference of the contain to our new factory
_defaultServiceHostFactory = new DefaultServiceHostFactory(_container.Kernel);
const string baseAddress = "sb://<<your namespace>>.servicebus.appfabriclabs.com/";
var credential = TransportClientCredentialBase.CreateSharedSecretCredential("owner","<<your key>>");
var serviceBusBinding = new ServiceBusMessagingBinding();
serviceBusBinding.MessagingFactorySettings.Credential = credential;
var timeOut = new TimeSpan(0, 3, 0); //increase the timeouts to 3 minutes like other examples
serviceBusBinding.SendTimeout = timeOut;
serviceBusBinding.ReceiveTimeout = timeOut;
serviceBusBinding.OpenTimeout = timeOut;
serviceBusBinding.CloseTimeout = timeOut;
Trace.WriteLine("Service Bus binding done");ContractDescription cd = new ContractDescription("ProcessingQueue");
cd.ContractType = typeof (IProcessing);
ServiceEndpoint svcEndpoint = new ServiceEndpoint(
cd, serviceBusBinding, new EndpointAddress(baseAddress + "CloudCafeProcessingQueue"));Trace.WriteLine("Service Bus Endpoint done");
_container.Register(Component.For<IProcessing>()
.AsWcfClient(DefaultClientModel
.On(WcfEndpoint.FromEndpoint(svcEndpoint)))
.LifeStyle.Transient); -
2011년 9월 21일 수요일 오전 4:25
I am guessing the September CTP release with queues and topics may help with this now.
Thanks,
If this answers your question, please use the "Answer" button to say so | Ben Cline

