Forward messages between two sockets, you can also specify control socket which both sockets will send messages to
Exemplo n.º 1
0
        /// <summary>
        /// Starts the local to external message transfering.
        /// </summary>
        /// <param name="proxyForPublishersPort">The port for local publishers.</param>
        /// <param name="busPublisherPort">Broker's publisher port for other brokers subscription.</param>
        private void StartLocalToExternalTransfer(int proxyForPublishersPort, int busPublisherPort)
        {
            Task.Run(() =>
            {
                using (var subSocket = new SubscriberSocket())
                    using (var pubSocket = new PublisherSocket())
                    {
                        subSocket.SubscribeToAnyTopic();
                        subSocket.Bind($"tcp://localhost:{proxyForPublishersPort}");

                        pubSocket.Bind($"tcp://localhost:{busPublisherPort}");

                        _localToExternalProxy = new NetMQ.Proxy(subSocket, pubSocket);

                        _localToExternalProxy.Start();
                    }
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Starts the external to local message transfering.
        /// </summary>
        /// <param name="portForSubscribers">The port for local subscribers.</param>
        /// <param name="discoveryEndpoints">The endpoints to perform other brokers discovery.</param>
        private void StartExternalToLocalTransfer(int portForSubscribers, EndpointsRange discoveryEndpoints)
        {
            Task.Run(() =>
            {
                using (var xsubSocket = new XSubscriberSocket())
                    using (var xpubSocket = new XPublisherSocket())
                    {
                        xpubSocket.Bind($"tcp://localhost:{portForSubscribers}");

                        var dynamicSubscriber = new DynamicSubscriber(xsubSocket, discoveryEndpoints);
                        dynamicSubscriber.StartDiscovering();

                        _externalToLocalProxy = new NetMQ.Proxy(xpubSocket, xsubSocket);

                        _externalToLocalProxy.Start();
                    }
            });
        }
Exemplo n.º 3
0
        public static void Main(string[] args)
        {
            //
            // Simple request-reply broker
            //
            // Author: metadings
            //

            // Prepare our context and sockets
            using (var ctx = NetMQContext.Create())
            using (var frontend = ctx.CreateRouterSocket())
            using (var backend = ctx.CreateDealerSocket())
            {
                frontend.Bind("tcp://*:5559");
                backend.Bind("tcp://*:5560");

                var proxy = new Proxy(frontend, backend);
                proxy.Start();
            }
        }
Exemplo n.º 4
0
 static void Main(string[] args)
 {
     NetMQ.Proxy proxy = new NetMQ.Proxy(new XSubscriberSocket("@tcp://*:1011"), new XPublisherSocket("@tcp://*:1012"));
     Console.WriteLine("running...");
     proxy.Start();
 }