private void FireAndWait(CFXMessage msg, int timeout = 60000) { using (evt = new System.Threading.AutoResetEvent(false)) { CFXEnvelope env = CFXEnvelope.FromCFXMessage(msg); testEnv = env; endpoint.Publish(env); if (!evt.WaitOne(timeout)) { throw new TimeoutException("The message was not received by listener. Timeout"); } } }
private CFXEnvelope Endpoint_OnRequestReceived(CFXEnvelope request) { // Process request. Return Result. if (request.MessageBody is WhoIsThereRequest) { CFXEnvelope result = CFXEnvelope.FromCFXMessage(new WhoIsThereResponse() { CFXHandle = myCFXHandle, RequestNetworkUri = myRequestUri.ToString(), RequestTargetAddress = "" }); result.Source = myCFXHandle; result.Target = request.Source; return(result); } return(null); }
public void MakingRequests() { string myCFXHandle = "Vendor1.Model1.Machine34"; AmqpCFXEndpoint endpoint = new AmqpCFXEndpoint(); endpoint.Open(myCFXHandle); string targetEndpointHostname = "machine55.mydomain.com"; string targetCFXHandle = "Vendor2.Model2.Machine55"; string remoteUri = string.Format("amqp://{0}", targetEndpointHostname); // Set a timeout of 20 seconds. If the target endpoint does not // respond in this time, the request will time out. AmqpCFXEndpoint.RequestTimeout = TimeSpan.FromSeconds(20); // Build a GetEndpointInfomation Request CFXEnvelope request = CFXEnvelope.FromCFXMessage(new GetEndpointInformationRequest() { CFXHandle = targetCFXHandle }); CFXEnvelope response = endpoint.ExecuteRequest(remoteUri, request); }