public void SessionValidationController_ValidateRequest_KnownUserExpired_Test() { KnownUserFactory.Reset(false); KnownUserFactory.Configure(SharedSecreteEventKey); int expectedPlaceInqueue = 7810; Guid expectedQueueId = Guid.NewGuid(); string placeInQueueEncrypted = Hashing.EncryptPlaceInQueue(expectedPlaceInqueue); long unixTimestamp = (long)(DateTime.UtcNow.AddMinutes(-4) - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds; string urlNoHash = "http://q.queue-it.net/inqueue.aspx?c=somecust&e=someevent&q=" + expectedQueueId + "&p=" + placeInQueueEncrypted + "&ts=" + unixTimestamp + "&h="; Uri hashUri = new Uri(urlNoHash); string hash = Hashing.GenerateMD5Hash(hashUri.AbsoluteUri, SharedSecreteEventKey); string querystring = "c=somecust&e=someevent&q=" + expectedQueueId + "&p=" + placeInQueueEncrypted + "&ts=" + unixTimestamp + "&h=" + hash; string url = urlNoHash + hash; HttpRequest httpRequest = new HttpRequest("inqueue.aspx", url, querystring); HttpContext.Current = new HttpContext(httpRequest, new HttpResponse(null)); SessionValidationController.ValidateRequest( QueueFactory.CreateQueue("somecust", "someevent")); }
static void Main(string[] args) { Console.Title = "Bank Account Manager"; var factory = new ConnectionFactory() { HostName = "localhost" }; using (var connection = factory.CreateConnection()) using (channel = connection.CreateModel()) { QueueFactory.MakePublishSubscribeAccountsQueue(channel); //QueueFactory.MakeRollbackQueue(channel); Console.WriteLine(" [*] Waiting for transactions."); var consumer = new EventingBasicConsumer(channel); consumer.Received += MessageReceiver; channel.BasicConsume(queue: "bank", autoAck: true, consumer: consumer); //channel.BasicConsume(queue: "rollback", // autoAck: true, // consumer: consumer); Console.WriteLine(" Press [enter] to exit."); Console.ReadLine(); } }
static async void MainAsync(string[] args) { var m = new QueueFactory("mongodb://localhost", "redcappedtest"); var q = await m.CreateQueueAsync<string>("test2", 64*1024*1024); await PublishMessages(q, QoS.Low, 10); await PublishMessages(q, QoS.Normal, 10); await PublishMessages(q, QoS.High, 10); var counter = 0; var watch = new Stopwatch(); watch.Start(); q.Subscribe(msg => { counter++; if (counter%1000 != 0) return true; SetCursorPosition(0, CursorTop); Write("Receive rate (msg/s): {0}", Math.Truncate(decimal.Divide(1000, watch.ElapsedMilliseconds) * 1000)); watch.Restart(); return true; }); }
public static void Main() { Console.Title = "Fraud Detector"; var factory = new ConnectionFactory() { HostName = "localhost" }; using (var connection = factory.CreateConnection()) using (channel = connection.CreateModel()) { QueueFactory.MakePublishSubscribeFraudQueue(channel); Console.WriteLine(" [*] Waiting for transactions."); var consumer = new EventingBasicConsumer(channel); consumer.Received += MessageReceiver; channel.BasicConsume(queue: "fraud", autoAck: true, consumer: consumer); Console.WriteLine(" Press [enter] to exit."); Console.ReadLine(); } }
public ActionResult Landing(string t) { IQueue queue = QueueFactory.CreateQueue("advanced"); ViewBag.QueueUrl = queue.GetQueueUrl(t); return(View()); }
public void QueueFactory_GetLandingPageUrl_Test() { IQueue queue = QueueFactory.CreateQueue("customerid", "eventid"); string actualLandingPageUrl = queue.GetLandingPageUrl(); Assert.IsNull(actualLandingPageUrl); }
public void CreateNewMyTuple_BadKey(string str, string queueF) { mtf = new MyTupleFactory(); mt = new MyTuple <string, Queue>("String", new Queue()); qf = new QueueFactory(); Assert.Throws <ArgumentException>(() => { QueueFactory qf = getObject1(queueF); }); }
public override IMessageQueue GetReplyQueue(Message message) { if (!(Connection.Pattern == MessagePattern.RequestResponse && Connection.Direction == Direction.Inbound)) { throw new InvalidOperationException("Cannot get a reply queue except for inbound request-response"); } return(QueueFactory.Create(message.ResponseConnection)); }
static void Main(string[] args) { // Note! Database must be configured for memory optimized tables before queue creation // creating queue var factory = new QueueFactory(connectionString); factory.DeleteQueue("MyQueue"); factory.CreateQueue("MyQueue"); // connecting to queue var client = QueueClient.Create(connectionString, "MyQueue"); // creating subscription client.CreateSubscription("MySubscription"); // creating writer var writer = client.CreateWriter(); // writing message to queue byte[] message = { 0x01, 0x02, 0x03 }; var id = writer.Write(message); // writing batch of messages to queue byte[][] batch = { new byte[] { 0x01, 0x02, 0x03 }, new byte[] { 0x01, 0x02, 0x04 }, new byte[] { 0x01, 0x02, 0x05 }, }; var ids = writer.WriteMany(batch, true); writer.Close(); // creating reader for subscription var reader = client.CreateReader("MySubscription"); // reading 1000 messages from subscription var messages = reader.Read(1000); // making massages completed after handling reader.Complete(); reader.Close(); // another way to handle messages - using AutoReader AutoReading().Wait(); // deleting subscription client.DeleteSubscription("MySubscription"); // deleting queue factory.DeleteQueue("MyQueue"); Console.ReadKey(); }
protected void Page_Load(object sender, EventArgs e) { UriBuilder targetUrl = new UriBuilder(Request.Url); targetUrl.Path = "LinkTarget.aspx"; IQueue queue = QueueFactory.CreateQueue("link"); hlQueue.NavigateUrl = queue.GetQueueUrl(targetUrl.Uri.AbsoluteUri); }
public void CreateWorkerQueue() { QueueFactory qF = new QueueFactory(new Common.MQModel() { QueueName = "workerQ", Message = "a.b.c.d" }); qF.CreateWorkerPublisher(); }
public void CreateNewMyTuple_True(string str, string queueF) { mtf = new MyTupleFactory(); mt = new MyTuple <string, Queue>("String", new Queue()); QueueFactory qf = getObject1(queueF); MyTuple <string, Queue> sd = mtf.CreateNewMyTuple(str, qf); Assert.AreEqual(sd.Item1, mt.Item1); Assert.AreEqual(mt.Item2, sd.Item2); }
public void setup() { konzola = new Konzola1(); konzola2 = new Konzola2(); lista = new List <Item>(); pfu = new Pomocne_funkcijeUpdate(); mtf = new MyTupleFactory(); qf = new QueueFactory(); dict = new Dictionary <string, MyTuple <MyTuple <string, Queue>, MyTuple <string, Queue> > >(); }
public void QueueFactory_CreateQueue_Constructor_Test() { string expectedCustomerId = "customerid"; string expectedEventId = "eventid"; IQueue queue = QueueFactory.CreateQueue(expectedCustomerId, expectedEventId); Assert.AreEqual(expectedCustomerId, queue.CustomerId); Assert.AreEqual(expectedEventId, queue.EventId); }
public void QueueFactory_GetLandingPageUrl_Configuration_Test() { string expectedLandingPageUrl = "http://www.mysplitpage.com/"; IQueue queue = QueueFactory.CreateQueue("queue1"); string actualLandingPageUrl = queue.GetLandingPageUrl(); Assert.AreEqual(expectedLandingPageUrl, actualLandingPageUrl); }
public void MessageQueueFactoryCanCreateLocaleInstance() { var name = $"IntegrationTest_{UniqueKeyUtility.Generate()}"; using (var queue = new QueueFactory(NullLogger.Instance).CreateLocale(name, true, LocaleQueueMode.TemporaryMaster, true, AccessMode.Receive)) { queue.Should().NotBeNull(); queue.GetType().Should().Be(typeof(LocaleQueue)); } }
public void TestSetup() { cf = new ClientFactory(); server = new Serverr(cf, null); konzola = new Konzola(); m = new Metode(server, konzola); mytuplefactory = new MyTupleFactory(); queueFactory = new QueueFactory(); pfs = new Pomocne_funkcijeSubscribe(mytuplefactory, queueFactory); }
public void setup() { mtf = new MyTupleFactory(); qf = new QueueFactory(); pfc = new Pomocne_funkcijeCreate(mtf, qf); pfs = new Pomocne_funkcijeSubscribe(mtf, qf); pfu = new Pomocne_funkcijeUpdate(); meni = new Meni(pfc, pfs, pfu); cf = new ClientFactory(); srv = new Serverr(cf, null); }
public void TearDown() { cf = null; server = null; konzola = null; m = null; mytuplefactory = null; queueFactory = null; pfc = null; client = null; }
public void TestSetup() { cf = new ClientFactory(); server = new Serverr(cf, null); konzola = new Konzola(); m = new Metode(server, konzola); mytuplefactory = new MyTupleFactory(); queueFactory = new QueueFactory(); pfc = new Pomocne_funkcijeCreate(mytuplefactory, queueFactory); client = new Clientt("Klijent"); }
protected void Page_Load(object sender, EventArgs e) { IValidateResult result = SessionValidationController.ValidateRequest( QueueFactory.CreateQueue("ticketania", Request.QueryString["eventid"])); var accepted = result as AcceptedConfirmedResult; if (accepted != null) { accepted.Cancel(); } }
public void QueueFactory_GetLandingPageUrl_TargetUrl_Test() { string expectedTarget = "http://target.url/?someprop=somevalue&another=value"; string expectedLandingPageUrl = "http://www.mysplitpage.com/?t=" + HttpUtility.UrlEncode(expectedTarget); IQueue queue = QueueFactory.CreateQueue("queue1"); string actualLandingPageUrl = queue.GetLandingPageUrl(expectedTarget); Assert.AreEqual(expectedLandingPageUrl, actualLandingPageUrl); }
protected void Page_Load(object sender, EventArgs e) { // Never perform queue validation on error handling pages (e.g. Error.aspx) because it will cause users to get looped arround. // The recommended approach is to display a cancel link to users as shown below. string queueName = Request.QueryString["queuename"]; IQueue queue = QueueFactory.CreateQueue(queueName); hlQueue.NavigateUrl = queue.GetCancelUrl(Request.QueryString["t"]); }
// // GET: /Link/ public ActionResult Index() { UriBuilder targetUrl = new UriBuilder(Request.Url); targetUrl.Path = "/Link/Target"; IQueue queue = QueueFactory.CreateQueue("link"); ViewBag.QueueUrl = queue.GetQueueUrl(targetUrl.Uri.AbsoluteUri); return(View()); }
public void QueueFactory_CreateQueue_Constructor_Configuration_Named_Test() { QueueFactory.Reset(); string expectedCustomerId = "queue1customerid"; string expectedEventId = "queue1eventid"; IQueue queue = QueueFactory.CreateQueue("queue1"); Assert.AreEqual(expectedCustomerId, queue.CustomerId); Assert.AreEqual(expectedEventId, queue.EventId); }
public void CreateNewMyTuple_T() { Assert.Throws <ArgumentException>(() => { QueueFactory qf = getObject1("k"); }); Assert.Throws <ArgumentException>(() => { MyTuple <string, Queue> qf1 = getObject2("k", "f"); }); Assert.Throws <ArgumentException>(() => { MyTuple <string, Queue> qf2 = getObject3("novo", "staro"); }); }
/// <summary> /// Build Message Broker /// </summary> /// <returns>The Message Bus</returns> public IMessageBroker Build() { var messageBrokerConfig = new MessageBrokerConfig { ServiceName = _serviceName, RemoteQueueName = _remoteQueueName }; var queueFactory = new QueueFactory(_logger); var queueHandlerFactory = new QueueHandlerFactory(_logger, queueFactory); return(new MessageBroker(_logger, messageBrokerConfig, _repositoryContextFactory, queueHandlerFactory, queueFactory, _processInformation)); }
public void RegisterMessageBusServiceShouldSendMessage() { var messageBusConfig = new MessageBusConfig { ServiceName = "IntegrationTest" }; var queueFactory = new QueueFactory(Substitute.For <ILogger>()); var processInformation = new ProcessInformation(); var queueNameUtility = new QueueNameUtility(messageBusConfig.ServiceName); new MessageQueueManager(Substitute.For <ILogger>()).Delete(MessageBrokerConfig.LocaleQueueName, true); Assert.Throws <MessageBrokerException>(() => new MessageBroker(Substitute.For <ILogger>(), messageBusConfig, queueFactory, processInformation, queueNameUtility)); }
public void TestConsumerSubscribe2() { int n = 0; do { IConsumer consumer = QueueFactory <IConsumer> .Create(); consumer.Subscribe(new Action <MqMessageModel>(ConsumeEvent)); Thread.Sleep(500); } while (n < 5); states[3] = true; }
public void QueueFactory_GetQueueUrl_Version_Test() { string expectedCustomerId = "customerid"; string expectedEventId = "eventid"; string expectedVersion = "c" + typeof(Queue).Assembly.GetName().Version.ToString(); string expectedQueueUrl = "&ver=" + expectedVersion; IQueue queue = QueueFactory.CreateQueue(expectedCustomerId, expectedEventId); string actualQueueUrl = queue.GetQueueUrl(); Assert.IsTrue(actualQueueUrl.Contains(expectedQueueUrl)); }
public void QueueFactory_GetQueueUrl_Test() { string expectedCustomerId = "customerid"; string expectedEventId = "eventid"; string expectedQueueUrl = "http://" + expectedCustomerId + ".queue-it.net/?c=" + expectedCustomerId + "&e=" + expectedEventId; IQueue queue = QueueFactory.CreateQueue(expectedCustomerId, expectedEventId); string actualQueueUrl = queue.GetQueueUrl(); Assert.IsTrue(actualQueueUrl.StartsWith(expectedQueueUrl)); }
public void SetUp() { MongoDbUtils.DropDatabase(); _manager = new QueueFactory(MongoDbUtils.ConnectionString, MongoDbUtils.DatabaseName); _sut = _manager.CreateQueueAsync<string>("testqueue", 4096).Result; }