コード例 #1
0
        public void ParticipatingTransactionWithCommit()
        {
            IConnectionFactory connectionFactory = mocks.StrictMock<IConnectionFactory>();
            IConnection connection = mocks.StrictMock<IConnection>();
            ISession session = mocks.StrictMock<ISession>();

            using (mocks.Ordered())
            {
                SetupCommitExpectations(connection, connectionFactory, session);
            }

            mocks.ReplayAll();

            NmsTransactionManager tm = new NmsTransactionManager(connectionFactory);
            ITransactionStatus ts = tm.GetTransaction(new DefaultTransactionDefinition());
            NmsTemplate nt = new NmsTemplate(connectionFactory);
            nt.Execute(new AssertSessionCallback(session));

            TransactionTemplate tt = new TransactionTemplate(tm);
            tt.Execute(delegate(ITransactionStatus status)
                           {
                               nt.Execute(new AssertSessionCallback(session));
                               return null;
                           });

            tm.Commit(ts);

            mocks.VerifyAll();
        }
コード例 #2
0
 private NmsTemplate CreateTemplate()
 {
     NmsTemplate template = new NmsTemplate();
     template.DestinationResolver = mockDestinationResolver;
     template.SessionTransacted = UseTransactedTemplate;
     return template;
 }
コード例 #3
0
 protected override void ConfigureMessageConverter(NmsTemplate nmsTemplate, INmsHeaderMapper headerMapper)
 {
     IMessageConverter converter = nmsTemplate.MessageConverter;
     if (converter == null || !(converter is HeaderMappingMessageConverter))
     {
         HeaderMappingMessageConverter hmmc = new HeaderMappingMessageConverter(converter, headerMapper);
         hmmc.ExtractIntegrationMessagePayload = extractPayload;
         nmsTemplate.MessageConverter = hmmc;
     }
 }
コード例 #4
0
        public void TransactionCommit()
        {
            IConnectionFactory connectionFactory = mocks.StrictMock<IConnectionFactory>();
            IConnection connection = mocks.StrictMock<IConnection>();
            ISession session = mocks.StrictMock<ISession>();

            using (mocks.Ordered())
            {
                SetupCommitExpectations(connection, connectionFactory, session);
            }

            mocks.ReplayAll();

            NmsTransactionManager tm = new NmsTransactionManager(connectionFactory);
            ITransactionStatus ts = tm.GetTransaction(new DefaultTransactionDefinition());
            NmsTemplate nt = new NmsTemplate(connectionFactory);
            nt.Execute(new AssertSessionCallback(session));
            tm.Commit(ts);

            mocks.VerifyAll();
                
        }
 public void AfterPropertiesSet()
 {
     lock(initializationMonitor)
     {
         if (initialized)
         {
             return;
         }
         if (nmsTemplate == null)
         {
             AssertUtils.IsTrue(this.connectionFactory != null
                 && (this.destination != null || this.destinationName != null),
                 "Either a 'jmsTemplate' or *both* 'connectionFactory' and"
                 + " 'destination' (or 'destination-name') are required.");
             nmsTemplate = CreateDefaultNmsTemplate();
         }
         ConfigureMessageConverter(nmsTemplate, headerMapper);
         initialized = true;
     }
 }
コード例 #6
0
ファイル: NmsTemplate.cs プロジェクト: Binodesk/spring-net
 public SendDestinationCallback(NmsTemplate jmsTemplate, IDestination destination, MessageCreatorDelegate messageCreatorDelegate)
 {
     this.jmsTemplate = jmsTemplate;
     this.destination = destination;
     this.messageCreatorDelegate = messageCreatorDelegate;
 }
コード例 #7
0
ファイル: NmsTemplate.cs プロジェクト: Binodesk/spring-net
 public NmsTemplateResourceFactory(NmsTemplate enclosingInstance)
 {
     InitBlock(enclosingInstance);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractNmsTemplateBasedAdapter"/> class.
 /// </summary>
 /// <param name="nmsTemplate">The NMS template.</param>
 public AbstractNmsTemplateBasedAdapter(NmsTemplate nmsTemplate)
 {
     this.nmsTemplate = nmsTemplate;
 }
コード例 #9
0
ファイル: NmsTemplate.cs プロジェクト: Binodesk/spring-net
 public ConvertAndSendMessageCreator(NmsTemplate jmsTemplate, object message, MessagePostProcessorDelegate messagePostProcessorDelegate)
 {
     this.jmsTemplate = jmsTemplate;
     objectToConvert = message;
     this.messagePostProcessorDelegate = messagePostProcessorDelegate;
 }
コード例 #10
0
ファイル: NmsTemplate.cs プロジェクト: Binodesk/spring-net
 public ConvertAndSendMessageCreator(NmsTemplate jmsTemplate, object message, IMessagePostProcessor messagePostProcessor)
 {
     this.jmsTemplate = jmsTemplate;
     objectToConvert = message;
     this.messagePostProcessor = messagePostProcessor;
 }
コード例 #11
0
ファイル: NmsTemplate.cs プロジェクト: Binodesk/spring-net
 public ReceiveCallback(NmsTemplate jmsTemplate, IDestination destination)
 {
     this.jmsTemplate = jmsTemplate;
     this.destination = destination;
 }
コード例 #12
0
ファイル: NmsTemplate.cs プロジェクト: Binodesk/spring-net
 public ReceiveCallback(NmsTemplate jmsTemplate, string destinationName)
 {
     this.jmsTemplate = jmsTemplate;
     this.destinationName = destinationName;
 }
コード例 #13
0
ファイル: NmsTemplate.cs プロジェクト: Binodesk/spring-net
 public ProducerCreatorCallback(NmsTemplate jmsTemplate, ProducerDelegate producerDelegate)
 {
     this.jmsTemplate = jmsTemplate;
     this.producerDelegate = producerDelegate;
 }
コード例 #14
0
ファイル: NmsTemplate.cs プロジェクト: Binodesk/spring-net
            public ProducerCreatorCallback(NmsTemplate jmsTemplate, IProducerCallback producerCallback)
            {
                this.jmsTemplate = jmsTemplate;
				this.producerCallback = producerCallback;
            }
コード例 #15
0
ファイル: NmsTemplate.cs プロジェクト: Binodesk/spring-net
 private void InitBlock(NmsTemplate enclosingInstance)
 {
     enclosingTemplateInstance = enclosingInstance;
 }
 protected abstract void ConfigureMessageConverter(NmsTemplate nmsTemplate, INmsHeaderMapper headerMapper);
 private NmsTemplate CreateDefaultNmsTemplate()
 {
     NmsTemplate template = new NmsTemplate();
     template.ConnectionFactory = connectionFactory;
     if (destination != null)
     {
         template.DefaultDestination = destination;
     } else
     {
         template.DefaultDestinationName = destinationName;
     }
     if (destinationResolver != null)
     {
         template.DestinationResolver = destinationResolver;
     }
     return template;
 }
コード例 #18
0
ファイル: NmsTemplate.cs プロジェクト: Binodesk/spring-net
 public ReceiveSelectedCallback(NmsTemplate jmsTemplate,
                                string destinationName,
                                string messageSelector)
 {
     this.jmsTemplate = jmsTemplate;
     this.destinationName = destinationName;
     this.messageSelector = messageSelector;
 }
コード例 #19
0
        public void TransactionRollback()
        {
            IConnectionFactory connectionFactory = (IConnectionFactory) mocks.CreateMock(typeof (IConnectionFactory));
            IConnection connection = (IConnection) mocks.CreateMock(typeof (IConnection));
            ISession session = (ISession) mocks.CreateMock(typeof (ISession));

            SetupRollbackExpectations(connection, connectionFactory, session);

            mocks.ReplayAll();

            NmsTransactionManager tm = new NmsTransactionManager(connectionFactory);
            ITransactionStatus ts = tm.GetTransaction(new DefaultTransactionDefinition());
            NmsTemplate nt = new NmsTemplate(connectionFactory);
            nt.Execute(new AssertSessionCallback(session));
            tm.Rollback(ts);

            mocks.VerifyAll();
        }
コード例 #20
0
ファイル: NmsTemplate.cs プロジェクト: Binodesk/spring-net
 public SimpleMessageCreator(NmsTemplate jmsTemplate, object objectToConvert)
 {
     this.jmsTemplate = jmsTemplate;
     this.objectToConvert = objectToConvert;
 }
コード例 #21
0
        public void TransactionSuspension()
        {
            IConnectionFactory connectionFactory = mocks.StrictMock<IConnectionFactory>();
            IConnection connection = mocks.StrictMock<IConnection>();
            ISession session = mocks.StrictMock<ISession>();
            ISession session2 = mocks.StrictMock<ISession>();

            Expect.Call(connectionFactory.CreateConnection()).Return(connection).Repeat.Twice();
            Expect.Call(connection.CreateSession(AcknowledgementMode.Transactional)).Return(session).Repeat.Once();
            Expect.Call(connection.CreateSession(AcknowledgementMode.Transactional)).Return(session2).Repeat.Once();

            session.Commit();
            LastCall.On(session).Repeat.Once();
            session2.Commit();
            LastCall.On(session2).Repeat.Once();

            session.Close();
            LastCall.On(session).Repeat.Once();
            session2.Close();
            LastCall.On(session2).Repeat.Once();

            connection.Close();
            LastCall.On(connection).Repeat.Twice();

            mocks.ReplayAll();

            NmsTransactionManager tm = new NmsTransactionManager(connectionFactory);
            ITransactionStatus ts = tm.GetTransaction(new DefaultTransactionDefinition());
            NmsTemplate nt = new NmsTemplate(connectionFactory);

            TransactionTemplate tt = new TransactionTemplate(tm);
            tt.PropagationBehavior = TransactionPropagation.RequiresNew;
            tt.Execute(delegate(ITransactionStatus status)
                           {
                               nt.Execute(new AssertNotSameSessionCallback(session));
                               return null;
                           });

            nt.Execute(new AssertSessionCallback(session));

            tm.Commit(ts);

            mocks.VerifyAll();
        }
コード例 #22
0
ファイル: NmsTemplate.cs プロジェクト: Binodesk/spring-net
 public SendDestinationCallback(NmsTemplate jmsTemplate, string destinationName, IMessageCreator messageCreator)
 {
     this.jmsTemplate = jmsTemplate;
     this.destinationName = destinationName;
     this.messageCreator = messageCreator;
 }
コード例 #23
0
        public void ParticipatingTransactionWithRollback()
        {
            IConnectionFactory connectionFactory = mocks.StrictMock<IConnectionFactory>();
            IConnection connection = mocks.StrictMock<IConnection>();
            ISession session = mocks.StrictMock<ISession>();

            using (mocks.Ordered())
            {
                SetupRollbackExpectations(connection, connectionFactory, session);
            }

            mocks.ReplayAll();

            NmsTransactionManager tm = new NmsTransactionManager(connectionFactory);
            ITransactionStatus ts = tm.GetTransaction(new DefaultTransactionDefinition());
            NmsTemplate nt = new NmsTemplate(connectionFactory);
            nt.Execute(new AssertSessionCallback(session));

            TransactionTemplate tt = new TransactionTemplate(tm);
            tt.Execute(delegate(ITransactionStatus status)
                           {
                               nt.Execute(new AssertSessionCallback(session));
                               status.SetRollbackOnly();
                               return null;
                           });
            try
            {
                tm.Commit(ts);
                Assert.Fail("Should have thrown UnexpectedRollbackException");
            } catch (UnexpectedRollbackException)
            {

            }

            mocks.VerifyAll();
        }
コード例 #24
0
ファイル: NmsTemplate.cs プロジェクト: Binodesk/spring-net
 public SendDestinationCallback(NmsTemplate jmsTemplate, IDestination destination, IMessageCreator messageCreator)
 {
     this.jmsTemplate = jmsTemplate;
     this.destination = destination;
     this.messageCreator = messageCreator;
 }
コード例 #25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NmsDestinationPollingSource"/> class.
 /// </summary>
 /// <param name="nmsTemplate">The NMS template.</param>
 public NmsDestinationPollingSource(NmsTemplate nmsTemplate)
     : base(nmsTemplate)
 {
 }
コード例 #26
0
ファイル: NmsTemplate.cs プロジェクト: Binodesk/spring-net
 public SendDestinationCallback(NmsTemplate jmsTemplate, string destinationName, MessageCreatorDelegate messageCreatorDelegate)
 {
     this.jmsTemplate = jmsTemplate;
     this.destinationName = destinationName;
     this.messageCreatorDelegate = messageCreatorDelegate;
 }