예제 #1
0
        public LinkProducerBuilder
        (
            Link link,
            TimeSpan recoveryInterval,
            ILinkSerializer serializer,
            TimeSpan?publishTimeout = null,
            bool?confirmsMode       = null,
            bool?setUserId          = null,
            ILinkMessageIdGenerator messageIdGenerator              = null,
            LinkPublishProperties publishProperties                 = null,
            LinkMessageProperties messageProperties                 = null,
            ILinkProducerTopologyHandler topologyHandler            = null,
            LinkStateHandler <LinkProducerState> stateHandler       = null,
            LinkStateHandler <LinkChannelState> channelStateHandler = null,
            LinkTypeNameMapping typeNameMapping = null
        )
        {
            _link = link ?? throw new ArgumentNullException(nameof(link));

            _confirmsMode        = confirmsMode ?? false;
            _setUserId           = setUserId ?? true;
            _publishTimeout      = publishTimeout ?? Timeout.InfiniteTimeSpan;
            _recoveryInterval    = recoveryInterval;
            _messageIdGenerator  = messageIdGenerator ?? new LinkGuidMessageIdGenerator();
            _publishProperties   = publishProperties ?? new LinkPublishProperties();
            _messageProperties   = messageProperties ?? new LinkMessageProperties();
            _topologyHandler     = topologyHandler;
            _stateHandler        = stateHandler ?? ((old, @new) => { });
            _channelStateHandler = channelStateHandler ?? ((old, @new) => { });
            _serializer          = serializer;
            _typeNameMapping     = typeNameMapping ?? new LinkTypeNameMapping();
        }
예제 #2
0
 private LinkProducerBuilder
 (
     LinkProducerBuilder prev,
     TimeSpan?recoveryInterval = null,
     TimeSpan?publishTimeout   = null,
     bool?confirmsMode         = null,
     bool?setUserId            = null,
     ILinkMessageIdGenerator messageIdGenerator              = null,
     LinkPublishProperties publishProperties                 = null,
     LinkMessageProperties messageProperties                 = null,
     ILinkProducerTopologyHandler topologyHandler            = null,
     LinkStateHandler <LinkProducerState> stateHandler       = null,
     LinkStateHandler <LinkChannelState> channelStateHandler = null,
     ILinkSerializer serializer          = null,
     LinkTypeNameMapping typeNameMapping = null
 ) : this
     (
         prev._link,
         recoveryInterval ?? prev._recoveryInterval,
         serializer ?? prev._serializer,
         publishTimeout ?? prev._publishTimeout,
         confirmsMode ?? prev._confirmsMode,
         setUserId ?? prev._setUserId,
         messageIdGenerator ?? prev._messageIdGenerator,
         publishProperties ?? prev._publishProperties.Clone(),
         messageProperties ?? prev._messageProperties.Clone(),
         topologyHandler ?? prev._topologyHandler,
         stateHandler ?? prev._stateHandler,
         channelStateHandler ?? prev._channelStateHandler,
         typeNameMapping ?? prev._typeNameMapping
     )
 {
 }
예제 #3
0
        public ILinkProducerBuilder MessageIdGenerator(ILinkMessageIdGenerator value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            return(new LinkProducerBuilder(this, messageIdGenerator: value));
        }
        public LinkProducerConfiguration(
            TimeSpan publishTimeout,
            TimeSpan recoveryInterval,
            ILinkMessageIdGenerator messageIdGenerator,
            bool confirmsMode,
            bool setUserId,
            LinkPublishProperties publishProperties,
            LinkMessageProperties messageProperties,
            ILinkProducerTopologyHandler topologyHandler,
            LinkStateHandler <LinkProducerState> stateHandler,
            ILinkSerializer serializer,
            LinkTypeNameMapping typeNameMapping
            )
        {
            if (publishTimeout < TimeSpan.Zero && publishTimeout != Timeout.InfiniteTimeSpan)
            {
                throw new ArgumentOutOfRangeException(nameof(publishTimeout),
                                                      "Must be greater or equal TimeSpan.Zero or equal Timeout.InfiniteTimeSpan");
            }

            if (recoveryInterval < TimeSpan.Zero)
            {
                throw new ArgumentOutOfRangeException(nameof(recoveryInterval), "Must be greater than TimeSpan.Zero");
            }

            PublishTimeout     = publishTimeout;
            RecoveryInterval   = recoveryInterval;
            MessageIdGenerator = messageIdGenerator ?? throw new ArgumentNullException(nameof(messageIdGenerator));
            ConfirmsMode       = confirmsMode;
            SetUserId          = setUserId;
            _publishProperties = publishProperties ?? throw new ArgumentNullException(nameof(publishProperties));
            _messageProperties = messageProperties ?? throw new ArgumentNullException(nameof(messageProperties));
            TopologyHandler    = topologyHandler ?? throw new ArgumentNullException(nameof(topologyHandler));
            StateHandler       = stateHandler ?? throw new ArgumentNullException(nameof(stateHandler));
            Serializer         = serializer;
            TypeNameMapping    = typeNameMapping ?? throw new ArgumentNullException(nameof(typeNameMapping));
        }
 public ILinkProducerConfigurationBuilder MessageIdGenerator(ILinkMessageIdGenerator value)
 {
     Configuration.MessageIdGenerator = value;
     return this;
 }