public LoopbackRabbitMqTransport(IRabbitMqEndpointAddress address, IInboundTransport inbound, IOutboundTransport outbound) { _inbound = inbound; _outbound = outbound; _address = address; }
public MessageTransactionDecorator( IMessageTransaction source, IOutboundTransport outbound, InboundTransportOptions options) { this.source = source; this.outbound = outbound; this.options = options; }
public RetryingInboundTransportDecorator( IInboundTransport inbound, IOutboundTransport outbound, InboundTransportOptions options) { this.inbound = inbound; this.outbound = outbound; this.options = options; }
void Dispose(bool disposing) { if (_disposed) return; if (disposing) { _inbound.Dispose(); _inbound = null; _outbound.Dispose(); _outbound = null; } _disposed = true; }
public Endpoint(EndpointAddress address, IInboundTransport inboundTransport, IOutboundTransport outboundTransport, IOutboundTransport errorTransport, IInboundPipeline inboundPipeline, IOutboundPipeline outboundPipeline, IOutboundPipeline errorPipeline) { this.address = address; this.inboundTransport = inboundTransport; this.outboundTransport = outboundTransport; this.errorTransport = errorTransport; this.inboundPipeline = inboundPipeline; this.outboundPipeline = outboundPipeline; this.errorPipeline = errorPipeline; }
public IEndpoint CreateEndpoint(ITransportFactory transportFactory) { try { IDuplexTransport transport = _transportFactory(transportFactory, _settings); IOutboundTransport errorTransport = _errorTransportFactory(transportFactory, _errorSettings); IInboundMessageTracker tracker = _messageTrackerFactory(); var endpoint = new Endpoint(transport.Address, _settings.Serializer, transport, errorTransport, tracker); return(endpoint); } catch (Exception ex) { throw new EndpointException(_uri, "Failed to create endpoint", ex); } }
void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { _transport.Dispose(); _transport = null; _errorTransport.Dispose(); _errorTransport = null; } _disposed = true; }
public IDuplexTransport BuildLoopback(ITransportSettings settings) { try { ITransportSettings msmqSettings = new TransportSettings(new MsmqEndpointAddress(settings.Address.Uri), settings); IInboundTransport inboundTransport = BuildInbound(settings); IOutboundTransport outboundTransport = BuildOutbound(settings); return(new Transport(msmqSettings.Address, () => inboundTransport, () => outboundTransport)); } catch (Exception ex) { throw new TransportException(settings.Address.Uri, "Failed to create MSMQ transport", ex); } }
public IDuplexTransport BuildLoopback(ITransportSettings settings) { try { var msmqEndpointAddress = new MsmqEndpointAddress(settings.Address.Uri, settings.Transactional, _defaultRecoverable); TransportSettings msmqSettings = GetTransportSettings(settings, msmqEndpointAddress); IInboundTransport inboundTransport = BuildInbound(settings); IOutboundTransport outboundTransport = BuildOutbound(settings); return(new Transport(msmqSettings.Address, () => inboundTransport, () => outboundTransport)); } catch (Exception ex) { throw new TransportException(settings.Address.Uri, "Failed to create MSMQ transport", ex); } }
public IDuplexTransport BuildLoopback(ITransportSettings settings) { try { if (settings.Transactional) { throw new TransportException(settings.Address.Uri, "Transactional support is not available for csharp-sqlite"); } IInboundTransport inboundTransport = BuildInbound(settings); IOutboundTransport outboundTransport = BuildOutbound(settings); return(new Transport(settings.Address, () => inboundTransport, () => outboundTransport)); } catch (Exception ex) { throw new TransportException(settings.Address.Uri, "Failed to create SqlLite transport", ex); } }
public bool Execute() { Uri uri = _uriString.ToUri("The from URI was invalid"); AbsolutePathName fullPath = PathName.GetAbsolutePathName(_name, Environment.CurrentDirectory); _log.DebugFormat("Using output path name: {0}", fullPath); string directoryName = Path.GetDirectoryName(fullPath.GetPath()); if (!System.IO.Directory.Exists(directoryName)) System.IO.Directory.CreateDirectory(directoryName); IOutboundTransport toTransport = Program.Transports.GetOutboundTransport(uri); ITextBlock text = new TextBlock() .BeginBlock("Load messages to URI: " + uri, ""); string[] files = System.IO.Directory.GetFiles(directoryName, fullPath.GetName() + "*.msg", SearchOption.TopDirectoryOnly) .OrderBy(x => x).ToArray(); int loadCount = 0; for (int i = 0; i < files.Length && loadCount < _count; i++) { string file = files[i]; string fileName = Path.Combine(directoryName, file); text.BodyFormat("Message File: {0}", file); ISendContext context = LoadMessageFromFile(fileName); toTransport.Send(context); if (_remove) System.IO.File.Delete(fileName); loadCount++; } _log.Info(text.ToString()); return true; }
public Endpoint([NotNull] IEndpointAddress address, [NotNull] IMessageSerializer serializer, [NotNull] IDuplexTransport transport, [NotNull] IOutboundTransport errorTransport, [NotNull] IInboundMessageTracker messageTracker, [NotNull] ISupportedMessageSerializers supportedSerializers) { if (address == null) { throw new ArgumentNullException("address"); } if (serializer == null) { throw new ArgumentNullException("serializer"); } if (transport == null) { throw new ArgumentNullException("transport"); } if (errorTransport == null) { throw new ArgumentNullException("errorTransport"); } if (messageTracker == null) { throw new ArgumentNullException("messageTracker"); } if (supportedSerializers == null) { throw new ArgumentNullException("supportedSerializers"); } _address = address; _errorTransport = errorTransport; _serializer = serializer; _tracker = messageTracker; _supportedSerializers = supportedSerializers; _transport = transport; _disposedMessage = string.Format("The endpoint has already been disposed: {0}", _address); }
public void EndpointSendAndReceive() { using (var management = new RabbitMqEndpointManagement(_queue)) { management.BindQueue(_queue.Name, _exchange.Name, ExchangeType.Fanout, "", null); } IMessageSerializer serializer = new XmlMessageSerializer(); var message = new BugsBunny { Food = "Carrot" }; IDuplexTransport transport = _factory.BuildLoopback(new TransportSettings(_exchange)); IOutboundTransport error = _factory.BuildError(new TransportSettings(_error)); var messageSerializers = new SupportedMessageSerializers(); messageSerializers.AddSerializer(serializer); var sendEndpoint = new Endpoint(_exchange, serializer, transport, error, new InMemoryInboundMessageTracker(5), messageSerializers); sendEndpoint.Send(message); var receiveEndpoint = new Endpoint(_queue, serializer, transport, error, new InMemoryInboundMessageTracker(5), messageSerializers); receiveEndpoint.Receive(o => { return(b => { var bb = (BugsBunny)b; Console.WriteLine(bb.Food); }); }, TimeSpan.Zero); }
void Dispose(bool disposing) { if (_disposed) { return; } if (disposing) { if (_inbound != null) { _inbound.Dispose(); _inbound = null; } if (_outbound != null) { _outbound.Dispose(); _outbound = null; } } _disposed = true; }
public void TransportSendAndReceive() { using (var management = new RabbitMqEndpointManagement(_queue)) { management.BindQueue(_queue.Name, _exchange.Name, ExchangeType.Fanout, "", null); } IOutboundTransport t = _factory.BuildOutbound(new TransportSettings(_exchange)); var context = new SendContext <string>("dru"); context.SetBodyWriter(stream => { byte[] buffer = Encoding.UTF8.GetBytes(context.Message); stream.Write(buffer, 0, buffer.Length); }); t.Send(context); IInboundTransport i = _factory.BuildInbound(new TransportSettings(_queue)); i.Receive(s => { return(ss => { string name; using (var stream = new MemoryStream()) { ss.CopyBodyTo(stream); name = Encoding.UTF8.GetString(stream.ToArray()); } Assert.AreEqual("dru", name); Console.WriteLine(name); }); }, 1.Minutes()); }
/// <summary> /// May throw a timeout exception if a message with the given id cannot be found. /// </summary> /// <param name="messageId"></param> public void ReturnMessageToSourceQueue(string messageId, IReceiveContext context) { try { var query = context.DestinationAddress.Query; var errorQueue = context.DestinationAddress.OriginalString.Replace(query, "") + "_error"; Uri fromUri = new Uri(errorQueue); Uri toUri = context.DestinationAddress; IInboundTransport fromTransport = Transports.GetInboundTransport(fromUri); IOutboundTransport toTransport = Transports.GetOutboundTransport(toUri); fromTransport.Receive(receiveContext => { if (receiveContext.MessageId == messageId) { return(ctx => { var moveContext = new MoveMessageSendContext(ctx); toTransport.Send(moveContext); }); } return(null); }, 5.Seconds()); Console.WriteLine("Success."); } catch (MessageQueueException ex) { if (ex.MessageQueueErrorCode == MessageQueueErrorCode.IOTimeout) { Console.WriteLine(NoMessageFoundErrorFormat, context.Id); foreach (var m in queue.GetAllMessages()) { var tm = TransportMessageHeaders.Create(m.Extension); if (tm[""] != null) { //if (messageId != tm[""]) // continue; Console.WriteLine("Found message - going to return to queue."); using (var tx = new TransactionScope()) { using (var q = new MessageQueue(new EndpointAddress(tm[""]).Path)) q.Send(m, MessageQueueTransactionType.Automatic); queue.ReceiveByLookupId(MessageLookupAction.Current, m.LookupId, MessageQueueTransactionType.Automatic); tx.Complete(); } Console.WriteLine("Success."); //scope.Complete(); return; } } } } //} }
public MessagingChainBuilder(IOutboundTransport outboundTransport, ILog log) { OutboundTransport = outboundTransport; Log = log; }
public MessageBus(ISubscriptionManager subscriptionManager, IOutboundTransport transport, ILoggerFactory loggerFactory) { this.subscriptionManager = subscriptionManager; this.transport = transport; this.logger = loggerFactory.GetLogger(typeof(MessageBus)); }
public Transport(IInboundTransport inbound, IOutboundTransport outbound) { _inbound = inbound; _outbound = outbound; }