Example #1
0
		protected void TryToConnect() {
			reqsOutstanding = 1 ;		
			Agent newAgent = new Agent(this,0,"BrokerAgent") ;
			Agents.Add(newAgent.AgentKey(), newAgent) ;
			client = new Client() ;
			client.Connect(url.Hostname, url.Port, null, url.AuthName, url.AuthPassword) ;
			clientSession = client.CreateSession(timeout) ;		
			//clientSession.SetAutoSync(false) ;
			string name = System.Text.Encoding.UTF8.GetString(clientSession.GetName()) ;
			replyName = "reply-" + name ;
			topicName = "topic-" + name ;
			clientSession.SetAutoSync(true) ;
			Option[] options = new Option[] {Option.EXCLUSIVE, Option.AUTO_DELETE} ;
		
			// This queue is used for responses to messages which are sent.	
			clientSession.QueueDeclare(replyName,options) ;
			clientSession.ExchangeBind(replyName,"amq.direct",replyName) ;
			clientSession.AttachMessageListener(this, "rdest") ;			
			clientSession.MessageSubscribe(replyName,"rdest",MessageAcceptMode.NONE,MessageAcquireMode.PRE_ACQUIRED,null,0,null) ;			  			  						
            clientSession.MessageSetFlowMode("rdest", MessageFlowMode.WINDOW);
            clientSession.MessageFlow("rdest", MessageCreditUnit.BYTE, ClientSession.MESSAGE_FLOW_MAX_BYTES);
            clientSession.MessageFlow("rdest", MessageCreditUnit.MESSAGE, ClientSession.MESSAGE_FLOW_MAX_BYTES);  			
		
			// This queue is used for unsolicited messages sent to this class.
			clientSession.QueueDeclare(topicName, options) ;
			clientSession.AttachMessageListener(this, "tdest") ;			
			clientSession.MessageSubscribe(topicName,"tdest",MessageAcceptMode.NONE,MessageAcquireMode.PRE_ACQUIRED,null,0,null) ;							  									
            clientSession.MessageSetFlowMode("tdest", MessageFlowMode.WINDOW);
            clientSession.MessageFlow("tdest", MessageCreditUnit.BYTE, ClientSession.MESSAGE_FLOW_MAX_BYTES);
            clientSession.MessageFlow("tdest", MessageCreditUnit.MESSAGE, ClientSession.MESSAGE_FLOW_MAX_BYTES);  				
			
			outSession = client.CreateSession(timeout) ;	
			outSession.ExchangeBind(replyName,"amq.direct",replyName) ;
			
			connected = true ;
			consoleSession.HandleBrokerConnect(this) ;		
				
			
			IEncoder encoder = CreateEncoder() ;
			this.SetHeader(encoder, 'B', 0) ;
			this.Send(encoder) ;
		}
Example #2
0
		public void HandleAgentRemoved(Agent agent) {
			if (Console != null) {
				Console.AgentRemoved(agent) ;
			}		
		}	
Example #3
0
		// Callback Methods
		public void HandleNewAgent(Agent agent) {
			if (Console != null) {
				Console.NewAgent(agent) ;
			}		
		}	
Example #4
0
		public void UpdateAgent(QMFObject obj) {
			long agentBank = (long)obj.GetProperty("agentBank") ;
			long brokerBank = (long)obj.GetProperty("brokerBank") ;
			String key = Agent.AgentKey(agentBank, brokerBank) ;
			if (obj.IsDeleted()) {
				if (Agents.ContainsKey(key)) {
					Agent agent = Agents[key] ;
					Agents.Remove(key) ;
					consoleSession.HandleAgentRemoved(agent) ;
				}
			}
			else {
				if (! Agents.ContainsKey(key)) {
					Agent newAgent = new Agent(this, agentBank, (string)obj.GetProperty("label")) ;
					Agents.Add(key, newAgent) ;
					consoleSession.HandleNewAgent(newAgent) ;
				}
			}
		}
Example #5
0
		public virtual void HearbeatRecieved(Agent agent, long timestamp) {}	
Example #6
0
		public virtual void AgentRemoved(Agent agent) {}
Example #7
0
		public virtual void NewAgent(Agent agent) {}