コード例 #1
0
        public void GatewayWithConnectionFactoryAndDestinationName()
        {
            XmlApplicationContext ctx =
                (XmlApplicationContext)
                NmsTestUtils.GetContext(@"Nms\Config\NmsGatewayWithConnectionFactoryAndDestinationName.xml");
            IPollableChannel         channel = (IPollableChannel)ctx.GetObject("requestChannel");
            NmsMessageDrivenEndpoint gateway = (NmsMessageDrivenEndpoint)ctx.GetObject("nmsGateway");

            Assert.That(gateway.GetType(), Is.EqualTo(typeof(NmsMessageDrivenEndpoint)));
            ctx.Start();

            ThreadPerTaskExecutor executor = new ThreadPerTaskExecutor();

            executor.Execute(delegate
            {
                SimpleMessageListenerContainer listenerContainer =
                    (SimpleMessageListenerContainer)
                    ctx.GetObject("Spring.Messaging.Nms.Listener.SimpleMessageListenerContainer#0");
                ISessionAwareMessageListener messageListener =
                    (ISessionAwareMessageListener)listenerContainer.MessageListener;
                messageListener.OnMessage(new StubTextMessage("message-driven-test"),
                                          new StubSession("message-driven-test"));
            });

            IMessage message = channel.Receive(TimeSpan.FromMilliseconds(3000));

            Assert.That(message, Is.Not.Null);
            Assert.That(message.Payload, Is.EqualTo("message-driven-test"));
            ctx.Stop();
        }
コード例 #2
0
        public void AdpaterWithDestinationAndDefaultConnectionFactory()
        {
            XmlApplicationContext ctx    = (XmlApplicationContext)NmsTestUtils.GetContext(@"Nms\Config\NmsInboundWithDestinationAndDefaultConnectionFactory.xml");
            IPollableChannel      output = (IPollableChannel)ctx.GetObject("output");
            IMessage message             = output.Receive(timeoutOnReceive);

            Assert.That(message, Is.Not.Null);
            Assert.That(message.Payload, Is.EqualTo("polling-test"));
            ctx.Stop();
        }