public void ConvertAndSend() { Assert.NotNull(emsConnectionFactory); Assert.NotNull(connectionFactory); Assert.NotNull(jndiEmsConnectionFactory); Assert.NotNull(cachingJndiConnectionFactory); Assert.NotNull(emsTemplate); string msgText = "Hello World"; //Use with destination set at runtime emsTemplate.ConvertAndSend("APP.TESTING", msgText); AssertRecievedHelloWorldMessage(msgText, emsTemplate.ReceiveAndConvert("APP.TESTING")); //Now using default destination set via property emsTemplate.DefaultDestinationName = "APP.TESTING"; emsTemplate.ConvertAndSend(msgText); AssertRecievedHelloWorldMessage(msgText, emsTemplate.ReceiveAndConvert()); //Now using destination oject Destination destination = (Destination)lookupContext.Lookup(queueName); emsTemplate.ConvertAndSend(destination, msgText); AssertRecievedHelloWorldMessage(msgText, emsTemplate.ReceiveAndConvert(destination)); }
public void SendMarketData() { while (true) { IDictionary data = GenerateFakeMarketData(); log.Info("Sending market data."); EmsTemplate.ConvertAndSend(data); log.Info("Sleeping " + sleepTimeInSeconds + " seconds before sending more market data."); Thread.Sleep(sleepTimeInSeconds); } }
public void SendAndAsyncReceive() { SimpleMessageListenerContainer container = (SimpleMessageListenerContainer)applicationContext["SimpleMessageListenerContainer"]; SimpleMessageListener listener = applicationContext["SimpleMessageListener"] as SimpleMessageListener; Assert.IsNotNull(container); Assert.IsNotNull(listener); Admin admin = new Admin("tcp://localhost:7222", "admin", null); admin.PurgeQueue("test.queue"); EmsTemplate emsTemplate = (EmsTemplate)applicationContext["MessageTemplate"] as EmsTemplate; Assert.IsNotNull(emsTemplate); Assert.AreEqual(0, listener.MessageCount); emsTemplate.ConvertAndSend("Hello World 1"); int waitInMillis = 2000; Thread.Sleep(waitInMillis); Assert.AreEqual(1, listener.MessageCount); container.Stop(); Console.WriteLine("container stopped."); emsTemplate.ConvertAndSend("Hello World 2"); Thread.Sleep(waitInMillis); Assert.AreEqual(1, listener.MessageCount); container.Start(); Console.WriteLine("container started."); Thread.Sleep(waitInMillis); Assert.AreEqual(2, listener.MessageCount); container.Shutdown(); Thread.Sleep(waitInMillis); }