protected AbstractMsmqListener(
            IQueueStrategy queueStrategy,
            Uri endpoint,
            int threadCount,
            IMessageSerializer messageSerializer,
            IEndpointRouter endpointRouter,
            TransactionalOptions transactional,
            IMessageBuilder<Message> messageBuilder)
        {
            this.queueStrategy = queueStrategy;
            this.messageSerializer = messageSerializer;
            this.endpointRouter = endpointRouter;
            this.endpoint = endpoint;

            this.threadCount = threadCount;
            threads = new Thread[threadCount];

            switch (transactional)
            {
                case TransactionalOptions.Transactional:
                    this.transactional = true;
                    break;
                case TransactionalOptions.NonTransactional:
                    this.transactional = false;
                    break;
                case TransactionalOptions.FigureItOut:
                    this.transactional = null;
                    break;
                default:
                    throw new ArgumentOutOfRangeException("transactional");
            }
            this.messageBuilder = messageBuilder;
            this.messageBuilder.Initialize(Endpoint);
        }
 public AsyncProcessingNetChannel(Func<IMessageProcessingPipeBuilder, IMessageProcessingPipeBuilder> configureProcesssingPipe, INetNode node,
     ITransportChannel transportChannel, IMessageSerializer serializer, ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool)
     : base(node, transportChannel, serializer, logger, config, bufferPool)
 {
     _pipeBuilder = configureProcesssingPipe(new MessageProcessingPipeBuilder());
     _processor = _pipeBuilder.Build();
 }
        public RhinoFilesTransport(Uri endpoint,
            IEndpointRouter endpointRouter,
            IMessageSerializer messageSerializer,
            int threadCount,
            string path,
            IsolationLevel queueIsolationLevel,
            int numberOfRetries,
            bool enablePerformanceCounters,
            IMessageBuilder<MessagePayload> messageBuilder,
            QueueManagerConfiguration queueManagerConfiguration)
        {
            _endpoint = endpoint;
            _queueIsolationLevel = queueIsolationLevel;
            _numberOfRetries = numberOfRetries;
            _enablePerformanceCounters = enablePerformanceCounters;
            _messageBuilder = messageBuilder;
            _queueManagerConfiguration = queueManagerConfiguration;
            _endpointRouter = endpointRouter;
            _messageSerializer = messageSerializer;
            _threadCount = threadCount;
            _path = path;

            _queueName = endpoint.GetQueueName();

            _threads = new Thread[threadCount];

            // This has to be the first subscriber to the transport events in order to successfully handle the errors semantics
            new ErrorAction(numberOfRetries).Init(this);
            messageBuilder.Initialize(Endpoint);
        }
        private Func<RogerEndpoint, IBasicProperties> CreatePropertiesFactory(IModel model,
            IIdGenerator idGenerator,
            IMessageTypeResolver messageTypeResolver,
            IMessageSerializer serializer,
            ISequenceGenerator sequenceGenerator)
        {
            var properties = model.CreateBasicProperties();

            properties.MessageId = idGenerator.Next();
            properties.Type = messageTypeResolver.Unresolve(messageType);
            properties.ContentType = serializer.ContentType;

            properties.Headers = new Hashtable
            {
                {Headers.Sequence, BitConverter.GetBytes(sequenceGenerator.Next(messageType))}
            };

            if (persistent)
                properties.DeliveryMode = 2;

            FillAdditionalProperties(properties, idGenerator);

            return endpoint =>
            {
                properties.ReplyTo = endpoint;
                return properties;
            };
        }
 public PublishSendEndpointProvider(IMessageSerializer serializer, Uri sourceAddress, IServiceBusHost[] hosts)
 {
     _hosts = hosts;
     _sourceAddress = sourceAddress;
     _serializer = serializer;
     _sendObservable = new SendObservable();
 }
Exemple #6
0
        public CLogMessage(
            IMessageSerializer messageSerializer,

            DateTime timeStamp,
            LogMessageCategoryEnum messageCategory,
            bool isException,
            bool isRootMessage,
            string source,
            string message,
            string messageStackTrace,
            string exceptionStackTrace,

            ILogMessage childMessage
            )
        {
            if (messageSerializer == null)
            {
                throw new ArgumentNullException("messageSerializer");
            }
            //childMessage allowed to be null

            _messageSerializer = messageSerializer;

            _timeStamp = timeStamp;
            _messageCategory = messageCategory;
            _isException = isException;
            _isRootMessage = isRootMessage;
            _source = source;
            _message = message.CrLnNormalize();
            _messageStackTrace = messageStackTrace.CrLnNormalize();
            _exceptionStackTrace = exceptionStackTrace.CrLnNormalize();

            _childMessage = childMessage;
        }
        private void Time(IMessage[] messages, IMessageSerializer serializer) {
            Stopwatch watch = new Stopwatch();
            watch.Start();

            for (int i = 0; i < numberOfIterations; i++)
                using (MemoryStream stream = new MemoryStream())
                    serializer.Serialize(messages, stream);

            watch.Stop();
            Debug.WriteLine("Serializing: " + watch.Elapsed);

            watch.Reset();

            MemoryStream s = new MemoryStream();
            serializer.Serialize(messages, s);
            byte[] buffer = s.GetBuffer();
            s.Dispose();
            Console.WriteLine(Encoding.ASCII.GetString(buffer));

            watch.Start();

            object[] result = null;

            for (int i = 0; i < numberOfIterations; i++)
                using (var forDeserializing = new MemoryStream(buffer))
                    result = serializer.Deserialize(forDeserializing);

            watch.Stop();
            Debug.WriteLine("Deserializing: " + watch.Elapsed);
        }
 public RabbitMqSendEndpointProvider(IMessageSerializer serializer, Uri inputAddress, ISendTransportProvider transportProvider)
 {
     _inputAddress = inputAddress;
     _transportProvider = transportProvider;
     _serializer = serializer;
     _sendObservable = new SendObservable();
 }
        public RhinoQueuesOneWayBus(MessageOwner[] messageOwners, IMessageSerializer messageSerializer, string path, bool enablePerformanceCounters, IMessageBuilder<MessagePayload> messageBuilder, QueueManagerConfiguration queueManagerConfiguration)
            : base(NullEndpoint, new EndpointRouter(), messageSerializer, 1, path, IsolationLevel.ReadCommitted, 5, enablePerformanceCounters, messageBuilder, queueManagerConfiguration)

        {
            this.messageOwners = new MessageOwnersSelector(messageOwners, new EndpointRouter());
            Start();
        }
        protected override void Initialize(IMessageSerializer messageSerializer)
        {
            try
            {
                this.socket = new ClientWebSocket();
                this.socket.ConnectAsync(new Uri(serverUrl), CancellationToken.None).Wait();
            }
            catch (AggregateException ex)
            {
                var wsException= ex.InnerExceptions.FirstOrDefault() as WebSocketException;
                if (wsException != null)
                {
                    Logger.Write(LogLevel.Warning,
                        string.Format("Failed to connect to WebSocket server. Error was '{0}'", wsException.Message));
                   
                }

                throw;
            }
            
            this.inputStream = new ClientWebSocketStream(socket);
            this.outputStream = new ClientWebSocketStream(socket);

            // Set up the message reader and writer
            this.MessageReader =
                new MessageReader(
                    this.inputStream,
                    messageSerializer);

            this.MessageWriter =
                new MessageWriter(
                    this.outputStream,
                    messageSerializer);
        }
 public ServiceBusSendEndpointProvider(IMessageSerializer serializer, Uri sourceAddress, ISendTransportProvider transportProvider)
 {
     _transportProvider = transportProvider;
     _sourceAddress = sourceAddress;
     _serializer = serializer;
     _sendObservable = new SendObservable();
 }
Exemple #12
0
 public MsmqTransport(IMessageSerializer serializer, IQueueStrategy queueStrategy, Uri endpoint, int threadCount, IMsmqTransportAction[] transportActions, IEndpointRouter endpointRouter, IsolationLevel queueIsolationLevel, TransactionalOptions transactional, bool consumeInTransaction)
     : base(queueStrategy, endpoint, threadCount, serializer, endpointRouter, transactional)
 {
     this.transportActions = transportActions;
     this.queueIsolationLevel = queueIsolationLevel;
     this.consumeInTransaction = consumeInTransaction;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="MicroMessageDecoder" /> class.
 /// </summary>
 /// <param name="serializer">The serializer used to decode the message that is being transported with MicroMsg.</param>
 /// <exception cref="System.ArgumentNullException">serializer</exception>
 public MicroMessageDecoder(IMessageSerializer serializer)
 {
     if (serializer == null) throw new ArgumentNullException("serializer");
     _serializer = serializer;
     _bytesLeftForCurrentState = sizeof(short);
     _stateMethod = ReadHeaderLength;
 }
		public TibcoMessageSelector(TibcoEndpoint endpoint, Session session, Message transportMessage, IMessageSerializer serializer)
		{
			_endpoint = endpoint;
			_session = session;
			_transportMessage = transportMessage;
			_serializer = serializer;
		}
        public void Arrived_Error_Will_Retry_Number_Of_Times_Configured()
        {
            var serviceLocator = new CastleServiceLocator(new WindsorContainer());
            messageSerializer = new XmlMessageSerializer(new DefaultReflection(), serviceLocator);
            transport = new RhinoQueuesTransport(
                new Uri("rhino.queues://localhost:23456/q"),
                new EndpointRouter(),
                messageSerializer,
                1,
                "test.esent",
                IsolationLevel.Serializable,
                5,
                false,
                new RhinoQueuesMessageBuilder(messageSerializer, serviceLocator)
                );
            transport.Start();
            var count = 0;
            transport.MessageArrived += info =>
            {
                throw new InvalidOperationException();
            };
            transport.MessageProcessingFailure += (messageInfo, ex) =>
            {
                count++;
            };
            transport.Send(transport.Endpoint, new object[] { "test" });

            wait.WaitOne(TimeSpan.FromSeconds(5));

            Assert.Equal(5, count);
        }
 /// <summary>
 ///     Initializes a new instance of the <see cref="MicroMessageClient" /> class.
 /// </summary>
 /// <param name="serializer">The serializer.</param>
 public MicroMessageClient(IMessageSerializer serializer)
 {
     _decoder = new MicroMessageDecoder(serializer);
     _encoder = new MicroMessageEncoder(serializer);
     _decoder.MessageReceived = OnMessageReceived;
     _args.Completed += OnConnect;
 }
 public static IEndpoint New(IMsmqEndpointAddress address, IMessageSerializer serializer)
 {
     return New(new CreateMsmqEndpointSettings(address)
         {
             Serializer = serializer,
         });
 }
 public ChatClientNetChannel(IActorSystem<IRoomActor> rooms, ICallbacksGatewayNode callbacksNode, INetNode node,  
     ITransportChannel transportChannel, IMessageSerializer serializer, ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool) 
     : base(node, transportChannel, serializer, logger, config, bufferPool)
 {
     _rooms = rooms;
     _callbacksNode = callbacksNode;
 }
 public DefaultAsyncEventPublisher(ISubscriptionStore subscriptionStore, IMessageTransport messageTransport, IMessageSerializer messageSerializer, ILoggerFactory loggerFactory)
 {
     _subscriptionStore = subscriptionStore;
     _messageTransport = messageTransport;
     _messageSerializer = messageSerializer;
     _logger = loggerFactory.Create("EventSourcing.DefaultAsyncEventPublisher");
 }
        public static void SendMessage(byte[] data, HostInfo hostInfo, IMessageSerializer messageSerializer)
        {
            //IPHostEntry hostEntry = Dns.GetHostEntry(hostInfo.Hostname);
            //IPEndPoint endPoint = new IPEndPoint(hostEntry.AddressList[0], hostInfo.Port);

            //Socket s = new Socket(endPoint.Address.AddressFamily, SocketType.Dgram, ProtocolType.Udp);
            //s.SendTo(data, endPoint);
            //s.Close();

            short netProtocolType = IPAddress.HostToNetworkOrder(messageSerializer.ProtocolType);
            short netProtocolVersion = IPAddress.HostToNetworkOrder(messageSerializer.ProtocolVersion);
            int netMessageLength = IPAddress.HostToNetworkOrder(data.Length);

            byte[] netProtocolTypeData = BitConverter.GetBytes(netProtocolType);
            byte[] netProtocolVersionData = BitConverter.GetBytes(netProtocolVersion);
            byte[] netMessageLengthData = BitConverter.GetBytes(netMessageLength);

            byte[] mergedData = new byte[netProtocolTypeData.Length + netProtocolVersionData.Length + netMessageLengthData.Length + data.Length];

            // Header
            Array.Copy(netProtocolTypeData, 0, mergedData, 0, netProtocolTypeData.Length);
            Array.Copy(netProtocolVersionData, 0, mergedData, netProtocolTypeData.Length, netProtocolVersionData.Length);
            Array.Copy(netMessageLengthData, 0, mergedData, netProtocolTypeData.Length + netProtocolVersionData.Length, netMessageLengthData.Length);
            // Data
            Array.Copy(data, 0, mergedData, netProtocolTypeData.Length + netProtocolVersionData.Length + netMessageLengthData.Length, data.Length);

            UdpClient client = new UdpClient();
            client.Send(mergedData, mergedData.Length, hostInfo.Hostname, hostInfo.Port);
            client.Close();
        }
        public RhinoQueuesTransport(
            Uri endpoint,
            IEndpointRouter endpointRouter,
            IMessageSerializer messageSerializer,
            int threadCount,
            string path,
            IsolationLevel queueIsolationLevel,
            int numberOfRetries)
        {
            this.endpoint = endpoint;
            this.queueIsolationLevel = queueIsolationLevel;
            this.numberOfRetries = numberOfRetries;
            this.endpointRouter = endpointRouter;
            this.messageSerializer = messageSerializer;
            this.threadCount = threadCount;
            this.path = path;

            queueName = endpoint.GetQueueName();

            threads = new Thread[threadCount];

            // This has to be the first subscriber to the transport events
            // in order to successfuly handle the errors semantics
            new ErrorAction(numberOfRetries).Init(this);
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="MicroMessageEncoder" /> class.
        /// </summary>
        /// <param name="serializer">Serialiser used to serialize the messages that should be sent. You might want to pick a serializer which is reasonable fast.</param>
        public MicroMessageEncoder(IMessageSerializer serializer)
        {
            if (serializer == null) throw new ArgumentNullException("serializer");

            _serializer = serializer;
            _bufferSlice = new BufferSlice(new byte[65535], 0, 65535);
        }
 public ActorRuntimeMock(IMessageSerializer serializer = null)
 {
     System      = new ActorSystemMock(serializer);
     Timers      = new TimerServiceMock();
     Reminders   = new ReminderServiceMock();
     Activation  = new ActivationServiceMock();
 }
        public SqlQueuesTransport(Uri queueEndpoint,
            IEndpointRouter endpointRouter,
            IMessageSerializer messageSerializer,
            int threadCount,
            string connectionString,
            int numberOfRetries,
            IMessageBuilder<MessagePayload> messageBuilder)
        {
            this.queueEndpoint = queueEndpoint;
            this.numberOfRetries = numberOfRetries;
            this.messageBuilder = messageBuilder;
            this.endpointRouter = endpointRouter;
            this.messageSerializer = messageSerializer;
            this.threadCount = threadCount;
            this.connectionString = connectionString;

            queueName = queueEndpoint.GetQueueName();

            threads = new Thread[threadCount];

            // This has to be the first subscriber to the transport events
            // in order to successfuly handle the errors semantics
            new ErrorAction(numberOfRetries).Init(this);
            messageBuilder.Initialize(Endpoint);
        }
 public ActiveMqMessageMapper(IMessageSerializer serializer, IMessageTypeInterpreter messageTypeInterpreter, IActiveMqMessageEncoderPipeline encoderPipeline, IActiveMqMessageDecoderPipeline decoderPipeline)
 {
     this.serializer = serializer;
     this.messageTypeInterpreter = messageTypeInterpreter;
     this.encoderPipeline = encoderPipeline;
     this.decoderPipeline = decoderPipeline;
 }
        public MessageLoggingTests()
        {
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "log_endpoint.esent");
            if (Directory.Exists(path))
                Directory.Delete(path, true);

            container = new WindsorContainer();
            new RhinoServiceBusConfiguration()
                .UseCastleWindsor(container)
                .UseStandaloneConfigurationFile("RhinoQueues/RhinoQueues.config")
                .Configure();
            container.Register(Component.For<MessageLoggingModule>());

            messageSerializer = container.Resolve<IMessageSerializer>();
            queue = new QueueManager(new IPEndPoint(IPAddress.Any, 2202), path);
            queue.CreateQueues("log_endpoint");
            queue.Start();
            

            var innerTransport = container.Resolve<ITransport>();
            innerTransport.Start();
            transport = MockRepository.GenerateStub<ITransport>();
            transport.Stub(t => t.Send(null, null)).IgnoreArguments()
                .Do((Delegates.Action<Endpoint, object[]>)(innerTransport.Send));
        }
 public SqlServerTransport(string listenerQueue, ISqlServerTransactionWrapper transactionWrapper, IMessageSerializer transportMessageSerializer, int initialNumberOfWorkThreads = 1)
 {
     this.ListenerQueue = listenerQueue.Trim();
     this.TransactionWrapper = transactionWrapper;
     this.MessageSerializer = transportMessageSerializer;
     this.numberOfWorkerThreads = initialNumberOfWorkThreads;
 }
 /// <summary>
 ///     Initializes a new instance of the <see cref="MicroMessageClient" /> class.
 /// </summary>
 /// <param name="serializer">The serializer.</param>
 /// <param name="sslStreamBuilder">The SSL stream builder.</param>
 public MicroMessageClient(IMessageSerializer serializer, ClientSideSslStreamBuilder sslStreamBuilder)
 {
     _sslStreamBuilder = sslStreamBuilder;
     _decoder = new MicroMessageDecoder(serializer);
     _encoder = new MicroMessageEncoder(serializer);
     _decoder.MessageReceived = OnMessageReceived;
     _args.Completed += OnConnect;
 }
 public void Setup()
 {
     var types = new List<Type> { typeof(Sample_Message) };
     var mapper = new MessageMapper();
     mapper.Initialize(types);
     serializer = new XmlMessageSerializer(mapper);
     ((XmlMessageSerializer)serializer).Initialize(types);
 }
Exemple #30
0
		public PublicationTests()
		{
			_serializer = new JsonMessageSerializer();
			_blobStorage = new InMemoryBlobStorage();
			_mapper = new InMemoryRecordMapper<FakePublicationRecord>();
			_publicationRegistry = new FakeRegistry(_mapper, _blobStorage, _serializer);
			_channel = new InMemoryMessageChannel();
		}
Exemple #31
0
 public void Register <T>(IMessageSerializer <T> messageSerializer) where T : MessageBase
 {
     _serializers[typeof(T).TypeHandle] = messageSerializer;
 }
Exemple #32
0
 public SerializeMessageConnector(IMessageSerializer messageSerializer, MessageMetadataRegistry messageMetadataRegistry)
 {
     this.messageSerializer       = messageSerializer;
     this.messageMetadataRegistry = messageMetadataRegistry;
 }
 public void Init(ITransportChannel channel, IMessageSerializer serializer, ICoreEvents logger, INetNodeConfig config, IBufferPool bufferPool)
 {
     throw new NotSupportedException();
 }
Exemple #34
0
        public ServiceClient(string serviceName, IMessageDispatcher messageDispatcher, IMessageSerializer messageSerializer)
        {
            if (string.IsNullOrWhiteSpace(serviceName))
            {
                throw new ArgumentException("Argument cannot be empty!", nameof(serviceName));
            }

            if (null == messageDispatcher)
            {
                throw new ArgumentNullException(nameof(messageDispatcher));
            }

            if (null == messageSerializer)
            {
                throw new ArgumentNullException(nameof(messageSerializer));
            }

            ServiceName        = serviceName;
            _messageDispatcher = messageDispatcher;
            _messageSerializer = messageSerializer;
            _uniqueId          = _messageDispatcher.GetNewUniqueID();
        }
 public RedisEventStream(ChannelMessageQueue channel, IMessageSerializer messageSerializer)
 {
     _channel           = channel;
     _messageSerializer = messageSerializer;
 }
        public MessageDistributor(
            NsqBus bus,
            IObjectBuilder objectBuilder,
            ILogger logger,
            MessageHandlerMetadata messageHandlerMetadata
            )
        {
            if (bus == null)
            {
                throw new ArgumentNullException("bus");
            }
            if (objectBuilder == null)
            {
                throw new ArgumentNullException("objectBuilder");
            }
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (messageHandlerMetadata == null)
            {
                throw new ArgumentNullException("messageHandlerMetadata");
            }

            _bus           = bus;
            _objectBuilder = objectBuilder;
            _logger        = logger;

            _serializer     = messageHandlerMetadata.Serializer;
            _handlerType    = messageHandlerMetadata.HandlerType;
            _messageType    = messageHandlerMetadata.MessageType;
            _messageAuditor = messageHandlerMetadata.MessageAuditor;
            _topic          = messageHandlerMetadata.Topic;
            _channel        = messageHandlerMetadata.Channel;

            var possibleMethods = _handlerType.GetMethods().Where(p => p.Name == "Handle" && !p.IsGenericMethod);

            foreach (var possibleMethod in possibleMethods)
            {
                var parameters = possibleMethod.GetParameters();
                if (parameters.Length == 1 && parameters[0].ParameterType == _messageType)
                {
                    _handleMethod = possibleMethod;
                    break;
                }
            }

            if (_handleMethod == null)
            {
                throw new Exception(string.Format("Handle({0}) not found on {1}", _messageType, _handlerType));
            }

            if (!_messageType.IsInterface)
            {
                _concreteMessageType = _messageType;
            }
            else
            {
                _concreteMessageType = InterfaceBuilder.CreateType(_messageType);
            }
        }
 public PreSharedKeyEncryptedMessageSerializer(string key, IMessageSerializer serializer)
 {
     _key = key;
     _wrappedSerializer = serializer;
 }
Exemple #38
0
 public ServiceBusQueueMessageBus(
     QueueClient queueClient,
     IMessageSerializer messageSerializer)
     : this(queueClient, new BrokeredMessageSerializer(messageSerializer))
 {
 }
 public TcpChannel(TcpEndpointData endpointData, IMessageSerializer serializer)
     : base(endpointData, serializer)
 {
 }
Exemple #40
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MessageServer"/> class.
        /// </summary>
        /// <param name="container">The componentry container.</param>
        /// <param name="messagingAdapter">The message bus adapter.</param>
        /// <param name="headerSerializer">The header serializer.</param>
        /// <param name="requestSerializer">The request serializer.</param>
        /// <param name="responseSerializer">The response serializer.</param>
        /// <param name="compressor">The message compressor.</param>
        /// <param name="encryption">The encryption configuration.</param>
        /// <param name="serviceName">The service name.</param>
        /// <param name="requestAddress">The inbound zmq network address.</param>
        /// <param name="responseAddress">The outbound zmq network address.</param>
        protected MessageServer(
            IComponentryContainer container,
            IMessageBusAdapter messagingAdapter,
            ISerializer <Dictionary <string, string> > headerSerializer,
            IMessageSerializer <Request> requestSerializer,
            IMessageSerializer <Response> responseSerializer,
            ICompressor compressor,
            EncryptionSettings encryption,
            Label serviceName,
            ZmqNetworkAddress requestAddress,
            ZmqNetworkAddress responseAddress)
            : base(container, messagingAdapter)
        {
            this.serverId           = new ServerId(this.Name.Value);
            this.headerSerializer   = headerSerializer;
            this.requestSerializer  = requestSerializer;
            this.responseSerializer = responseSerializer;
            this.compressor         = compressor;
            this.serviceName        = serviceName;

            this.socketInbound = new RouterSocket
            {
                Options =
                {
                    Identity             = Encoding.UTF8.GetBytes($"{this.serviceName.Value}-{this.Name.Value}"),
                    Linger               = TimeSpan.FromSeconds(1),
                    TcpKeepalive         = true,
                    TcpKeepaliveInterval = TimeSpan.FromSeconds(2),
                    RouterHandover       = true,
                },
            };

            this.socketOutbound = new RouterSocket
            {
                Options =
                {
                    Identity             = Encoding.UTF8.GetBytes($"{this.serviceName.Value}-{this.Name.Value}"),
                    Linger               = TimeSpan.FromSeconds(1),
                    TcpKeepalive         = true,
                    TcpKeepaliveInterval = TimeSpan.FromSeconds(2),
                    RouterMandatory      = true,
                    RouterHandover       = true,
                },
            };

            this.requestAddress   = requestAddress;
            this.responseAddress  = responseAddress;
            this.peers            = new Dictionary <ClientId, SessionId>();
            this.correlationIndex = new ConcurrentDictionary <Guid, Address>();

            this.queue = new MessageQueue(
                container,
                this.socketInbound,
                this.socketOutbound,
                this.HandlePayload);

            if (encryption.UseEncryption)
            {
                EncryptionProvider.SetupSocket(encryption, this.socketInbound);
                this.Logger.LogInformation(
                    LogId.Network,
                    $"{encryption.Algorithm} encryption setup for {this.requestAddress}");

                EncryptionProvider.SetupSocket(encryption, this.socketOutbound);
                this.Logger.LogInformation(
                    LogId.Network,
                    $"{encryption.Algorithm} encryption setup for {this.responseAddress}");
            }
            else
            {
                this.Logger.LogWarning(
                    LogId.Network,
                    $"No encryption setup for {this.requestAddress}");

                this.Logger.LogWarning(
                    LogId.Network,
                    $"No encryption setup for {this.responseAddress}");
            }

            this.ReceivedCount = 0;
            this.SentCount     = 0;
        }
Exemple #41
0
        public static void ShouldContain <TMessage>(this IInboundTransport transport, IMessageSerializer serializer)
            where TMessage : class
        {
            var future = new Future <TMessage>();

            transport.Receive(context =>
            {
                context.ShouldNotBeNull();
                context.ShouldBeAnInstanceOf <IReceiveContext>();

                serializer.Deserialize(context);

                IConsumeContext <TMessage> messageContext;
                if (context.TryGetContext(out messageContext))
                {
                    if (!future.IsCompleted)
                    {
                        future.Complete(messageContext.Message);
                    }
                }

                return(null);
            }, TimeSpan.FromSeconds(3));

            future.IsCompleted.ShouldBeTrue(transport.Address + " should contain a message of type " + typeof(TMessage).Name);
        }
 public MessageReceiveTask(IRemoteClient client, IMessageSerializer messageSerializer)
 {
     _client            = client;
     _messageSerializer = messageSerializer;
 }
Exemple #43
0
 public InMemorySagaPersister(IServiceLocator serviceLocator, IReflection reflection, IMessageSerializer messageSerializer)
 {
     this.serviceLocator    = serviceLocator;
     this.reflection        = reflection;
     this.messageSerializer = messageSerializer;
 }
Exemple #44
0
 public MessageBusBuilder WithSerializer(IMessageSerializer serializer)
 {
     _settings.Serializer = serializer;
     return(this);
 }
Exemple #45
0
 public MessageLoggingModule(IMessageSerializer messageSerializer, IEndpointRouter endpointRouter, Uri logQueue)
 {
     this.messageSerializer = messageSerializer;
     this.endpointRouter    = endpointRouter;
     this.logQueue          = logQueue;
 }
        public RabbitMqReceiveEndpointTopology(IRabbitMqEndpointConfiguration configuration, Uri inputAddress, IMessageSerializer serializer,
                                               IRabbitMqHost host, BusHostCollection <RabbitMqHost> hosts, BrokerTopology brokerTopology)
        {
            InputAddress    = inputAddress;
            _configuration  = configuration;
            _serializer     = serializer;
            _host           = host;
            _brokerTopology = brokerTopology;

            _hosts = hosts;

            _consume = configuration.Topology.Consume;

            _send    = configuration.Topology.Send;
            _publish = configuration.Topology.Publish;

            _sendTransportProvider   = new Lazy <ISendTransportProvider>(CreateSendTransportProvider);
            _sendEndpointProvider    = new Lazy <ISendEndpointProvider>(CreateSendEndpointProvider);
            _publishEndpointProvider = new Lazy <IPublishEndpointProvider>(CreatePublishEndpointProvider);
        }
 public NHibernateSagaPersister(INHibernateSessionProvider session, IServiceLocator serviceLocator, IMessageSerializer messageSerializer, IReflection reflection)
 {
     this.session           = session.CurrentSession;
     this.serviceLocator    = serviceLocator;
     this.messageSerializer = messageSerializer;
     this.reflection        = reflection;
 }
Exemple #48
0
 public void Serializer(Stream stream, IMessageSerializer serializeHelper)
 {
     serializeHelper.AddToMessageStream(stream, typeof(long), Amount);
     Symbol.Serializer(stream, serializeHelper);
 }
Exemple #49
0
 public ActorRefMock(ActorPath path, IMessageSerializer serializer = null)
     : base(path)
 {
     this.serializer = serializer;
 }
 public void SetMessageSerializer(IMessageSerializer serializer)
 {
     _serializer = serializer;
 }
Exemple #51
0
 internal Envelope(object message, IMessageSerializer writer)
 {
     Message     = message;
     this.writer = writer;
 }
Exemple #52
0
 public RabbitMQMessagingService(ILoggingService loggingService, IConfiguration config, IMessageSerializer serializer)
 {
     this.loggingService    = loggingService;
     this.log               = loggingService.GetCurrentClassLogger();
     this.configuration     = config;
     this.connectionDetails = new ConnectionDetails(config);
     this.serializer        = serializer;
     ConnectToBroker(new ConnectionDetails(config));
 }
        public IChannelReceiver Create(Type messageType, IEventSubscription subscription, IProcessingSettings processingSettings, IMessageSerializer serializer, IHostConfiguration configuration, IMessageProcessor processor)
        {
            var queueReaderType = typeof(RedisEventChannelReceiver <>).MakeGenericType(messageType);
            var queueReader     = (IChannelReceiver)Activator.CreateInstance(queueReaderType, _connectionMultiplexer, processingSettings, serializer, subscription, Configuration, configuration, processor);

            return(queueReader);
        }
Exemple #54
0
 public static T Deserialize <T>(this IMessageSerializer serializer, byte[] bytes)
 {
     return((T)Deserialize(serializer, typeof(T), bytes));
 }
Exemple #55
0
 public ActorSystemMock(IMessageSerializer serializer = null)
 {
     this.serializer = serializer ?? new BinarySerializer();
 }
Exemple #56
0
 public SerializationMapper(IMessageMapper mapper, ReadOnlySettings settings)
 {
     xmlSerializer  = new XmlSerializer().Configure(settings)(mapper);
     jsonSerializer = new JsonSerializer().Configure(settings)(mapper);
 }
Exemple #57
0
 /// <summary>
 /// A method to be implemented by subclasses to handle the
 /// actual initialization of the channel and the creation and
 /// assignment of the MessageReader and MessageWriter properties.
 /// </summary>
 /// <param name="messageSerializer">The IMessageSerializer to use for message serialization.</param>
 protected abstract void Initialize(IMessageSerializer messageSerializer);
Exemple #58
0
 public ClientFactory(IMessageSerializer messageSerializer, IBus bus)
 {
     this.messageSerializer = messageSerializer;
     this.bus = bus;
 }
 public SerializationBuilder With <T>(IMessageSerializer <T> serializer) where T : MessageBase
 {
     TestObject.Register(serializer);
     return(this);
 }
 public ICanCreateEndpointAsClientOrServer <TMessage, TCommand, TEvent, TRequest, TResponse> SerializedWith(IMessageSerializer serializer, IMessageDeserializerFactory deserializerFactory)
 {
     _serializer          = serializer;
     _deserializerFactory = deserializerFactory;
     return(this);
 }