static void Main(string[] args) { QueueNames.SetQueuePrefix("site1."); typeof(Program).Namespace.Print(); using (var mqServer = CreateMqServer()) using (var mqClient = mqServer.CreateMessageQueueClient()) { var replyToMq = mqClient.GetTempQueueName(); mqClient.Publish(new Message <HelloRabbit>(new HelloRabbit { Name = "World" }) { ReplyTo = replyToMq }); IMessage <HelloRabbitResponse> responseMsg = mqClient.Get <HelloRabbitResponse>(replyToMq); mqClient.Ack(responseMsg); responseMsg.GetBody().PrintDump(); Console.ReadKey(); } }
public void Does_resolve_QueueNames_using_QueuePrefix() { QueueNames.SetQueuePrefix("site1."); Assert.That(new QueueNames(typeof(TestPrefix)).In, Is.EqualTo("site1.mq:TestPrefix.inq")); Assert.That(QueueNames <TestPrefix> .In, Is.EqualTo("site1.mq:TestPrefix.inq")); QueueNames.SetQueuePrefix(""); }
public void Can_determine_TempQueue_with_Custom_QueuePrefix() { QueueNames.SetQueuePrefix("site1."); var tmpName = QueueNames.GetTempQueueName(); Assert.That(QueueNames.IsTempQueue(tmpName), Is.True); QueueNames.SetQueuePrefix(""); }
static void Main(string[] args) { QueueNames.SetQueuePrefix("site1."); using (var mqServer = CreateMqServer()) { mqServer.RegisterHandler<HelloRabbit>(m => new HelloRabbitResponse { Result = "Hello, {0}!".Fmt(m.GetBody().Name) }); mqServer.Start(); typeof(Program).Namespace.Print(); Console.ReadKey(); } }
public void Can_Send_and_Receive_messages_using_QueueNamePrefix() { QueueNames.SetQueuePrefix("site1."); Assert.That(QueueNames.TopicIn, Is.EqualTo("site1.mq:topic:in")); Assert.That(QueueNames.TopicOut, Is.EqualTo("site1.mq:topic:out")); using (var mqServer = CreateMqServer()) { mqServer.RegisterHandler <HelloIntro>(m => new HelloIntroResponse { Result = $"Hello, {m.GetBody().Name}!" }); mqServer.Start(); using (var mqClient = mqServer.CreateMessageQueueClient()) { var request = new HelloIntro { Name = "World" }; var requestInq = MessageFactory.Create(request).ToInQueueName(); Assert.That(requestInq, Is.EqualTo("site1.mq:HelloIntro.inq")); mqClient.Publish(request); var responseInq = QueueNames <HelloIntroResponse> .In; Assert.That(responseInq, Is.EqualTo("site1.mq:HelloIntroResponse.inq")); IMessage <HelloIntroResponse> responseMsg = mqClient.Get <HelloIntroResponse>(responseInq); mqClient.Ack(responseMsg); Assert.That(responseMsg.GetBody().Result, Is.EqualTo("Hello, World!")); } } QueueNames.SetQueuePrefix(""); }