Esempio n. 1
0
 private static void PurgeExistingMessagesIfRequested(CreateMsmqEndpointSettings settings)
 {
     if(settings.Address.IsLocal && settings.PurgeExistingMessages)
     {
         MsmqEndpointManagement.Manage(settings.Address, x => x.Purge());
     }
 }
Esempio n. 2
0
 private static void PurgeExistingMessagesIfRequested(CreateMsmqEndpointSettings settings)
 {
     if (settings.Address.IsLocal && settings.PurgeExistingMessages)
     {
         MsmqEndpointManagement.Manage(settings.Address, x => x.Purge());
     }
 }
Esempio n. 3
0
        public static IEndpoint New(CreateMsmqEndpointSettings settings)
        {
            try
            {
                Guard.Against.Null(settings.Address, "An address for the endpoint must be specified");
                Guard.Against.Null(settings.ErrorAddress, "An error address for the endpoint must be specified");
                Guard.Against.Null(settings.Serializer, "A message serializer for the endpoint must be specified");

                var transport = MsmqTransportFactory.New(settings);
                
				// TODO Does this need to be a bus concern?
                PurgeExistingMessagesIfRequested(settings);

                var errorSettings = new CreateMsmqTransportSettings(settings.ErrorAddress, settings);
				if(transport.MsmqAddress.IsTransactional)
					settings.Transactional = true;

                IMsmqTransport errorTransport = MsmqTransportFactory.New(errorSettings);

                var endpoint = new MsmqEndpoint(settings.Address, settings.Serializer, transport, errorTransport);

                return endpoint;
            }
            catch (Exception ex)
            {
                throw new EndpointException(settings.Address.Uri, "Failed to create MSMQ endpoint", ex);
            }
        }
Esempio n. 4
0
        public static IEndpoint New(CreateMsmqEndpointSettings settings)
        {
            try
            {
                Guard.Against.Null(settings.Address, "An address for the endpoint must be specified");
                Guard.Against.Null(settings.ErrorAddress, "An error address for the endpoint must be specified");
                Guard.Against.Null(settings.Serializer, "A message serializer for the endpoint must be specified");

                var transport = MsmqTransportFactory.New(settings);

                // TODO Does this need to be a bus concern?
                PurgeExistingMessagesIfRequested(settings);

                var errorSettings = new CreateMsmqTransportSettings(settings.ErrorAddress, settings);
                if (transport.MsmqAddress.IsTransactional)
                {
                    settings.Transactional = true;
                }

                IMsmqTransport errorTransport = MsmqTransportFactory.New(errorSettings);

                var endpoint = new MsmqEndpoint(settings.Address, settings.Serializer, transport, errorTransport);

                return(endpoint);
            }
            catch (Exception ex)
            {
                throw new EndpointException(settings.Address.Uri, "Failed to create MSMQ endpoint", ex);
            }
        }