Пример #1
0
        public CGateMQPublisher(CGateConnection connection,
                                string name,
                                string service,
                                string category,
                                SchemeSource schemeSource,
                                uint timeout)
        {
            // TODO: check arguments validity

            if( connection == null )
                throw new ArgumentNullException("connection");

            string settings = FormatNewPublisherSettings(name,
                                                         service,
                                                         category,
                                                         schemeSource,
                                                         timeout);
            Publisher = new Publisher(connection.Handle, settings);
        }
Пример #2
0
 public CGateFortsPublisher(CGateConnection connection,
                            string name,
                            SchemeSource schemeSource,
                            uint timeout)
     : base(connection, name, "FORTS_SRV", "FORTS_MSG", schemeSource, timeout)
 {
 }
Пример #3
0
        private string FormatNewPublisherSettings(string name,
                                                  string service,
                                                  string category,
                                                  SchemeSource schemeSource,
                                                  uint timeout)
        {
            if( service == null )
                service = string.Empty;

            Dictionary<string, string> parameters = new Dictionary<string, string>();

            if( !string.IsNullOrEmpty(name) )
                parameters["name"] = name;

            if( !string.IsNullOrEmpty(category) )
                parameters["category"] = category;

            parameters["timeout"] = timeout.ToString(CultureInfo.InvariantCulture);
            parameters["scheme"] = CGateSettingsFormatter.FormatSchemeSource(schemeSource);

            return string.Format("p2mq://{0};{1}",
                                 service,
                                 CGateSettingsFormatter.FormatParameters(parameters));
        }
 public static string FormatSchemeSource(SchemeSource schemeSource)
 {
     return string.Format("|FILE|{0}|{1}", schemeSource.Path, schemeSource.Section);
 }
Пример #5
0
        private static string FormatListenerNewSettings(string streamName,
                                                        SchemeSource schemeSource,
                                                        ICollection<string> tables)
        {
            if( streamName == null )
                streamName = string.Empty;

            string parameters = string.Empty;

            if( schemeSource != null )
                parameters = string.Format("scheme={0}",
                                           CGateSettingsFormatter.FormatSchemeSource(schemeSource));
            else if( tables != null )
            {
                // TODO: investigate a case when tables.Length == 0
                parameters = "tables=" + string.Join(",", tables);
            }

            return string.Format("p2repl://{0};{1}",
                                 streamName,
                                 parameters);
        }
Пример #6
0
        public CGateReplicationListener(CGateConnection connection,
                                        string streamName,
                                        SchemeSource schemeSource = null,
                                        ICollection<string> tables = null)
        {
            if( string.IsNullOrEmpty(streamName) )
                throw new ArgumentException("Stream name cannot be null or empty", "streamName");

            string settings = FormatListenerNewSettings(streamName, schemeSource, tables);

            Listener = new Listener(connection.Handle, settings) { Handler = HandleMessage };

            _tables = tables;

            StreamName = streamName;
            IsOnline = false;

            EnableSnapshotMode = true;
            EnableOnlineMode = true;
            LifeNum = 0;
        }