public ConsumeMessagingContext(ConsumeChannel channel, object model, BasicDeliverEventArgs e, Func <ReadOnlyMemory <byte>, TMessage> deserializeFunc, ConsumeMetadata metadata)
        {
            Channel  = channel;
            Model    = model;
            Args     = e;
            Metadata = metadata;

            _deserializeFunc = deserializeFunc;
            Data             = _deserializeFunc(e.Body);
        }
        public ConsumeChannel(ConsumeMetadata metadata)
        {
            if (metadata.ConsumeOptions == null)
            {
                throw new ArgumentNullException(nameof(metadata.ConsumeOptions));
            }
            if (string.IsNullOrWhiteSpace(metadata.ConsumeOptions.Queue))
            {
                throw new ArgumentNullException(nameof(metadata.ConsumeOptions.Queue));
            }
            if (string.IsNullOrWhiteSpace(metadata.ConsumeOptions.Exchange))
            {
                throw new ArgumentNullException(nameof(metadata.ConsumeOptions.Exchange));
            }
            if (metadata.HandlerType == null)
            {
                throw new ArgumentNullException(nameof(metadata.HandlerType));
            }
            if (metadata.ServerOptions == null)
            {
                throw new ArgumentNullException(nameof(metadata.ServerOptions));
            }
            if (string.IsNullOrWhiteSpace(metadata.ServerOptions.Host))
            {
                throw new ArgumentNullException(nameof(metadata.ServerOptions.Host));
            }
            if (metadata.ServerOptions.Port == 0)
            {
                throw new ArgumentNullException(nameof(metadata.ServerOptions.Port));
            }
            if (string.IsNullOrWhiteSpace(metadata.ServerOptions.VirtualHost) && string.IsNullOrWhiteSpace(metadata.ConsumeOptions.VirtualHost))
            {
                throw new ArgumentNullException("VirtualHost is null!");
            }
            if (string.IsNullOrWhiteSpace(metadata.ConsumeOptions.VirtualHost))
            {
                metadata.ConsumeOptions.VirtualHost = metadata.ServerOptions.VirtualHost;
            }

            _metadata   = metadata;
            _logger     = ObjectContainerFactory.ObjectContainer.Resolve <ILoggerFactory>().CreateLogger <ConsumeChannel>();
            _connection = RabbitMQConnectionFactory.Instance.GetOrCreateConnection(_metadata.ServerOptions, _metadata.ConsumeOptions.VirtualHost, Binding);
        }
 public ConsumeMessagingHandler()
 {
     _logger        = ObjectContainerFactory.ObjectContainer.Resolve <ILoggerFactory>().CreateLogger(this.GetType());
     _jsonSerialzer = SerializeFactory.Serializer;
     _metadata      = ConsumeMetadataFactory.Get(this.GetType().FullName);
 }
 public static void Set(ConsumeMetadata metadata)
 {
     _metadataDic.Add(metadata.HandlerType.FullName, metadata);
 }