示例#1
0
    private void updateParentConnection()
    {
        parent = new RedisDataAccessProvider();
        parent.Configuration.Host          = RedisServerHost;
        parent.Configuration.Port          = RedisServerPort;
        parent.Configuration.NoDelaySocket = NoDelaySocket;

        ConnectionStatusChanged += OnConnectionStatusChanged;
        NewService += OnNewServiceArrived;
    }
        public override void NativeSessionStatusChanged(ConnectionStatusArguments args)
        {
            ConnectionStatus = args.Status;

            ConnectionStatusChangedHandler ev = ConnectionStatusChanged;

            if (ev != null)
            {
                ev(this, args);
            }
        }
示例#3
0
    public void Start()
    {
        parent = new RedisDataAccessProvider();
        parent.Configuration.Host          = RedisServerHost;
        parent.Configuration.Port          = RedisServerPort;
        parent.Configuration.NoDelaySocket = NoDelaySocket;

        ConnectionStatusChanged += OnConnectionStatusChanged;
        NewService += OnNewServiceArrived;

        Connect();

        pingRoutine = PingRedis();
        StartCoroutine(pingRoutine);
    }
示例#4
0
        private Task ListenToMq(string queueManagerName, string topicOrQueueString, bool isQueue, MessageReceivedHandler messageHandler, ConnectionStatusChangedHandler connectionStatusChangedHandler)
        {
            var           openOptionsForGet  = MQC.MQSO_CREATE | MQC.MQSO_FAIL_IF_QUIESCING | MQC.MQSO_MANAGED | MQC.MQSO_NON_DURABLE;
            MQDestination inboundDestination = null;

            var gmo = new MQGetMessageOptions();

            gmo.Options |= MQC.MQGMO_NO_WAIT | MQC.MQGMO_FAIL_IF_QUIESCING;

            try
            {
                var queueManager = new MQQueueManager(queueManagerName, _queueManagerProperties);

                if (isQueue)
                {
                    inboundDestination = queueManager.AccessQueue(topicOrQueueString, MQC.MQTOPIC_OPEN_AS_SUBSCRIPTION);
                }
                else
                {
                    inboundDestination = queueManager.AccessTopic(topicOrQueueString, null, MQC.MQTOPIC_OPEN_AS_SUBSCRIPTION, openOptionsForGet);
                }

                connectionStatusChangedHandler(new ConnectionStatus(queueManagerName, topicOrQueueString, Status.Connected));

                while (true)
                {
                    try
                    {
                        var msg = new MQMessage();
                        inboundDestination.Get(msg, gmo);

                        messageHandler(msg);
                    }
                    catch (MQException mqException)
                    {
                        if (mqException.Reason == MQC.MQRC_NO_MSG_AVAILABLE)
                        {
                            Thread.Sleep(200);
                        }
                        else
                        {
                            throw;
                        }
                    }
                }
            }
            catch (MQException mqException)
            {
                connectionStatusChangedHandler(new ConnectionStatus(queueManagerName, topicOrQueueString, Status.Disconnected));
            }

            return(Task.CompletedTask);
        }
示例#5
0
 public Task ListenToQueue(string queueManagerName, string topicString, MessageReceivedHandler messageHandler, ConnectionStatusChangedHandler connectionStatusChangedHandler)
 {
     return(ListenToMq(queueManagerName, topicString, true, messageHandler, connectionStatusChangedHandler));
 }