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); }
public MonitoringControlHandler(ILogger logger, Envelope envelope, ChannelGraph graph, IPersistentTaskController controller) { _logger = logger; _envelope = envelope; _graph = graph; _controller = controller; }
public Receiver(IHandlerPipeline pipeline, ChannelGraph graph, ChannelNode node) { _pipeline = pipeline; _graph = graph; _node = node; _address = node.Channel.Address; }
public ChannelGraphFubuDiagnostics(ChannelGraph graph, ISubscriptionCache cache, IEnumerable<ITransport> transports, IEnumerable<IMessageSerializer> serializers) { _graph = graph; _cache = cache; _transports = transports; _serializers = serializers; }
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; }); }
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); } }
public TransportActivator(ChannelGraph graph, IServiceLocator services, IHandlerPipeline pipeline, IEnumerable<ITransport> transports) { _graph = graph; _services = services; _pipeline = pipeline; _transports = transports; }
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(); }
public ScheduledJobsFubuDiagnostics(IUrlRegistry urls, ISchedulePersistence persistence, ChannelGraph graph, ScheduledJobGraph jobs, IScheduledJobController controller) { _urls = urls; _persistence = persistence; _graph = graph; _jobs = jobs; _controller = controller; }
public SubscriptionActivator(ISubscriptionRepository repository, IEnvelopeSender sender, ISubscriptionCache cache, IEnumerable<ISubscriptionRequirement> requirements, ChannelGraph graph) { _repository = repository; _sender = sender; _cache = cache; _requirements = requirements; _graph = graph; }
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; }
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; }
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); }
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"); }
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)); }
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"); }
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; }
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(); }
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); }
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)); }); }
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); }
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); }
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()); }
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); } }
public SubscriptionRequirements(T settings, ChannelGraph graph, IList <ISubscriptionRequirement <T> > requirements) { _settings = settings; _graph = graph; _requirements = requirements; }
public static Uri ReplyUriForGraph(ChannelGraph graph) { return("{0}://localhost/{1}/replies".ToFormat(InMemoryChannel.Protocol, graph.Name ?? "node").ToUri()); }
public SubscriptionRepository(ChannelGraph graph, ISubscriptionPersistence persistence) { _graph = graph; _persistence = persistence; }
protected abstract Uri getReplyUri(ChannelGraph graph);
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); }
public void Start(IHandlerPipeline pipeline, ChannelGraph channels) { }
public MessagingSession(ChannelGraph graph) { _graph = graph; }
public EnvelopeSender(ChannelGraph channels, IEnvelopeSerializer serializer, IBusLogger[] loggers) { _channels = channels; _serializer = serializer; Logger = BusLogger.Combine(loggers); }
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); } }
public EnvelopeSerializer(ChannelGraph graph, IEnumerable<IMessageSerializer> serializers) { _graph = graph; _serializers = serializers; }
internal ChannelExpression(ChannelGraph channels, ChannelNode node) { _channels = channels; _node = node; }
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; }
public ScheduledJobRecordModifier(ChannelGraph graph) { _graph = graph; }
public MessagesFubuDiagnostics(BehaviorGraph graph, ChannelGraph channels) { _graph = graph; }
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); } }