Apache.NMS.ActiveMQ.Transport.Mock.MockTransportFactory.CompositeConnect C# (CSharp) Method

CompositeConnect() public method

public CompositeConnect ( Uri location ) : ITransport
location System.Uri
return ITransport
        public ITransport CompositeConnect(Uri location)
        {
            Tracer.Debug("MockTransportFactory: Create new Transport with options: " + location.Query);

            // Extract query parameters from broker Uri
            StringDictionary map = URISupport.ParseQuery(location.Query);

            // Set transport. properties on this (the factory)
            URISupport.SetProperties(this, map, "transport.");

            if(this.FailOnCreate == true)
            {
                throw new IOException("Failed to Create new MockTransport.");
            }

            // Create the Mock Transport
            MockTransport transport = new MockTransport(location);

            transport.FailOnReceiveMessage = this.FailOnReceiveMessage;
            transport.NumReceivedMessagesBeforeFail = this.NumReceivedMessagesBeforeFail;
            transport.FailOnSendMessage = this.FailOnSendMessage;
            transport.NumSentMessagesBeforeFail = this.NumSentMessagesBeforeFail;
            transport.Name = this.Name;
            transport.RespondToMessages = this.respondToMessages;
            transport.NumMessagesToRespondTo = this.numMessagesToRespondTo;

            return transport;
        }

Same methods

MockTransportFactory::CompositeConnect ( Uri location, SetTransport setTransport ) : ITransport

Usage Example

 public void CreateMockTransportWithParamsTest()
 {
     MockTransportFactory factory = new MockTransportFactory();
     
     Uri location = new Uri("mock://0.0.0.0:61616?transport.failOnSendMessage=true&transport.numSentMessagesBeforeFail=20");
     
     MockTransport transport = (MockTransport) factory.CompositeConnect(location);
     
     Assert.IsNotNull(transport);
     Assert.IsTrue(transport.FailOnSendMessage);
     Assert.AreEqual(20, transport.NumSentMessagesBeforeFail);
 }
All Usage Examples Of Apache.NMS.ActiveMQ.Transport.Mock.MockTransportFactory::CompositeConnect