public EventingBasicConsumerFactory(IChannelFactory channelFactory, IErrorHandlingStrategy strategy)
 {
     _channelFactory = channelFactory;
     _strategy = strategy;
     _processedButNotAcked = new ConcurrentBag<string>();
     _consumers = new ConcurrentBag<IRawConsumer>();
 }
        public MainWindow()
        {
            InitializeComponent();
            var ender = new EndpointAddress(MyEndpoint);
            bindbert.MaxReceivedMessageSize = 2147483647;
            bindbert.MaxBufferSize = 2147483647;

            MyScanneriChannel = new ChannelFactory<ScannerEngine.ScannerInterfaceDefinition>(bindbert);
            
            Trycorder = MyScanneriChannel.CreateChannel(ender);



            StartWCFService();
            var teststate = host.State;
            
            Trycorder.Initialize();
            BuildProfileMenuList();
            BuildRegionMenuList();
            BuildComponentMenuList();
            ConfigureComponentSelectComboBox();

            ///Get a timer to update status on UI.
            /// 
            DispatcherTimer UpdateStatusTimer = new DispatcherTimer();
            UpdateStatusTimer.Tick += new EventHandler(updateStatusTimer_Tick);
            UpdateStatusTimer.Interval = new TimeSpan(0, 0, 5);
            UpdateStatusTimer.Start();


        }
Example #3
0
        public GuestHandleFactory(IChannelFactory channelFactory)
        {
            ISerializer serializer = new ProtobufSerializer();
            IChannel channel = channelFactory.CreateChannel();

            // todo1[ak] check args
            _requester = new Requester(serializer, channel);
        }
 public SingleCallChannelReceiver(IChannelFactory channelFactory, IDeduplicateMessages deduplicator,
     DataBusHeaderManager headerManager, IdempotentChannelReceiver receiver)
 {
     this.channelFactory = channelFactory;
     this.deduplicator = deduplicator;
     this.headerManager = headerManager;
     this.receiver = receiver;
 }
 public SingleCallChannelReceiver(IChannelFactory channelFactory, IDeduplicateMessages deduplicator,
     DataBusHeaderManager headerManager, GatewayTransaction transaction)
 {
     this.channelFactory = channelFactory;
     this.deduplicator = deduplicator;
     this.headerManager = headerManager;
     this.transaction = transaction;
 }
Example #6
0
 public Sender(string name, bool useDedicatedThread, TimeSpan delay)
 {
     this.name = name;
     NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
     this.factory = binding.BuildChannelFactory<IDuplexSessionChannel>();
     this.useDedicatedThread = useDedicatedThread;
     this.delay = delay;
 }
 public DuplexChannelManager(int connections, int messageRate, Binding binding, string address, MessageBuffer messageBuffer = null)
 {
     _connections = connections;
     _rate = messageRate;
     _factory = binding.BuildChannelFactory<IDuplexSessionChannel>();
     _address = new EndpointAddress(address);
     _messageBuffer = messageBuffer ??  Message.CreateMessage(binding.MessageVersion, "TestAction", new byte[1024]).CreateBufferedCopy(int.MaxValue); ;
     _factory.Open();
 }
Example #8
0
 public DefaultStrategy(IMessageSerializer serializer, INamingConventions conventions, IBasicPropertiesProvider propertiesProvider, ITopologyProvider topologyProvider, IChannelFactory channelFactory)
 {
     _serializer = serializer;
     _propertiesProvider = propertiesProvider;
     _topologyProvider = topologyProvider;
     _channelFactory = channelFactory;
     _errorExchangeCfg = ExchangeConfiguration.Default;
     _errorExchangeCfg.ExchangeName = conventions.ErrorExchangeNamingConvention();
 }
 public TransactionalChannelDispatcher(IChannelFactory channelFactory,
                                         IMessageNotifier notifier,
                                         ISendMessages messageSender,
                                         IRouteMessages routeMessages)
 {
     this.routeMessages = routeMessages;
     this.channelFactory = channelFactory;
     this.notifier = notifier;
     this.messageSender = messageSender;
 }
Example #10
0
 private void Initialize()
 {
     lock (this.syncroot)
     {
         if (this.channel == null)
         {
             this.channelFactory = new ChannelFactory <T>(this.binding);
             this.channel        = this.channelFactory.CreateChannel(this.endpoint);
         }
     }
 }
        public override void OnClose(TimeSpan timeout)
        {
            TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);

            if (this.rstChannelFactory != null)
            {
                this.rstChannelFactory.Close(timeoutHelper.RemainingTime());
                this.rstChannelFactory = null;
            }
            FreeCredentialsHandle();
        }
        public override void OnClose(TimeSpan timeout)
        {
            TimeoutHelper helper = new TimeoutHelper(timeout);

            if (this.rstChannelFactory != null)
            {
                this.rstChannelFactory.Close(timeout);
                this.rstChannelFactory = null;
            }
            base.OnClose(helper.RemainingTime());
        }
 protected LayeredChannelFactory(BindingContext context)
     : base(context.Binding)
 {
     this.innerChannelFactory = context.BuildInnerChannelFactory <TInnerChannel>();
     if (this.innerChannelFactory == null)
     {
         throw new ArgumentNullException("innerChannelFactory");
     }
     this.onInnerFactoryFaulted        = new EventHandler(OnInnerFactoryFaulted);
     this.innerChannelFactory.Faulted += this.onInnerFactoryFaulted;
 }
Example #14
0
 public override void OnAbort()
 {
     if ((this.channelFactory != null) && (this.channelFactory.State == CommunicationState.Opened))
     {
         this.channelFactory.Abort();
         this.channelFactory = null;
     }
     this.CleanUpRsaSecurityTokenCache();
     this.FreeCredentialsHandle();
     base.OnAbort();
 }
 public Publisher(IChannelFactory channelFactory, ITopologyProvider topologyProvider, IMessageSerializer serializer, IPublishAcknowledger acknowledger,
                  IBasicPropertiesProvider propertiesProvider, RabbitMqConfiguration config, ILogger <Publisher> logger)
 {
     _logger             = logger;
     _channelFactory     = channelFactory;
     _topologyProvider   = topologyProvider;
     _serializer         = serializer;
     _acknowledger       = acknowledger;
     _propertiesProvider = propertiesProvider;
     _config             = config;
 }
    //[WcfFact]
    //[OuterLoop]
    public static void IRequestChannel_Async_Http_CustomBinding()
    {
        IChannelFactory <IRequestChannel> factory = null;
        IRequestChannel channel      = null;
        Message         replyMessage = null;

        try
        {
            // *** SETUP *** \\
            BindingElement[] bindingElements = new BindingElement[2];
            bindingElements[0] = new TextMessageEncodingBindingElement();
            bindingElements[1] = new HttpTransportBindingElement();
            CustomBinding binding = new CustomBinding(bindingElements);

            // Create the channel factory for the request-reply message exchange pattern.
            factory = binding.BuildChannelFactory <IRequestChannel>(new BindingParameterCollection());
            Task.Factory.FromAsync(factory.BeginOpen, factory.EndOpen, TaskCreationOptions.None).GetAwaiter().GetResult();

            // Create the channel.
            channel = factory.CreateChannel(new EndpointAddress(Endpoints.DefaultCustomHttp_Address));
            Task.Factory.FromAsync(channel.BeginOpen, channel.EndOpen, TaskCreationOptions.None).GetAwaiter().GetResult();

            // Create the Message object to send to the service.
            Message requestMessage = Message.CreateMessage(
                binding.MessageVersion,
                action,
                new CustomBodyWriter(clientMessage));

            // *** EXECUTE *** \\
            // Send the Message and receive the Response.
            replyMessage = Task.Factory.FromAsync((asyncCallback, o) => channel.BeginRequest(requestMessage, asyncCallback, o),
                                                  channel.EndRequest,
                                                  TaskCreationOptions.None).GetAwaiter().GetResult();

            // *** VALIDATE *** \\
            string replyMessageAction = replyMessage.Headers.Action;
            Assert.Equal(action + "Response", replyMessageAction);

            var    replyReader      = replyMessage.GetReaderAtBodyContents();
            string actualResponse   = replyReader.ReadElementContentAsString();
            string expectedResponse = "[client] This is my request.[service] Request received, this is my Reply.";
            Assert.Equal(expectedResponse, actualResponse);

            // *** CLEANUP *** \\
            replyMessage.Close();
            Task.Factory.FromAsync(channel.BeginClose, channel.EndClose, TaskCreationOptions.None).GetAwaiter().GetResult();
            Task.Factory.FromAsync(factory.BeginClose, factory.EndClose, TaskCreationOptions.None).GetAwaiter().GetResult();
        }
        finally
        {
            // *** ENSURE CLEANUP *** \\
            ScenarioTestHelpers.CloseCommunicationObjects(channel, factory);
        }
    }
Example #17
0
        // with July CTP it still works ...
        public void BuildChannelFactoryHttpNoMessage()
        {
            BindingContext ctx = new BindingContext(
                new CustomBinding(
                    new HttpTransportBindingElement()),
                empty_params);
            IChannelFactory <IRequestChannel> cf =
                ctx.BuildInnerChannelFactory <IRequestChannel> ();

            cf.Open();
        }
Example #18
0
        public ClientContext(Uri endpointUri, AddressingVersion addressingVersion, IChannelFactory <T> proxyFactory, AddressHeaderCreatorDelegate addressHeaderCreatorDelegate)
        {
            var builder = new EndpointAddressBuilder();

            addressHeaderCreatorDelegate(builder.Headers);
            builder.Uri = endpointUri;

            _channel = proxyFactory.CreateChannel(builder.ToEndpointAddress());
            _scope   = new OperationContextScope((IContextChannel)_channel);
            AddressingVersionExtension.Activate(addressingVersion);
        }
 protected ClientReliableChannelBinder(EndpointAddress to, Uri via, IChannelFactory <TChannel> factory,
                                       MaskingMode maskingMode, TolerateFaultsMode faultMode, ChannelParameterCollection channelParameters,
                                       TimeSpan defaultCloseTimeout, TimeSpan defaultSendTimeout)
     : base(factory.CreateChannel(to, via), maskingMode, faultMode,
            defaultCloseTimeout, defaultSendTimeout)
 {
     _to                = to;
     Via                = via;
     _factory           = factory;
     _channelParameters = channelParameters ?? throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull(nameof(channelParameters));
 }
Example #20
0
    public static void IDuplexSessionChannel_Https_NetHttpsBinding()
    {
        IChannelFactory <IDuplexSessionChannel> factory = null;
        IDuplexSessionChannel channel = null;
        Message replyMessage          = null;

        try
        {
            // *** SETUP *** \\
            NetHttpsBinding binding = new NetHttpsBinding(BasicHttpsSecurityMode.Transport);

            // Create the channel factory
            factory = binding.BuildChannelFactory <IDuplexSessionChannel>(new BindingParameterCollection());
            factory.Open();

            // Create the channel.
            channel = factory.CreateChannel(new EndpointAddress(Endpoints.HttpBaseAddress_NetHttpsWebSockets));
            channel.Open();

            // Create the Message object to send to the service.
            Message requestMessage = Message.CreateMessage(
                binding.MessageVersion,
                action,
                new CustomBodyWriter(clientMessage));
            requestMessage.Headers.MessageId = new UniqueId(Guid.NewGuid());

            // *** EXECUTE *** \\
            // Send the Message and receive the Response.
            channel.Send(requestMessage);
            replyMessage = channel.Receive(TimeSpan.FromSeconds(5));

            // *** VALIDATE *** \\
            // If the incoming Message did not contain the same UniqueId used for the MessageId of the outgoing Message we would have received a Fault from the Service
            string expectedMessageID = requestMessage.Headers.MessageId.ToString();
            string actualMessageID   = replyMessage.Headers.RelatesTo.ToString();
            Assert.True(String.Equals(expectedMessageID, actualMessageID), String.Format("Expected Message ID was {0}. Actual was {1}", expectedMessageID, actualMessageID));

            // Validate the Response
            var    replyReader      = replyMessage.GetReaderAtBodyContents();
            string actualResponse   = replyReader.ReadElementContentAsString();
            string expectedResponse = "[client] This is my request.[service] Request received, this is my Reply.";
            Assert.Equal(expectedResponse, actualResponse);

            // *** CLEANUP *** \\
            replyMessage.Close();
            channel.Close();
            factory.Close();
        }
        finally
        {
            // *** ENSURE CLEANUP *** \\
            ScenarioTestHelpers.CloseCommunicationObjects(channel, factory);
        }
    }
Example #21
0
 public ExplicitAckMiddleware(INamingConventions conventions, ITopologyProvider topology, IChannelFactory channelFactory, ExplicitAckOptions options = null)
 {
     Conventions                = conventions;
     Topology                   = topology;
     ChannelFactory             = channelFactory;
     DeliveryArgsFunc           = options?.DeliveryArgsFunc ?? (context => context.GetDeliveryEventArgs());
     ConsumerFunc               = options?.ConsumerFunc ?? (context => context.GetConsumer());
     MessageAcknowledgementFunc = options?.GetMessageAcknowledgement ?? (context => context.GetMessageAcknowledgement());
     AbortExecution             = options?.AbortExecution ?? (ack => !(ack is Ack));
     AutoAckFunc                = options?.AutoAckFunc ?? (context => context.GetConsumeConfiguration().AutoAck);
 }
 public Subscriber(IChannelFactory channelFactory, IConsumerFactory consumerFactory, ITopologyProvider topologyProvider,
                   IMessageSerializer serializer, RabbitMqConfiguration config, ILogger <Subscriber> logger)
 {
     _logger           = logger;
     _channelFactory   = channelFactory;
     _consumerFactory  = consumerFactory;
     _topologyProvider = topologyProvider;
     _serializer       = serializer;
     _config           = config;
     _subscriptions    = new List <ISubscription>();
 }
    public static void IDuplexSessionChannel_Async_Tcp_NetTcpBinding()
    {
        IChannelFactory <IDuplexSessionChannel> factory = null;
        IDuplexSessionChannel channel = null;
        Message replyMessage          = null;

        try
        {
            // *** SETUP *** \\
            NetTcpBinding binding = new NetTcpBinding(SecurityMode.None);

            // Create the channel factory
            factory = binding.BuildChannelFactory <IDuplexSessionChannel>(new BindingParameterCollection());
            Task.Factory.FromAsync(factory.BeginOpen, factory.EndOpen, TaskCreationOptions.None).GetAwaiter().GetResult();

            // Create the channel.
            channel = factory.CreateChannel(new EndpointAddress(Endpoints.Tcp_NoSecurity_Address));
            Task.Factory.FromAsync(channel.BeginOpen, channel.EndOpen, TaskCreationOptions.None).GetAwaiter().GetResult();

            // Create the Message object to send to the service.
            Message requestMessage = Message.CreateMessage(
                binding.MessageVersion,
                action,
                new CustomBodyWriter(clientMessage));
            requestMessage.Headers.MessageId = new UniqueId(Guid.NewGuid());

            // *** EXECUTE *** \\
            // Send the Message and receive the Response.
            Task.Factory.FromAsync((asyncCallback, o) => channel.BeginSend(requestMessage, asyncCallback, o),
                                   channel.EndSend,
                                   TaskCreationOptions.None).GetAwaiter().GetResult();
            replyMessage = Task.Factory.FromAsync(channel.BeginReceive, channel.EndReceive, TaskCreationOptions.None).GetAwaiter().GetResult();

            // *** VALIDATE *** \\
            // If the incoming Message did not contain the same UniqueId used for the MessageId of the outgoing Message we would have received a Fault from the Service
            Assert.Equal(requestMessage.Headers.MessageId.ToString(), replyMessage.Headers.RelatesTo.ToString());

            // Validate the Response
            var    replyReader      = replyMessage.GetReaderAtBodyContents();
            string actualResponse   = replyReader.ReadElementContentAsString();
            string expectedResponse = "[client] This is my request.[service] Request received, this is my Reply.";
            Assert.Equal(expectedResponse, actualResponse);

            // *** CLEANUP *** \\
            replyMessage.Close();
            Task.Factory.FromAsync(channel.BeginClose, channel.EndClose, TaskCreationOptions.None).GetAwaiter().GetResult();
            Task.Factory.FromAsync(factory.BeginClose, factory.EndClose, TaskCreationOptions.None).GetAwaiter().GetResult();
        }
        finally
        {
            // *** ENSURE CLEANUP *** \\
            ScenarioTestHelpers.CloseCommunicationObjects(channel, factory);
        }
    }
        public override IChannelFactory <TChannel> BuildChannelFactory <TChannel>(BindingContext context)
        {
            ValidateTransport(context.Binding);
            IChannelFactory <TChannel> innerChannelFactory = context.BuildInnerChannelFactory <TChannel>();

            IChannelFactory <TChannel> channelFactory =
                new DurableInstanceChannelFactory <TChannel>(contextStoreLocation,
                                                             contextType, innerChannelFactory);

            return(channelFactory);
        }
    public static void IRequestChannel_Http_CustomBinding()
    {
        try
        {
            BindingElement[] bindingElements = new BindingElement[2];
            bindingElements[0] = new TextMessageEncodingBindingElement();
            bindingElements[1] = new HttpTransportBindingElement();
            CustomBinding binding = new CustomBinding(bindingElements);

            // Create the channel factory for the request-reply message exchange pattern.
            IChannelFactory <IRequestChannel> factory =
                binding.BuildChannelFactory <IRequestChannel>(
                    new BindingParameterCollection());
            factory.Open();

            // Create the channel.
            IRequestChannel channel = factory.CreateChannel(
                new EndpointAddress(BaseAddress.HttpBaseAddress));
            channel.Open();

            // Create the Message object to send to the service.
            Message requestMessage = Message.CreateMessage(
                binding.MessageVersion,
                action,
                new CustomBodyWriter(clientMessage));

            // Send the Message and receive the Response.
            Message replyMessage       = channel.Request(requestMessage);
            string  replyMessageAction = replyMessage.Headers.Action;

            if (!string.Equals(replyMessageAction, action + "Response"))
            {
                Assert.True(false, String.Format("A response was received from the Service but it was not the expected Action, expected: {0} actual: {1}", action + "Response", replyMessageAction));
            }


            var    replyReader      = replyMessage.GetReaderAtBodyContents();
            string actualResponse   = replyReader.ReadElementContentAsString();
            string expectedResponse = "[client] This is my request.[service] Request received, this is my Reply.";
            if (!string.Equals(actualResponse, expectedResponse))
            {
                Assert.True(false, String.Format("Actual MessageBodyContent from service did not match the expected MessageBodyContent, expected: {0} actual: {1}", expectedResponse, actualResponse));
            }

            replyMessage.Close();
            channel.Close();
            factory.Close();
        }

        catch (Exception ex)
        {
            Assert.True(false, String.Format("Unexpected exception was caught: {0}", ex.ToString()));
        }
    }
Example #26
0
        public ClientBase(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress)
        {
            //this.remoteAddress = remoteAddress;
            this.messageVersion = binding.MessageVersion;

            IChannelFactory <IRequestChannel> channelFactory = binding.BuildChannelFactory <IRequestChannel>(
                new BindingParameterCollection());

            channelFactory.Open();
            this.requestChannel = channelFactory.CreateChannel(remoteAddress);
        }
Example #27
0
 public void Dispose()
 {
     if (_contactService != null)
     {
         IChannelFactory channel = _contactService as IChannelFactory;
         if (channel != null && channel.State != CommunicationState.Closed)
         {
             channel.Close();
         }
     }
 }
Example #28
0
 static void BindLifetimes(IChannelFactory factory, IChannel channel)
 {
     channel.Closed += delegate
     {
         IAsyncResult result = factory.BeginClose(FactoryCloseCallback, factory);
         if (result.CompletedSynchronously)
         {
             factory.EndClose(result);
         }
     };
 }
Example #29
0
        private void Initialize(string kernelName, IKernelSpecManager specManager, IChannelFactory channelFactory, ILogger logger)
        {
            this.Logger                = logger ?? new DefaultLogger();
            this.HashHelper            = new HashHelper();
            this.SpecManager           = specManager ?? (new KernelSpecManager());
            this.Spec                  = SpecManager.GetKernelSpec(kernelName);
            this.ConnectionInformation = new KernelConnection();
            this.ChannelFactory        = channelFactory;

            this.Debug = false;
        }
Example #30
0
        public override IChannelFactory <TChannel> BuildChannelFactory <TChannel>(BindingContext context)
        {
            if (!CanBuildChannelFactory <TChannel>(context))
            {
                throw new ArgumentException();
            }

            IChannelFactory <IRequestChannel> innerChannelFactory = (IChannelFactory <IRequestChannel>)base.BuildChannelFactory <TChannel>(context);

            return((IChannelFactory <TChannel>) new OAuthChannelFactory(innerChannelFactory));
        }
Example #31
0
        public virtual IChannelFactory <TChannel> BuildChannelFactory <TChannel>(BindingParameterCollection parameters)
        {
            EnsureInvariants();
            BindingContext             context        = new BindingContext(new CustomBinding(this), parameters);
            IChannelFactory <TChannel> channelFactory = context.BuildInnerChannelFactory <TChannel>();

            context.ValidateBindingElementsConsumed();
            this.ValidateSecurityCapabilities(channelFactory.GetProperty <ISecurityCapabilities>(), parameters);

            return(channelFactory);
        }
        public void OpenRequestWithDefaultServiceCertificate()
        {
            IChannelFactory <IRequestChannel> f =
                CreateDefaultServiceCertFactory();

            f.Open();
            // This EndpointAddress does not contain X509 identity
            IRequestChannel ch = f.CreateChannel(new EndpointAddress("stream:dummy"));

            ch.Open();
            // stop here.
        }
Example #33
0
 public RequestSessionChannel(ReconnectBindingElement.ReconnectChannelFactory <IRequestSessionChannel> factory, EndpointAddress address, IEnumerable <Uri> viaAddresses) : base(factory)
 {
     this.innerFactory  = factory.innerFactory;
     this.RemoteAddress = address;
     this.Via           = viaAddresses.First <Uri>();
     ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.OutputSession outputSession = new ReconnectBindingElement.ReconnectChannelFactory <TChannel> .RequestSessionChannel.OutputSession()
     {
         Id = Guid.NewGuid().ToString()
     };
     this.Session       = outputSession;
     this.sharedChannel = new SharedChannel <IRequestSessionChannel>(this.innerFactory, viaAddresses);
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="RabbitMqChannel"/> class.
        /// </summary>
        /// <param name="channelFactory">A <see cref="IChannelFactory"/> used to construct the <see cref="IModel"/> representing Rabbit MQ channel.</param>
        /// <param name="timer">Timer used to check if there is connection</param>
        /// <param name="maxTimeBetweenMessages">Max timeout between messages to check if connection is ok</param>
        public RabbitMqChannel(IChannelFactory channelFactory, ITimer timer, TimeSpan maxTimeBetweenMessages)
        {
            Guard.Argument(channelFactory, nameof(channelFactory)).NotNull();

            _channelFactory      = channelFactory;
            _routingKeys         = new List <string>();
            _lastMessageReceived = DateTime.MinValue;

            _timer = timer;
            _maxTimeBetweenMessages = maxTimeBetweenMessages;
            _timer.Elapsed         += OnTimerElapsed;
        }
        public ClientRuntimeChannel(ClientRuntime runtime, ContractDescription contract, TimeSpan openTimeout, TimeSpan closeTimeout, IChannel contextChannel, IChannelFactory factory, MessageVersion messageVersion, EndpointAddress remoteAddress, Uri via)
        {
            if (runtime == null)
            {
                throw new ArgumentNullException("runtime");
            }
            if (messageVersion == null)
            {
                throw new ArgumentNullException("messageVersion");
            }
            this.runtime        = runtime;
            this.remote_address = remoteAddress;
            if (runtime.Via == null)
            {
                runtime.Via = via ?? (remote_address != null ?remote_address.Uri : null);
            }
            this.contract         = contract;
            this.message_version  = messageVersion;
            default_open_timeout  = openTimeout;
            default_close_timeout = closeTimeout;
            _processDelegate      = new ProcessDelegate(Process);
            requestDelegate       = new RequestDelegate(Request);
            sendDelegate          = new SendDelegate(Send);

            // default values
            AllowInitializationUI = true;
            OperationTimeout      = TimeSpan.FromMinutes(1);

            if (contextChannel != null)
            {
                channel = contextChannel;
            }
            else
            {
                var method = factory.GetType().GetMethod("CreateChannel", new Type [] { typeof(EndpointAddress), typeof(Uri) });
                try
                {
                    channel      = (IChannel)method.Invoke(factory, new object [] { remote_address, Via });
                    this.factory = factory;
                }
                catch (TargetInvocationException ex)
                {
                    if (ex.InnerException != null)
                    {
                        throw ex.InnerException;
                    }
                    else
                    {
                        throw;
                    }
                }
            }
        }
Example #36
0
 public CompactSignatureSecurityChannelFactory(
     IChannelFactory <IDuplexChannel> innerChannelFactory,
     DiscoveryVersion discoveryVersion,
     X509Certificate2 signingCertificate,
     ReceivedCertificatesStoreSettings receivedCertificatesStoreSettings)
     : base()
 {
     this.signingCertificate = signingCertificate;
     this.receivedCertificatesStoreSettings = receivedCertificatesStoreSettings;
     this.InnerChannelFactory = innerChannelFactory;
     this.discoveryVersion    = discoveryVersion;
 }
Example #37
0
 public void CreateChannelWithoutOpen()
 {
     BindingContext ctx = new BindingContext(
         new CustomBinding(
             new HttpTransportBindingElement()),
         empty_params);
     // returns HttpChannelFactory
     IChannelFactory <IRequestChannel> f =
         ctx.BuildInnerChannelFactory <IRequestChannel> ();
     IChannel c = f.CreateChannel(new EndpointAddress(
                                      "http://www.mono-project.com"));
 }
Example #38
0
        public T CreateServiceFromFactory <T>(IChannelFactory <T> channelFactory)
            where T : class
        {
            var concreteChannelFactory = channelFactory as ChannelFactory <T>;

            if (concreteChannelFactory != null)
            {
                return(concreteChannelFactory.CreateChannel());
            }

            throw new InvalidOperationException("Invalid IChannelFactory type: " + channelFactory.GetType());
        }
Example #39
0
            public override void OnClose(TimeSpan timeout)
            {
                TimeoutHelper timeoutHelper = new TimeoutHelper(timeout);

                if (this.channelFactory != null && this.channelFactory.State == CommunicationState.Opened)
                {
                    this.channelFactory.Close(timeoutHelper.RemainingTime());
                    this.channelFactory = null;
                    CleanUpRsaSecurityTokenCache();
                    FreeCredentialsHandle();
                    base.OnClose(timeoutHelper.RemainingTime());
                }
            }
Example #40
0
		public TopologyProvider(IChannelFactory channelFactory)
		{
			_channelFactory = channelFactory;
			_initExchanges = new List<string>();
			_initQueues = new List<string>();
			_queueBinds = new List<string>();
			_topologyTasks = new ConcurrentQueue<ScheduledTopologyTask>();
			_disposeTimer = new Timer(state =>
			{
				_logger.LogInformation("Disposing topology channel (if exists).");
				_channel?.Dispose();
				_disposeTimer.Change(TimeSpan.FromHours(1), new TimeSpan(-1));
			}, null, TimeSpan.FromSeconds(2), new TimeSpan(-1));
		}
        public static void InitComm()
        {
            // set the machine name from the config
            machineName = Properties.Settings.Default.MachineName.Trim().ToUpper();

            // configure remoting
            RemotingConfiguration.Configure("net.xml", false);

            // get the name service
            WellKnownServiceTypeEntry[] wkst = RemotingConfiguration.GetRegisteredWellKnownServiceTypes();
            objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri);

            // get the channel factory
            channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory");
        }
Example #42
0
        internal override IPublisher OnCreatePublisher(PublisherConfigurator configuration)
        {
            if (_channelFactory == null)
            {
                object[] parameters = CreateParameters(configuration.BufferManager);

                _channelFactory = _binding.BuildChannelFactory<IOutputChannel>(parameters);

                _channelFactory.Open();
            }

            Uri toAddress = CreateUri();

            IKnownContractCollector collector = new KnownContractCollector();

            IOutputChannel outputChannel = _channelFactory.CreateChannel(new EndpointAddress(toAddress));

            return new Publisher(outputChannel, _binding.MessageVersion, collector, BusId);
        }
Example #43
0
        public void TestInitialize()
        {
            _ev = new ManualResetEvent(false);

            const string clientAddress = "amqp://localhost/amq.direct?routingKey=NoSuchRoute";

            _binding = new RabbitMQBinding
                {
                    OneWayOnly = true,
                    ApplicationId = "MyApp",
                    Mandatory = true
                };

            _channelFactory = _binding.BuildChannelFactory<IOutputChannel>(this);

            _channelFactory.Open();

            _outputChannel = _channelFactory.CreateChannel(new EndpointAddress(clientAddress)) as RabbitMQTransportOutputChannel;

            _outputChannel.Open();
        }
        public void RefreshList(IChannelFactory factory)
        {
            List<ListViewItem> removeItems = new List<ListViewItem>();
            foreach (ChannelListViewItem item in Items) {
                if (item.DynamicChannel) {
                    if (item.IsListening) {
                        item.StopListening();
                    }

                    removeItems.Add(item);
                }
            }

            foreach (ListViewItem item in removeItems) {
                Items.Remove(item);
            }

            ICollection<string> channels = null;
            try {
                channels = factory.Channels;
            }
            catch (Exception ex) {
                MessageBox.Show(this.FindForm(), "Could not get channels from channel factory:\n" + ex.Message, "Car Browser", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            List<ChannelListViewItem> items = new List<ChannelListViewItem>();
            foreach (string name in channels) {
                try {
                    IChannel channel = factory.GetChannel(name, ChannelMode.Bytestream);
                    ChannelListViewItem item = new ChannelListViewItem(channel, this);

                    items.Add(item);
                }
                catch (Exception) {
                }
            }

            Items.AddRange(items.ToArray());
        }
Example #45
0
 public ExchangeUpdater(IBindingProvider bindingProvider, IChannelFactory channelFactory)
 {
     _bindingProvider = bindingProvider;
     _channelFactory = channelFactory;
 }
 public SingleCallChannelForwarder(IChannelFactory channelFactory)
 {
     this.channelFactory = channelFactory;
 }
 public EventingBasicConsumerFactory(IChannelFactory channelFactory)
 {
     _channelFactory = channelFactory;
     _processedButNotAcked = new ConcurrentBag<string>();
     _consumers = new ConcurrentBag<IRawConsumer>();
 }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="registry"></param>
 /// <param name="channelFactory"></param>
 public void Initilize(IRegistry registry, IChannelFactory channelFactory)
 {
     Registry = registry;
     ChannelFactory = channelFactory;
 }
        /// <summary>
        /// Registers with the correct services
        /// </summary>
        public void Register()
        {
            // "Activate" the NameService singleton.
            objectDirectory = (ObjectDirectory)Activator.GetObject(typeof(ObjectDirectory), wkst[0].ObjectUri);

            // Retreive the directory of messaging channels
            channelFactory = (IChannelFactory)objectDirectory.Resolve("ChannelFactory");

            // Notify user of success
            RemoraOutput.WriteLine("Connection to Name Service Successful", OutputType.Remora);

            // get simulation if supposed to
            if (global::RemoraAdvanced.Properties.Settings.Default.SimMode)
            {
                this.simulatorFacade = (SimulatorFacade)objectDirectory.Resolve("SimulationServer");

                // Notify user of success
                RemoraOutput.WriteLine("Connection to Simulation Service Successful", OutputType.Remora);
            }
        }
 static WcfRoutingService()
 {
     BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
     _factory = binding.BuildChannelFactory<IRequestChannel>();
     _factory.Open();
 }
Example #51
0
        //Create the channel factory based on the Service Contracts selected by the user
        private void InitializeClient(Uri baseUri, Binding binding)
        {
            Log.Trace("Binding == " + binding.Name);
            Log.Trace("Initializing Clients ...");
            string uriString = baseUri.ToString();
            Log.Trace("Client Connecting to base Uri == " + baseUri);
            EndpointAddress epa;
            foreach (ServiceContract serviceContract in Parameters.ServiceContracts)
            {
                string addressString = serviceContract.ToString();
                switch (serviceContract)
                {
                    case ServiceContract.IAsyncOneWay:
                        epa = new EndpointAddress(uriString + addressString);
                        asyncOneWayChannelFactory = new ChannelFactory<IAsyncOneWay>(binding, epa);
                        break;

                    case ServiceContract.IAsyncSessionOneWay:
                        epa = new EndpointAddress(uriString + addressString);
                        asyncSessionOneWayChannelFactory = new ChannelFactory<IAsyncSessionOneWay>(binding, epa);
                        break;

                    case ServiceContract.IAsyncTwoWay:
                        epa = new EndpointAddress(uriString + addressString);
                        asyncTwoWayChannelFactory = new ChannelFactory<IAsyncTwoWay>(binding, epa);
                        break;

                    case ServiceContract.IAsyncSessionTwoWay:
                        epa = new EndpointAddress(uriString + addressString);
                        asyncSessionTwoWayChannelFactory = new ChannelFactory<IAsyncSessionTwoWay>(binding, epa);
                        break;

                    case ServiceContract.ISyncOneWay:
                        epa = new EndpointAddress(uriString + addressString);
                        syncOneWayChannelFactory = new ChannelFactory<ISyncOneWay>(binding, epa);
                        break;

                    case ServiceContract.ISyncSessionOneWay:
                        epa = new EndpointAddress(uriString + addressString);
                        syncSessionOneWayChannelFactory = new ChannelFactory<ISyncSessionOneWay>(binding, epa);
                        break;

                    case ServiceContract.ISyncTwoWay:
                        epa = new EndpointAddress(uriString + addressString);
                        syncTwoWayChannelFactory = new ChannelFactory<ISyncTwoWay>(binding, epa);
                        break;

                    case ServiceContract.ISyncSessionTwoWay:
                        epa = new EndpointAddress(uriString + addressString);
                        syncSessionTwoWayChannelFactory = new ChannelFactory<ISyncSessionTwoWay>(binding, epa);
                        break;

                    case ServiceContract.IDuplexContract:
                        epa = new EndpointAddress(uriString + addressString);
                        duplexChannelFactory = new DuplexChannelFactory<IDuplexContract>(cb, binding, epa);
                        break;

                    case ServiceContract.IDuplexSessionContract:
                        epa = new EndpointAddress(uriString + addressString);
                        duplexSessionChannelFactory = new DuplexChannelFactory<IDuplexSessionContract>(cb,binding, epa);
                        break;

                    default:
                        Log.Trace(serviceContract +  " type is not supported");
                        break;
                }
            }
        }
 public IdempotentChannelForwarder(IChannelFactory channelFactory)
 {
     this.channelFactory = channelFactory;
 }
Example #53
0
		protected OperatorBase(IChannelFactory channelFactory, IMessageSerializer serializer)
		{
			ChannelFactory = channelFactory;
			Serializer = serializer;
		}
 protected IContextChannel CreateProxy(IChannelFactory factory)
 {
     Type channelType = typeof(ChannelFactory<>).MakeGenericType(Endpoint.ContractType);
     return (IContextChannel)channelType.GetMethod("CreateChannel", new Type[] { }).Invoke(factory, new object[] { });
 }
 public TopologyProvider(IChannelFactory channelFactory)
 {
     _channelFactory = channelFactory;
     _initExchanges = new ConcurrentDictionary<string, Task>();
     _initQueues = new ConcurrentDictionary<string, Task>();
 }
 public IdempotentChannelReceiver(IChannelFactory channelFactory, IPersistMessages persister)
 {
     this.channelFactory = channelFactory;
     this.persister = persister;
 }
Example #57
0
 /// <summary>
 /// address or registry must provider one
 /// </summary>
 /// <param name="address"></param>
 /// <param name="registry"></param>
 /// <param name="channelFactory"></param>
 public DefaultInvoker(string address, IRegistry registry, IChannelFactory channelFactory)
 {
     _channelFactory = channelFactory;
     _address = address;
     _registry = registry;
 }
		public QueueingBaiscConsumerFactory(IChannelFactory channelFactory)
		{
			_channelFactory = channelFactory;
			_consumers = new ConcurrentBag<IRawConsumer>();
		}
        public void StartWCFService()
        {

            try
            {
                //host = new ServiceHost(typeof(ScannerEngine.ScannerClass), new Uri(MyEndpoint));
                {

                    MyScanneriChannel = new ChannelFactory<ScannerEngine.ScannerInterfaceDefinition>(bindbert);
                    host.AddServiceEndpoint(typeof(ScannerEngine.ScannerInterfaceDefinition), bindbert, MyEndpoint);

                    //Override the option that makes she work as IIS service
                    var behaviour =host.Description.Behaviors.Find<ServiceBehaviorAttribute>();
                    behaviour.UseSynchronizationContext = false;
                    behaviour.InstanceContextMode = InstanceContextMode.PerSession;
                    
                    

                    var huhn = host.Description.Behaviors.Find<ServiceBehaviorAttribute>().UseSynchronizationContext;


                    // Enable metadata exchange
                    ServiceMetadataBehavior smb = new ServiceMetadataBehavior() { HttpGetEnabled = false };
                    host.Description.Behaviors.Add(smb);
                    
                    // Enable exeption details
                    ServiceDebugBehavior sdb = host.Description.Behaviors.Find<ServiceDebugBehavior>();
                    sdb.IncludeExceptionDetailInFaults = true;
                   
                    host.Open();

                    
                }


            }
            catch (Exception ex)
            {
                host.Abort();
                MessageBox.Show("Error = " + ex.Message);
            }

        }
Example #60
0
 protected override void OnOpen(TimeSpan timeout)
 {
     _factory = base.CreateFactory();
     this.GetType().BaseType.InvokeMember("innerFactory", BindingFlags.SetField | BindingFlags.NonPublic | BindingFlags.Instance, null, this, new object[] { _factory }, CultureInfo.InvariantCulture);
     base.OnOpen(timeout);
 }