Quantcast
Channel: Service Bus forum
Viewing all articles
Browse latest Browse all 1916

Timeout using WCF to send messages to an Azure Service Bus topic

$
0
0

It might be getting a bit dated, but I am using this article as my example:

http://blogs.msdn.com/b/tomholl/archive/2011/10/09/using-service-bus-topics-and-subscriptions-with-wcf.aspx

If there is a more up-to-date example out there, I am having a hard time finding it.

I'm struggling with the "Client" that is using WCF to write to the topic.  For simplicity, it is currently a console app, and I'm not trying to implement the dynamic topic/subscription creation - I just created them manually for now.


[DataContract]
    public class EventBase
    {
        [DataMember]
        public Guid Id { get; set; }

        [DataMember]
        public DateTime OccurredDateTimeUtc { get; set; }
    }

  [DataContract]
    public class DownloadTimerEvent : EventBase
    {
        [DataMember]
        public String RetailerSchemaName { get; set; }
    }

    [ServiceContract]
    public interface IEventEmitterBase<TEvent>
    {
        [OperationContract(IsOneWay = true)]
        void EmitEvent(TEvent e);
    }

    [ServiceContract]
    public interface IDownloadTimerEventEmitter : IEventEmitterBase<DownloadTimerEvent>
    {
    }

     class Program
    {
        private static readonly ILog log = LogManager.GetLogger(typeof (Program));

        static void Main(string[] args)
        {
            log.Info("Publishing event...");

            DownloadTimerEvent timerEvent = new DownloadTimerEvent();
            timerEvent.RetailerSchemaName = "test";
            try
            {
                var channelFactory = new ChannelFactory<IDownloadTimerEventEmitter>("destinationEndpoint");
                var channel = channelFactory.CreateChannel();
                channel.EmitEvent(timerEvent);

                log.Info("Event published.");
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
    }

<system.serviceModel>
    <extensions>
      <behaviorExtensions>
        <add name="transportClientEndpointBehavior" type="Microsoft.ServiceBus.Configuration.TransportClientEndpointBehaviorElement, Microsoft.ServiceBus, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </behaviorExtensions>
      <bindingExtensions>
        <add name="netMessagingBinding" type="Microsoft.ServiceBus.Messaging.Configuration.NetMessagingBindingCollectionElement, Microsoft.ServiceBus, Version=2.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
      </bindingExtensions>
    </extensions>
    <behaviors>
      <endpointBehaviors>
        <behavior name="securityBehavior">
          <transportClientEndpointBehavior>
            <tokenProvider>
              <sharedSecret issuerName="RootManageSharedAccessKey" issuerSecret="{MyKey}" />
            </tokenProvider>
          </transportClientEndpointBehavior>
        </behavior>
      </endpointBehaviors>
    </behaviors>
    <bindings>
      <netMessagingBinding>
        <binding name="messagingBinding" sendTimeout="00:03:00" receiveTimeout="00:03:00"
                 openTimeout="00:03:00" closeTimeout="00:03:00" sessionIdleTimeout="00:01:00"
                 prefetchCount="-1">
          <transportSettings batchFlushInterval="00:01:01" />
        </binding>
      </netMessagingBinding>
    </bindings>
    <client>
      <endpoint name="destinationEndpoint"
                address="sb://{MyNamespace}.servicebus.windows.net/{MyTopic}"
                binding="netMessagingBinding"
                bindingConfiguration="messagingBinding"
                contract="PremierConcepts.RetailDataImport.Service.V1.IDownloadTimerEventEmitter"
                behaviorConfiguration="securityBehavior" />
    </client>
  </system.serviceModel>

Below is the exception that is thrown (it looks like the timeout is about 15 seconds).  Something to do with getting the authorization token?

PremierConcepts.RetailDataImport.MockDownloadScheduler.WorkerRole: 2015-03-31 14:11:59,568 [Role Start Thread] INFO  WorkerRole                     Publishing event...
PremierConcepts.RetailDataImport.MockDownloadScheduler.WorkerRole: 2015-03-31 14:12:16,384 [Role Start Thread] ERROR WorkerRole                     System.TimeoutException: The request has timed out after 00:00:00 milliseconds. The successful completion of the request cannot be determined. Additional queries should be made to determine whether or not the operation has succeeded.

Server stack trace: 


Exception rethrown at [0]: 
   at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception)
   at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)
   at Microsoft.ServiceBus.TokenProviderHelper.EndGetAccessTokenCore(IAsyncResult result, String& expiresIn, String& audience)
   at Microsoft.ServiceBus.TokenProviderHelper.EndGetAccessTokenByAssertion(IAsyncResult result)
   at Microsoft.ServiceBus.SharedSecretTokenProvider.OnEndGetToken(IAsyncResult result, DateTime& cacheUntil)
   at Microsoft.ServiceBus.TokenProvider.GetTokenAsyncResult.OnEndTokenProviderCallback(IAsyncResult result, DateTime& cacheUntil)
   at Microsoft.ServiceBus.TokenProvider.GetTokenAsyncResultBase`1.OnCompletion(IAsyncResult result)
   at Microsoft.ServiceBus.TokenProvider.GetTokenAsyncResultBase`1.<GetAsyncSteps>b__f(T thisPtr, IAsyncResult r)
   at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state)

Exception rethrown at [1]: 
   at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception)
   at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)
   at Microsoft.ServiceBus.TokenProvider.EndGetToken(IAsyncResult result)
   at Microsoft.ServiceBus.TokenProviderUtility.GetMessagingToken(TokenProvider tokenProvider, Uri namespaceAddress, String appliesTo, String action, Boolean bypassCache, TimeSpan timeout)
   at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageCreator.GetAuthorizationToken(String appliesTo, String action)
   at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageCreator.GetAuthorizationHeader(String action)
   at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageCreator.CreateWcfMessageInternal(String action, Object body, Boolean includeToken, String parentLinkId, RetryPolicy policy, TrackingContext trackingContext, RequestInfo requestInfo)
   at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageCreator.CreateWcfMessage(String action, Object body, String parentLinkId, RetryPolicy policy, TrackingContext trackingContext, RequestInfo requestInfo)
   at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.GetOverheadSize()
   at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender..ctor(String path, SbmpMessagingFactory messagingFactory, SbmpMessageCreator messageCreator, RetryPolicy retryPolicy)
   at Microsoft.ServiceBus.Messaging.Sbmp.CreateSenderLinkSettings..ctor(SbmpMessagingFactory messagingFactory, String entityName, Nullable`1 entityType, String transferDestinationEntityName, RetryPolicy retryPolicy)
   at Microsoft.ServiceBus.Messaging.Sbmp.CreateSenderLinkSettings..ctor(SbmpMessagingFactory messagingFactory, String entityName, Nullable`1 entityType, String transferDestinationEntityName)
   at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessagingFactory.OnBeginCreateMessageSender(String transferDestinationEntityName, String viaEntityName, TimeSpan timeout, AsyncCallback callback, Object state)
   at Microsoft.ServiceBus.Messaging.MessagingFactory.CreateMessageSenderAsyncResult.<GetAsyncSteps>b__5b(CreateMessageSenderAsyncResult thisPtr, TimeSpan t, AsyncCallback c, Object s)
   at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.EnumerateSteps(CurrentThreadType state)
   at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.Start()

Exception rethrown at [2]: 
   at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception)
   at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)
   at Microsoft.ServiceBus.Messaging.OpenOnceManager.<>c__DisplayClass4`1.<Begin>b__3(IAsyncResult r, T& output)
   at Microsoft.ServiceBus.Messaging.OpenOnceManager.OpenOnceManagerAsyncResult`1.OperationComplete(IAsyncResult result)
   at Microsoft.ServiceBus.Common.AsyncResult.SyncContinue(IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.OpenOnceManager.OpenOnceManagerAsyncResult`1.BeginOperation()
   at Microsoft.ServiceBus.Messaging.OpenOnceManager.OpenOnceManagerAsyncResult`1.OpenComplete(IAsyncResult result)
   at Microsoft.ServiceBus.Common.AsyncResult.AsyncCompletionWrapperCallback(IAsyncResult result)

Exception rethrown at [3]: 
   at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception)
   at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.OpenOnceManager.OpenOnceManagerAsyncResult`1.End(IAsyncResult result, T& output)
   at Microsoft.ServiceBus.Messaging.OpenOnceManager.End[T](IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.MessagingFactory.EndCreateMessageSender(IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.Channels.ServiceBusOutputChannel.OpenMessagingFactoryAndMessageSenderAsyncResult.CreateSenderComplete(IAsyncResult result)
   at Microsoft.ServiceBus.Common.AsyncResult.AsyncCompletionWrapperCallback(IAsyncResult result)

Exception rethrown at [4]: 
   at Microsoft.ServiceBus.Common.ExceptionDispatcher.Throw(Exception exception)
   at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.Channels.ServiceBusOutputChannel.OpenMessagingFactoryAndMessageSenderAsyncResult.End(IAsyncResult result)
   at Microsoft.ServiceBus.Messaging.Channels.ServiceBusOutputChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
   at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOpenOnce.System.ServiceModel.Channels.ServiceChannel.ICallOnce.Call(ServiceChannel channel, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeSpan timeout, CallOnceManager cascade)
   at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout)
   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)

Exception rethrown at [5]: 
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at PremierConcepts.RetailDataImport.Service.V1.IEventEmitterBase`1.EmitEvent(TEvent e)
   at PremierConcepts.RetailDataImport.MockDownloadScheduler.WorkerRole.PublishEvent(DownloadTimerEvent timerEvent) in c:\Development\C#\ImportCloudServices\PremierConcepts.RetailDataImport.MockDownloadScheduler\WorkerRole.cs:line 57

Any tips or leads would be appreciated - I've never used WCF for messaging before. 

Thanks

 - Brandon


Viewing all articles
Browse latest Browse all 1916

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>