public void Does_process_multi_messages_in_HttpListener_AppHost() { using (var appHost = new AppHost(() => CreateMqServer()).Init()) { using (var mqClient = appHost.Resolve <IMessageService>().CreateMessageQueueClient()) { var requests = new[] { new HelloIntro { Name = "Foo" }, new HelloIntro { Name = "Bar" }, }; var client = (IOneWayClient)mqClient; client.SendAllOneWay(requests); var responseMsg = mqClient.Get <HelloIntroResponse>(QueueNames <HelloIntroResponse> .In); mqClient.Ack(responseMsg); Assert.That(responseMsg.GetBody().Result, Is.EqualTo("Hello, Foo!")); responseMsg = mqClient.Get <HelloIntroResponse>(QueueNames <HelloIntroResponse> .In); mqClient.Ack(responseMsg); Assert.That(responseMsg.GetBody().Result, Is.EqualTo("Hello, Bar!")); } } }
public void Can_make_authenticated_requests_with_MQ() { using (var appHost = new AppHost(() => CreateMqServer()).Init()) { appHost.Start(Config.ListeningOn); var client = new JsonServiceClient(Config.ListeningOn); var response = client.Post(new Authenticate { UserName = "******", Password = "******" }); var sessionId = response.SessionId; using (var mqClient = appHost.Resolve <IMessageService>().CreateMessageQueueClient()) { mqClient.Publish(new MqAuthOnly { Name = "MQ Auth", SessionId = sessionId, }); var responseMsg = mqClient.Get <MqAuthOnlyResponse>(QueueNames <MqAuthOnlyResponse> .In); mqClient.Ack(responseMsg); Assert.That(responseMsg.GetBody().Result, Is.EqualTo("Hello, MQ Auth! Your UserName is mythz")); } } }
public void Can_make_authenticated_requests_with_MQ_BearerToken() { using var appHost = new AppHost(() => CreateMqServer()).Init(); appHost.Start(Config.ListeningOn); var client = new JsonServiceClient(Config.ListeningOn); var response = client.Post(new Authenticate { provider = "credentials", UserName = "******", Password = "******" }); using var mqClient = appHost.Resolve <IMessageService>().CreateMessageQueueClient(); mqClient.Publish(new MqAuthOnlyToken { Name = "MQ AuthToken", BearerToken = response.BearerToken, }); var responseMsg = mqClient.Get <MqAuthOnlyResponse>(QueueNames <MqAuthOnlyResponse> .In); mqClient.Ack(responseMsg); Assert.That(responseMsg.GetBody().Result, Is.EqualTo("Hello, MQ AuthToken! Your UserName is mythz")); }
public void Does_process_messages_in_HttpListener_AppHost() { using var appHost = new AppHost(() => CreateMqServer()).Init().Start(Config.ListeningOn); using var mqClient = appHost.Resolve <IMessageService>().CreateMessageQueueClient(); mqClient.Publish(new HelloIntro { Name = "World" }); IMessage <HelloIntroResponse> responseMsg = mqClient.Get <HelloIntroResponse>(QueueNames <HelloIntroResponse> .In); mqClient.Ack(responseMsg); Assert.That(responseMsg.GetBody().Result, Is.EqualTo("Hello, World!")); }
public void Does_allow_MessageQueue_restricted_Services() { using var appHost = new AppHost(() => CreateMqServer()).Init().Start(Config.ListeningOn); using var mqClient = appHost.Resolve <IMessageService>().CreateMessageQueueClient(); mqClient.Publish(new MqRestriction { Name = "MQ Restriction", }); var responseMsg = mqClient.Get <MqRestrictionResponse>(QueueNames <MqRestrictionResponse> .In); mqClient.Ack(responseMsg); Assert.That(responseMsg.GetBody().Result, Is.EqualTo("MQ Restriction")); }
public void Does_process_messages_in_HttpListener_AppHost() { using (var appHost = new AppHost(() => CreateMqServer()).Init()) { using (var mqClient = appHost.Resolve<IMessageService>().CreateMessageQueueClient()) { mqClient.Publish(new HelloIntro { Name = "World" }); IMessage<HelloIntroResponse> responseMsg = mqClient.Get<HelloIntroResponse>(QueueNames<HelloIntroResponse>.In); mqClient.Ack(responseMsg); Assert.That(responseMsg.GetBody().Result, Is.EqualTo("Hello, World!")); } } }