Example #1
0
        static void Main(string[] args)
        {
            Console.CancelKeyPress += delegate { _interrupted = true; };

            while (!_interrupted)
            {
                using (var context = new Context(1))
                {
                    var proxyStoreFactory = new ProxyStoreZeroMQFactory(context);

                    var proxyResourceService = proxyStoreFactory.Build();

                    var getProxyResourceRequest = new GetProxyResourceRequest {
                        TargetUrl = "http://www.ticketmaster.com/example"
                    };

                    const int requestsToSend = 1000;

                    DateTime start = DateTime.UtcNow;
                    for (int requestNumber = 0; requestNumber < requestsToSend; requestNumber++)
                    {
                        var resource = proxyResourceService.GetProxyResource(getProxyResourceRequest);

                        ReleaseProxyResourceRequest releaseRequest = new ReleaseProxyResourceRequest()
                        {
                            ProxyResource = resource.ProxyResource
                        };
                        proxyResourceService.ReleaseProxyResource(releaseRequest);
                    }
                    DateTime end = DateTime.UtcNow;

                    Console.WriteLine("{0} took {1}", requestsToSend, end.Subtract(start));
                }
            }
        }
Example #2
0
        public ReleaseProxyResourceResponse ReleaseProxyResource(ReleaseProxyResourceRequest request)
        {
            var jsonRequest = JsonSerializer.SerializeToString(request);

            var response = new ReleaseProxyResourceResponse(request);

            using (Socket proxyResourceService = _zMqContext.Socket(SocketType.REQ))
            {
                proxyResourceService.Connect(ProxyStoreReleaseResourceAddress);

                //proxyResourceService.SendMore("GET_PROXY_RESOURCE", Encoding.Unicode);
                proxyResourceService.Send(jsonRequest, Encoding.Unicode);

                string jsonResponse = proxyResourceService.Recv(Encoding.Unicode);

                response = JsonSerializer.DeserializeFromString <ReleaseProxyResourceResponse>(jsonResponse);
            }
            return(response);
        }
 public ReleaseProxyResourceResponse(ReleaseProxyResourceRequest request)
 {
     _request = request;
 }
Example #4
0
 public ReleaseProxyResourceResponse(ReleaseProxyResourceRequest request)
 {
     _request = request;
 }