3

Windows 1.0 の Service Bus の調査を開始して、アプリケーション用のローカル Service Bus を作成しました。バスを使用する最初の試みとして、ここに示す例に従いました: http://msdn.microsoft.com/en-us/ライブラリ/windowsazure/jj542433(v=azure.10).aspx

ただし、サンプルを実行すると、次のエラーが表示されます。

トークン プロバイダーは、'https://{machineName.domainName}/ServiceBusDefaultNamespace/$STS/Windows/' にアクセスしているときに、セキュリティ トークンを提供できませんでした。トークン プロバイダーからメッセージが返されました:「基になる接続が閉じられました: 送信時に予期しないエラーが発生しました。」

内部例外:

基になる接続が閉じられました: 送信時に予期しないエラーが発生しました。

私が検索したものはすべて、ローカルで生成された証明書などの問題に関連しています。これはそうではありません。「https://{machineName.domainName}:9355/ServiceBusDefaultNamespace/」を使用して STS を参照すると、キュー/トピックの Atom フィードが返されます。少なくともサンプルを機能させるために、これを前進させる助けはありますか?

ソース コード (上記のサンプル リンクと 99% 同一。文体の違いと ServerFQDN アドレスのみ。ローカルであり、インストールからのデータと一致します):

using System;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;

namespace ServiceBus1
{
    class Program
    {
        private const string ServerFQDN = "{machineName}.{domain}.net";
        private const int HttpPort = 9355;
        private const int TcpPort = 9354;
        private const string ServiceNamespace = "ServiceBusDefaultNamespace";

        static void Main( string[] args )
        {
            var connBuilder = new ServiceBusConnectionStringBuilder
                {
                    ManagementPort = HttpPort,
                    RuntimePort = TcpPort
                };
            connBuilder.Endpoints.Add( new UriBuilder { Scheme = "sb", Host = ServerFQDN, Path = ServiceNamespace }.Uri );
            connBuilder.StsEndpoints.Add( new UriBuilder { Scheme = "https", Host = ServerFQDN, Path = ServiceNamespace }.Uri );

            var messageFactory = MessagingFactory.CreateFromConnectionString( connBuilder.ToString() );
            var namespaceManager = NamespaceManager.CreateFromConnectionString( connBuilder.ToString() );

            const string queueName = "ServiceBusQueueSample";

            if ( namespaceManager == null )
            {
                Console.WriteLine( "\nUnexpectedError: NamespaceManager is NULL" );
                return;
            }

            if ( namespaceManager.QueueExists( queueName ) )
            {
                namespaceManager.DeleteQueue( queueName );
            }

            namespaceManager.CreateQueue( queueName );

            var myQueueClient = messageFactory.CreateQueueClient( queueName );

            try
            {
                // send a message to the queue
                var sendMessage = new BrokeredMessage( "Hello World!" );
                myQueueClient.Send( sendMessage );

                // receive the message from the queue
                var receivedMessage = myQueueClient.Receive( TimeSpan.FromSeconds( 5 ) );

                if ( receivedMessage != null )
                {
                    Console.WriteLine( "Message received: Body = {0}", receivedMessage.GetBody<string>() );
                    receivedMessage.Complete(); // releases msg lock and removes from queue?
                }
            }
            catch ( Exception e )
            {
                Console.WriteLine( "Unexpected exception {0}", e );
            }
            finally
            {
                if ( messageFactory != null )
                {
                    messageFactory.Close();
                }
            }

            Console.WriteLine( "Press ENTER to clean up and exit." );
            Console.ReadLine();
        }
    }
}
4

0 に答える 0