How can use config section in rebus 2? - config

I'm trying to configure rebus using app.config. This lines are working in older versions of rebus, but in the new version (Rebus 2) it does not work.
.Transport(t => t.UseMsmqAndGetInputQueueNameFromAppConfig())
.MessageOwnership(o => o.FromRebusConfigurationSection())
What are the equivalent ones in rebus 2?

Unfortunately, there's no equivalent for the queue name and worker configuration in Rebus 2.
You can configure your endpoint mappings with the Rebus.XmlConfig package by going
Configure.With(...)
(...)
.Routing(t => t.AddEndpointMappingsFromAppConfig())
(...)
though.
Maybe there will be some way of picking up settings from app.config/web.config in the future - but the configuration thing is one big thing that I know will not be portable to .NET core if it's based on ConfigurationManager.AppSettings, so I intentionally left it out.

Related

Upgrading v2 -> v4.3, Problem with Translation and changing from Services to Facades

we are busy upgrading from v2 to v4.3 and have run into some issues with Transalations and switching to Facades. We have followed the upgrade docs 2-3 then 3-4.
The first issue we are facing is that we need to include all the individual translations files (order, checkout, etc) whereas before we just needed the single translations and translationsChunks config as per (https://sap.github.io/spartacus-docs/i18n/#getting-started), and having our custom overrides in the translationOverwrites and provided it in the config was sufficient. This does not work anymore, are we perhaps missing a step and is providing each individual translation file the correct approach?
The second issue is changing our existing calls from Service to its Facade counterpart/replacement as per the upgrade docs, the facade methods are abstract and the implementation (the Service) is not executed. Changing back to the Service class executed the correct code. Again, are we missing an upgrade step or should we ignore the upgrade doc and continue using the Service?

NServiceBus configuration in netcore 3.1 Startup

I've gone through all the documentation and examples of setting up NServiceBuse in NetCore, however, all the examples have the configuration being done in the Program.cs (Host.CreateDefaultBuilder().UseNServiceBus()).
I would like to know if I can configure NServiceBus in the ConfigureServices method of Program.cs.
The reason is that in the HostBuilder I'm building up all of the IConfiguration options (e.g. reading from appsettings.json, EnvironmentVariables, AzureKeyVault, ConfigMaps, etc.) and the Logger implementation. By the time ConfigureServices is called, all of those have been resolved. I need to be able to get things like connection strings from the IConfiguration, and so I don't believe it will work to do it in the HostBuilder.
It looks like a lot of work might be being done under the covers to inject the IMessageSession and scan for IHandlMessages instances. That should be able to be done in the Service.
Edit: Forgot to add, because it is in the Program.cs and we are using Serilog, I do not have a LoggerFactory. The LoggerFactory is registered and injected by the Services, but I cannot get it at this point in startup.
Looks like this isn't an option. I was able to have a workaround to get it all working, which is just to put it in the Program() and just make sure it is called after all the other configuration is done. It doesn't seem ideal and seem to be an anti-pattern from where netcore 3 is going.
I'd like to add that this is a poor design choice. I should be able to register my stuff in startup and package scanning shouldn't be happening.
This is a neat project, but I think that for any non-trivial development it may be left lacking.
The reason is that I would like to have a web host with multiple endpoints and I cannot do that without running two full instances (https://docs.particular.net/samples/hosting/generic-multi-hosting/).
My workflow is
message comes in to do all the work
message #1 starts a saga with 100+ messages
each message publishes an update that it is done, so that the UI can check the status of the Saga
The messages from #3 are not handled until all 100+ messages are processed (FIFO).
What I'm wanting to do is have a second queue (we're using Azure service bus) to listen for the worker updates on and update the UI.
Although you already have a workaround I have build a similar setup as you described with with Serilog as logger and NServiceBus. You can access the configuration in Program.cs like so:
public static IHostBuilder CreateHostBuilder() =>
Host.CreateDefaultBuilder()
.ConfigureAppConfiguration()
.UseSerilog()
.UseNServiceBus(c => NServiceBusSetup.Configure(c.Configuration, c.HostingEnvironment))
In the self made method NServiceBus.Configure you can setup your endpoint.

NserviceBus 6 use MsmqTransport not working

We are using NSB 6.0. I have set up RabbitMQTransport and MsmqTransport on my configuration with following code
if (this.UseRabbitMQ)
{
config.UseTransport<RabbitMQTransport>().Transactions(TransportTransactionMode.ReceiveOnly);
}
else
{
config.UseTransport<MsmqTransport>().Transactions(TransportTransactionMode.ReceiveOnly);
}
I have no problem with RabbitMQTransport, But as soon as I switch to MsmqTransport I have the following error.
"The given key (RabbitMQ.RoutingTopologySupportsDelayedDelivery) was not present in the dictionary.'"
I'm not sure what's the requirement to run either one transport or another.
RabbitMQ has a feature that is picked up when assembly scanning is taking place and executed even though it's not configured to be the transport. You'll have to explicitly exclude RabbitMQ transport assembly from scanning using assembly scanning API.

NServiceBus 4.0.4 Subscriber very slow

I have a problem with my publish/subscribe implementation. I'm upgrading from NServiceBus version 2.6 to 4.0.4 and everything seems okay as far as I can understand from the logs but the messages are processed really slowly by the subscriber. I use NServiceBus.Host.exe.
In the old implementation I have configured threads as follows:
<MsmqTransportConfig
ErrorQueue="error"
NumberOfWorkerThreads="40"
MaxRetries="5" />
And the messages go through with nice speed.
In the new implementation I've tried to make the changes needed for the configurations:
<TransportConfig
MaximumConcurrencyLevel="10"
MaxRetries="5"
MaximumMessageThroughputPerSecond="500"/>
Am I missing something critical?
I have a valid license so I should have max threads in use. I haven't got RavenDB or SQL, the implementation uses MSMQ, I've disabled Sagas and TimeoutManager in my subscribers configuration code:
NServiceBus.SetLoggingLibrary.Log4Net(log4net.Config.XmlConfigurator.Configure);
Configure.Features.Disable<Sagas>();
NServiceBus.Configure.With()
.DefaultBuilder()
.UseTransport<Msmq>()
.DisableTimeoutManager()
.UnicastBus()
.LoadMessageHandlers();
I did a crude test and the difference in my development environment is so that the 2.6 version handled approximately 80 messages per second and the 4.0.4 version handled approximately 8 messages per second - which is really very bad. So something's wrong here and I just can't seem to find what it is.
Edit: It looks like the problem was generated from our project structure, for some reason the older version of NServiceBus didn't mind our structural approach with generic subsrcriber that uses MEF to load the actual subsrciber-assemblies but the new one went to sleep. I changed the folder structure and now the subscriber works as intended. So the configurations I was using work just fine, but I did delete MaximumMessageThroughputPerSecond from my settings so that it won't present a future problem since the aim is to be as fast as is possible.

NServiceBus Loading All Assemblies Regardless of Setting

I am trying to run an NServiceBus solution containing several endpoint configs in one directory. I am executing the host.exe with (among other things) /endpointConfigurationType:"class, assembly".
The host correctly isolates itself to using only the one endpoint config, but then it appears to scan the directory anyway, loading and leveraging any NSB interfaces found in other DLLs that are used by the other services. For example, the IWantToRunAtStartup implementations in other endpoint DLLs are being executed even though I only expect NSB to care about interfaces found in /endpointConfigurationType.
What all steps are required to deploy an NSB solution to a flat folder structure, such that NSB will only concern itself with the endpoint it is told to execute?
See the "File Scanning" section of this page:
http://support.nservicebus.com/customer/portal/articles/856698-the-nservicebus-host
The following should work:
Configure.With(Assembly.GetExecutingAssembly())
.NinjectBuilder(kernel)
.FileShareDataBus(BasePath)
.UnicastBus()
.MsmqSubscriptionStorage()
.PurgeOnStartup(false)
.XmlSerializer()
.MsmqTransport();
Regarding the installation, just make sure you run /install for each /endpointConfigurationType, see http://support.nservicebus.com/customer/portal/articles/856698#installation