public static void RegisterServices(IContainer container) { Preconditions.CheckNotNull(container, "container"); // Note: IConnectionConfiguration gets registered when RabbitHutch.CreateBus(..) is run. // default service registration container .Register(_ => container) .Register <IEasyNetQLogger, ConsoleLogger>() .Register <ISerializer, JsonSerializer>() .Register <IConventions, Conventions>() .Register <IEventBus, EventBus>() .Register <ITypeNameSerializer, TypeNameSerializer>() .Register <ICorrelationIdGenerationStrategy, DefaultCorrelationIdGenerationStrategy>() .Register <IMessageSerializationStrategy, DefaultMessageSerializationStrategy>() .Register <IMessageDeliveryModeStrategy, MessageDeliveryModeStrategy>() .Register <IClusterHostSelectionStrategy <ConnectionFactoryInfo>, DefaultClusterHostSelectionStrategy <ConnectionFactoryInfo> >() .Register <IConsumerDispatcherFactory, ConsumerDispatcherFactory>() .Register <IPublishExchangeDeclareStrategy, PublishExchangeDeclareStrategy>() .Register(sp => PublisherFactory.CreatePublisher(sp.Resolve <IConnectionConfiguration>(), sp.Resolve <IEasyNetQLogger>(), sp.Resolve <IEventBus>())) .Register <IConsumerErrorStrategy, DefaultConsumerErrorStrategy>() .Register <IHandlerRunner, HandlerRunner>() .Register <IInternalConsumerFactory, InternalConsumerFactory>() .Register <IConsumerFactory, ConsumerFactory>() .Register <IConnectionFactory, ConnectionFactoryWrapper>() .Register <IPersistentChannelFactory, PersistentChannelFactory>() .Register <IClientCommandDispatcherFactory, ClientCommandDispatcherFactory>() .Register <IHandlerCollectionFactory, HandlerCollectionFactory>() .Register <IAdvancedBus, RabbitAdvancedBus>() .Register <IRpc, Rpc>() .Register <ISendReceive, SendReceive>() .Register <IBus, RabbitBus>(); }
public void SetUp() { eventBus = new EventBus(); var connectionConfiguration = new ConnectionConfiguration { PublisherConfirms = true, Timeout = 1000 }; var logger = MockRepository.GenerateStub <IEasyNetQLogger>(); publisherConfirms = PublisherFactory.CreatePublisher(connectionConfiguration, logger, eventBus); }
public void Should_return_instance_of_publisher_basic() { var eventBus = MockRepository.GenerateStub <IEventBus>(); var logger = MockRepository.GenerateStub <IEasyNetQLogger>(); var connectionConfiguration = new ConnectionConfiguration { PublisherConfirms = false }; publisher = PublisherFactory.CreatePublisher(connectionConfiguration, logger, eventBus); Assert.IsAssignableFrom <PublisherBasic>(publisher); }
private static IMessagePublisher GetSender(PublisherFactory publisherFactory) { string primaryConnectionString = ConfigurationManager.AppSettings[YOUR_PRIMARY_CONNECTION_STRING]; var sender = publisherFactory.CreatePublisher(new ServiceBusPublisherConfiguration() { PrimaryConfiguration = new TopicConfiguration() { ConnectionString = primaryConnectionString, TopicName = "testtopic3", }, ServiceBusPublisherStrategy = ServiceBusPublisherStrategy.Simple }); return(sender); }
private static IMessagePublisher GetSender(PublisherFactory publisherFactory) { var sender = publisherFactory.CreatePublisher(new ServiceBusPublisherConfiguration() { PrimaryConfiguration = new TopicConfiguration() { ConnectionString = "Endpoint=sb://v-dv-dtrc-failover.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=bmTetnCQLAH5+cJqTnlNj+ZtpEkafIcIWw5NQUnSIAU=", TopicName = "testtopic2", }, ServiceBusPublisherStrategy = ServiceBusPublisherStrategy.Simple }); return(sender); }
internal static bool LogCore(LogLevel logLevel, PublishTypes publishType, string source, string userName, string message, Exception exception, bool autoInform) { try { Publisher publisher = PublisherFactory.CreatePublisher(publishType); publisher.Message = message; publisher.Level = logLevel; publisher.Source = source; publisher.UserName = userName; publisher.Exception = exception; publisher.AutoInform = autoInform; if (LogPublishing != null) { var subs = LogPublishing.GetInvocationList(); foreach (LogPublishingEventHandler sub in subs) { sub.Invoke(publisher); } } var result = publisher.Publish(); if (LogPublished != null) { var subs = LogPublished.GetInvocationList(); foreach (LogPublishedEventHandler sub in subs) { sub.Invoke(publisher, result); } } return(result); } catch { return(false); } }