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) ; }
public void HandleAgentRemoved(Agent agent) { if (Console != null) { Console.AgentRemoved(agent) ; } }
// Callback Methods public void HandleNewAgent(Agent agent) { if (Console != null) { Console.NewAgent(agent) ; } }
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) ; } } }
public virtual void HearbeatRecieved(Agent agent, long timestamp) {}
public virtual void AgentRemoved(Agent agent) {}
public virtual void NewAgent(Agent agent) {}