Exemplo n.º 1
0
        static void Main(string[] args)
        {
            BrokerClient bk = new BrokerClient("localhost", 2222, "tcp://mycompany.com/mypublisher");

            Console.WriteLine("Start sending");
            for (int i = 0; i < 1000; i++)
            {
                Console.WriteLine("message:" + i);
                BrokerMessage brkMsg = new BrokerMessage();

                brkMsg.TextPayload = RandomString(200);
                brkMsg.DestinationName = "sample_topic1";
                bk.PublishMessage(brkMsg);

                System.Threading.Thread.Sleep(500);
            }
        }
Exemplo n.º 2
0
 public abstract void OnMessage(BrokerMessage message);
Exemplo n.º 3
0
 public void PublishMessage(BrokerMessage brkmsg)
 {
     if ((brkmsg != null) && (!IsBlank(brkmsg.DestinationName)))
     {
         Publish pubreq = new Publish();
         pubreq.BrokerMessage = brkmsg;
         SoapEnvelope soap = BuildSoapEnvelope("http://services.sapo.pt/broker/publish");
         soap.Body.Publish = pubreq;
         _skClient.SendMessageAsync(soap, false);
     }
     else
     {
         throw new ArgumentException("Mal-formed PublishRequest object");
     }
 }
Exemplo n.º 4
0
        public void Acknowledge(BrokerMessage brkmsg)
        {
            if ((brkmsg != null) && (!IsBlank(brkmsg.MessageId)))
            {
                Acknowledge ack = new Acknowledge();
                ack.MessageId = brkmsg.MessageId;

                SoapEnvelope soap = BuildSoapEnvelope("http://services.sapo.pt/broker/acknowledge");
                soap.Body.Acknowledge = ack;
                _skClient.SendMessageAsync(soap, false);
            }
            else
            {
                throw new ArgumentException("Can't acknowledge invalid message.");
            }
        }
Exemplo n.º 5
0
 public void EnqueueMessage(BrokerMessage brkmsg)
 {
     if ((brkmsg != null) && (!IsBlank(brkmsg.DestinationName)))
     {
         Enqueue enqreq = new Enqueue();
         enqreq.BrokerMessage = brkmsg;
         SoapEnvelope soap = BuildSoapEnvelope("http://services.sapo.pt/broker/enqueue");
         soap.Body.Enqueue = enqreq;
         _skClient.SendMessageAsync(soap, false);
     }
     else
     {
         throw new ArgumentException("Mal-formed EnqueueRequest object");
     }
 }