コード例 #1
0
        public void reading_settings()
        {
            var channel = new ChannelSettings
            {
                Outbound = new Uri("channel://outbound"),
                Downstream = new Uri("channel://downstream")
            };

            var bus = new BusSettings
            {
                Outbound = new Uri("bus://outbound"),
                Downstream = new Uri("bus://downstream")
            };

            var services = new InMemoryServiceLocator();
            services.Add(channel);
            services.Add(bus);

            var graph = new ChannelGraph();
            graph.ChannelFor<ChannelSettings>(x => x.Outbound);
            graph.ChannelFor<ChannelSettings>(x => x.Downstream);
            graph.ChannelFor<BusSettings>(x => x.Outbound);
            graph.ChannelFor<BusSettings>(x => x.Downstream);

            graph.ReadSettings(services);

            graph.ChannelFor<ChannelSettings>(x => x.Outbound)
                 .Uri.ShouldBe(channel.Outbound);
            graph.ChannelFor<ChannelSettings>(x => x.Downstream)
                 .Uri.ShouldBe(channel.Downstream);
            graph.ChannelFor<BusSettings>(x => x.Outbound)
                .Uri.ShouldBe(bus.Outbound);
            graph.ChannelFor<BusSettings>(x => x.Downstream)
                .Uri.ShouldBe(bus.Downstream);
        }
コード例 #2
0
 public MonitoringControlHandler(ILogger logger, Envelope envelope, ChannelGraph graph, IPersistentTaskController controller)
 {
     _logger = logger;
     _envelope = envelope;
     _graph = graph;
     _controller = controller;
 }
コード例 #3
0
 public Receiver(IHandlerPipeline pipeline, ChannelGraph graph, ChannelNode node)
 {
     _pipeline = pipeline;
     _graph = graph;
     _node = node;
     _address = node.Channel.Address;
 }
コード例 #4
0
 public ChannelGraphFubuDiagnostics(ChannelGraph graph, ISubscriptionCache cache, IEnumerable<ITransport> transports, IEnumerable<IMessageSerializer> serializers)
 {
     _graph = graph;
     _cache = cache;
     _transports = transports;
     _serializers = serializers;
 }
コード例 #5
0
        public SubscriptionCache(ChannelGraph graph, IEnumerable<ITransport> transports)
        {
            if (!transports.Any())
            {
                throw new Exception(
                    "No transports are registered.  FubuTransportation cannot function without at least one ITransport");
            }

            _graph = graph;
            _transports = transports;

            _volatileNodes = new Cache<Uri, ChannelNode>(uri =>
            {
                var transport = _transports.FirstOrDefault(x => x.Protocol == uri.Scheme);
                if (transport == null)
                {
                    throw new UnknownChannelException(uri);
                }

                var node = new ChannelNode { Uri = uri, Key = uri.ToString() };
                node.Channel = transport.BuildDestinationChannel(node.Uri);

                return node;
            });
        }
コード例 #6
0
        public void create_from_graph_and_run_through_the_channel()
        {
            using (var graph = new ChannelGraph())
            {
                var node = graph.ChannelFor<BusSettings>(x => x.Outbound);

                node.Uri = new Uri("memory://foo");

                var transport = new InMemoryTransport();
                transport.OpenChannels(graph);
                node.Channel.ShouldNotBeNull();

                var envelope = new Envelope();
                envelope.CorrelationId = Guid.NewGuid().ToString();
                envelope.Headers["Foo"] = "Bar";
                envelope.Data = new byte[] { 1, 2, 3, 4, 5 };

                var receiver = new RecordingReceiver();

                node.StartReceiving(receiver);

                node.Channel.Send(envelope.Data, envelope.Headers);

                Wait.Until(() => receiver.Received.Any(), timeoutInMilliseconds: 2000);

                var received = receiver.Received.Single();

                received.CorrelationId.ShouldEqual(envelope.CorrelationId);
                received.ContentType.ShouldEqual(envelope.ContentType);
                received.Data.ShouldEqual(envelope.Data);

            }
        }
コード例 #7
0
 public TransportActivator(ChannelGraph graph, IServiceLocator services, IHandlerPipeline pipeline, IEnumerable<ITransport> transports)
 {
     _graph = graph;
     _services = services;
     _pipeline = pipeline;
     _transports = transports;
 }
コード例 #8
0
        protected override Uri getReplyUri(ChannelGraph graph)
        {
            var channelNode = graph.FirstOrDefault(x => x.Protocol() == LightningUri.Protocol && x.Incoming);
            if (channelNode == null)
                throw new InvalidOperationException("You must have at least one incoming Lightning Queue channel for accepting replies");

            return channelNode.Channel.Address.ToLocalUri();
        }
コード例 #9
0
 public ScheduledJobsFubuDiagnostics(IUrlRegistry urls, ISchedulePersistence persistence, ChannelGraph graph, ScheduledJobGraph jobs, IScheduledJobController controller)
 {
     _urls = urls;
     _persistence = persistence;
     _graph = graph;
     _jobs = jobs;
     _controller = controller;
 }
コード例 #10
0
 public SubscriptionActivator(ISubscriptionRepository repository, IEnvelopeSender sender, ISubscriptionCache cache, IEnumerable<ISubscriptionRequirement> requirements, ChannelGraph graph)
 {
     _repository = repository;
     _sender = sender;
     _cache = cache;
     _requirements = requirements;
     _graph = graph;
 }
コード例 #11
0
 public TransportActivator(ChannelGraph graph, IServiceLocator services, IHandlerPipeline pipeline, ILogger logger, IEnumerable<ITransport> transports, IEnumerable<IFubuTransportActivator> fubuTransportActivators)
 {
     _graph = graph;
     _services = services;
     _pipeline = pipeline;
     _logger = logger;
     _transports = transports;
     _fubuTransportActivators = fubuTransportActivators;
 }
コード例 #12
0
 public ServiceBusActivator(TransportActivator transports, SubscriptionActivator subscriptions, IScheduledJobController scheduledJobs, PollingJobActivator pollingJobs, TransportSettings settings, ChannelGraph graph)
 {
     _transports = transports;
     _subscriptions = subscriptions;
     _scheduledJobs = scheduledJobs;
     _pollingJobs = pollingJobs;
     _settings = settings;
     _graph = graph;
 }
コード例 #13
0
        public void SetUp()
        {
            messageSerializers = new IMessageSerializer[]
            {new BinarySerializer(), new BasicJsonMessageSerializer(), new XmlMessageSerializer()};
            theGraph = new ChannelGraph();
            theSerializer = new EnvelopeSerializer(theGraph, messageSerializers);

            theAddress = new Address {City = "Jasper", State = "Missouri"};
        }
        public void FixtureSetup()
        {
            FubuTransport.AllQueuesInMemory = true;

            theRuntime = FubuTransport.For(x => { }).StructureMap(new Container()).Bootstrap();
            graph = theRuntime.Factory.Get<ChannelGraph>();

            var uri = graph.ReplyChannelFor(InMemoryChannel.Protocol);
            theReplyNode = graph.Single(x => x.Channel.Address == uri);
        }
        public void SetUp()
        {
            theGraph = new ChannelGraph { Name = "FooNode" };

            var requirement = new GroupSubscriptionRequirement<BusSettings>(x => x.Upstream, x => x.Incoming);
            requirement.AddType(typeof(FooMessage));
            requirement.AddType(typeof(BarMessage));

            theSubscriptions = requirement.Determine(theSettings, theGraph);
        }
コード例 #16
0
        public void channel_for_by_accessor()
        {
            var graph = new ChannelGraph();
            var channelNode = graph.ChannelFor<ChannelSettings>(x => x.Outbound);
            channelNode
                 .ShouldBeTheSameAs(graph.ChannelFor<ChannelSettings>(x => x.Outbound));

            channelNode.Key.ShouldBe("Channel:Outbound");
            channelNode.SettingAddress.Name.ShouldBe("Outbound");
        }
コード例 #17
0
ファイル: TransportBase.cs プロジェクト: DarthFubuMVC/fubumvc
        public void OpenChannels(ChannelGraph graph)
        {
            var nodes = graph.NodesForProtocol(Protocol).ToArray();

            if (Disabled(nodes)) return;

            nodes.OrderByDescending(x => x.Incoming).Each(x => x.Channel = buildChannel(x));
            seedQueues(nodes);

            graph.AddReplyChannel(Protocol, getReplyUri(graph));
        }
コード例 #18
0
        public void blow_up_if_no_reply_channels()
        {
            var graph = new ChannelGraph
            {
                NodeId = "Foo@Bar"

            };

            Exception<InvalidOperationException>.ShouldBeThrownBy(() => {
                new TransportNode(graph);
            }).Message.ShouldEqual("At least one reply channel is required");
        }
コード例 #19
0
ファイル: TransportNode.cs プロジェクト: kingreatwill/fubumvc
        public TransportNode(ChannelGraph graph)
        {
            NodeName = graph.Name;

            Addresses = graph.ReplyUriList().ToArray();

            if (!Addresses.Any())
            {
                throw new InvalidOperationException("At least one reply channel is required");
            }

            MachineName = System.Environment.MachineName;
            Id = graph.NodeId;
        }
コード例 #20
0
        public PersistentTaskController(ChannelGraph graph, ILogger logger, ITaskMonitoringSource factory, IList<IPersistentTaskSource> sources)
        {
            _graph = graph;
            _logger = logger;
            _factory = factory;
            sources.Each(x => _sources[x.Protocol] = x);

            _agents.OnMissing = uri => {
                var persistentTask = FindTask(uri);
                return persistentTask == null ? null : _factory.BuildAgentFor(persistentTask);
            };

            _permanentTasks = sources.SelectMany(x => x.PermanentTasks()).ToArray();
        }
コード例 #21
0
        public void build_with_channel_graph_sets_the_id_to_the_node_id()
        {
            var graph = new ChannelGraph
            {
                NodeId = "Foo@Bar"

            };

            graph.AddReplyChannel(InMemoryChannel.Protocol, "memory://localhost/replies".ToUri());

            var node = new TransportNode(graph);

            node.Id.ShouldEqual(graph.NodeId);
        }
コード例 #22
0
        public ChannelsTableTag(ChannelGraph graph)
        {
            AddClass("table");
            AddClass("channels");

            AddHeaderRow(row => {
                row.Header("Description");
                row.Header("Incoming Scheduler");
                row.Header("Routing Rules");
            });

            graph.OrderBy(x => x.Key).Each(channel => {
                AddBodyRow(row => addRow(row, channel));
            });
        }
コード例 #23
0
        public void SetUp()
        {
            theGraph = new ChannelGraph { Name = "FooNode" };

            var requirement = new LocalSubscriptionRequirement<BusSettings>(x => x.Upstream);
            requirement.AddType(typeof(FooMessage));
            requirement.AddType(typeof(BarMessage));

            theLocalReplyUri = InMemoryTransport.ReplyUriForGraph(theGraph);

            theGraph.AddReplyChannel("Fake2", "fake2://2".ToUri());
            theGraph.AddReplyChannel(InMemoryChannel.Protocol, theLocalReplyUri);
            theGraph.AddReplyChannel("Fake1", "fake1://1".ToUri());

            theSubscriptions = requirement.Determine(theSettings, theGraph);
        }
コード例 #24
0
        private void SetupTransport(string uri, ChannelMode mode)
        {
            graph = new ChannelGraph();
            node = graph.ChannelFor<ChannelSettings>(x => x.Upstream);
            node.Mode = mode;

            node.Uri = new Uri(uri);
            node.Incoming = true;

            var delayedCache = new DelayedMessageCache<MessageId>();
            queues = new PersistentQueues(new RecordingLogger());
            queues.ClearAll();
            transport = new LightningQueuesTransport(queues, new LightningQueueSettings());

            transport.OpenChannels(graph);
        }
コード例 #25
0
        public void create_a_transport_node_from_a_channel_graph()
        {
            var graph = new ChannelGraph
            {
                Name = "Service1"
            };

            graph.AddReplyChannel("memory", "memory://replies".ToUri());
            graph.AddReplyChannel("foo", "foo://replies".ToUri());
            graph.AddReplyChannel("bar", "bar://replies".ToUri());

            var node = new TransportNode(graph);

            node.NodeName.ShouldEqual("Service1");

            node.Addresses.OrderBy(x => x.ToString()).ShouldHaveTheSameElementsAs("bar://replies".ToUri(), "foo://replies".ToUri(), "memory://replies".ToUri());
        }
コード例 #26
0
        public void can_be_used_after_clearing_all_messages()
        {
            using (var graph = new ChannelGraph())
            {
                var node = graph.ChannelFor<BusSettings>(x => x.Outbound);
                node.Uri = new Uri("memory://foo");

                var transport = new InMemoryTransport();
                transport.OpenChannels(graph);

                var receiver = new RecordingReceiver();
                node.StartReceiving(receiver);

                node.Channel.Send(new byte[] { 1, 2 }, new NameValueHeaders());

                transport.ClearAll();

                node.Channel.Send(new byte[] { 3, 4 }, new NameValueHeaders());

                Wait.Until(() => receiver.Received.Count == 2);
                receiver.Received.ShouldHaveCount(2);
            }
        }
コード例 #27
0
 public SubscriptionRequirements(T settings, ChannelGraph graph, IList <ISubscriptionRequirement <T> > requirements)
 {
     _settings     = settings;
     _graph        = graph;
     _requirements = requirements;
 }
コード例 #28
0
 public static Uri ReplyUriForGraph(ChannelGraph graph)
 {
     return("{0}://localhost/{1}/replies".ToFormat(InMemoryChannel.Protocol, graph.Name ?? "node").ToUri());
 }
コード例 #29
0
 public SubscriptionRepository(ChannelGraph graph, ISubscriptionPersistence persistence)
 {
     _graph = graph;
     _persistence = persistence;
 }
コード例 #30
0
ファイル: TransportBase.cs プロジェクト: RyanHauert/fubumvc
 protected abstract Uri getReplyUri(ChannelGraph graph);
コード例 #31
0
 public SubscriptionRepository(ChannelGraph graph, ISubscriptionPersistence persistence)
 {
     _graph       = graph;
     _persistence = persistence;
 }
コード例 #32
0
        public void SetUp()
        {
            persistence = new InMemorySubscriptionPersistence();
            channelGraph = new ChannelGraph{Name = TheNodeName};
            channelGraph.AddReplyChannel("foo", "foo://replies".ToUri());
            channelGraph.AddReplyChannel("bar", "bar://replies".ToUri());

            theRepository = new SubscriptionRepository(channelGraph, persistence);
        }
コード例 #33
0
ファイル: StubTransport.cs プロジェクト: randommuses/jasper
 public void Start(IHandlerPipeline pipeline, ChannelGraph channels)
 {
 }
コード例 #34
0
 public MessagingSession(ChannelGraph graph)
 {
     _graph = graph;
 }
コード例 #35
0
 public EnvelopeSender(ChannelGraph channels, IEnvelopeSerializer serializer, IBusLogger[] loggers)
 {
     _channels   = channels;
     _serializer = serializer;
     Logger      = BusLogger.Combine(loggers);
 }
コード例 #36
0
        public async Task Activate(HandlerGraph handlers, CapabilityGraph capabilities, JasperRuntime runtime, ChannelGraph channels, LocalWorkerSender localWorker)
        {
            var capabilityCompilation = capabilities.Compile(handlers, _serialization, channels, runtime, _transports, _lookups);

            var transports = _transports.Where(x => _settings.StateFor(x.Protocol) != TransportState.Disabled)
                             .ToArray();

            _settings.Workers.Compile(handlers.Chains.Select(x => x.MessageType));

            localWorker.Start(_persistence, _workerQueue);

            if (!_settings.DisableAllTransports)
            {
                await _settings.ApplyLookups(_lookups);

                channels.Start(_settings, transports, _lookups, capabilities, _logger);


                scheduledJobs.Start(_workerQueue);
            }

            runtime.Capabilities = await capabilityCompilation;
            if (runtime.Capabilities.Errors.Any() && _settings.ThrowOnValidationErrors)
            {
                throw new InvalidSubscriptionException(runtime.Capabilities.Errors);
            }
        }
コード例 #37
0
 public EnvelopeSerializer(ChannelGraph graph, IEnumerable<IMessageSerializer> serializers)
 {
     _graph = graph;
     _serializers = serializers;
 }
コード例 #38
0
 internal ChannelExpression(ChannelGraph channels, ChannelNode node)
 {
     _channels = channels;
     _node     = node;
 }
コード例 #39
0
 public SubscriptionActivator(ISubscriptionRepository repository, IEnvelopeSender sender, ISubscriptionCache cache, IEnumerable <ISubscriptionRequirement> requirements, ChannelGraph graph,
                              TransportSettings settings)
 {
     _repository   = repository;
     _sender       = sender;
     _cache        = cache;
     _requirements = requirements;
     _graph        = graph;
     _settings     = settings;
 }
コード例 #40
0
 public ScheduledJobRecordModifier(ChannelGraph graph)
 {
     _graph = graph;
 }
コード例 #41
0
 public MessagesFubuDiagnostics(BehaviorGraph graph, ChannelGraph channels)
 {
     _graph = graph;
 }
コード例 #42
0
        public void start_receiving()
        {
            using (var graph = new ChannelGraph())
            {
                var node1 = graph.ChannelFor<ChannelSettings>(x => x.Upstream);
                var node2 = graph.ChannelFor<ChannelSettings>(x => x.Downstream);
                var node3 = graph.ChannelFor<BusSettings>(x => x.Upstream);
                var node4 = graph.ChannelFor<BusSettings>(x => x.Downstream);

                node1.Incoming = true;
                node2.Incoming = false;
                node3.Incoming = true;
                node4.Incoming = false;

                graph.Each(x => x.Channel = new FakeChannel());

                graph.StartReceiving(MockRepository.GenerateMock<IHandlerPipeline>(), new RecordingLogger());

                node1.Channel.As<FakeChannel>().ReceivedCount.ShouldBeGreaterThan(0);
                node2.Channel.As<FakeChannel>().ReceivedCount.ShouldBe(0);
                node3.Channel.As<FakeChannel>().ReceivedCount.ShouldBeGreaterThan(0);
                node4.Channel.As<FakeChannel>().ReceivedCount.ShouldBe(0);
            }
        }