Nservicebus integrated with rabbitmq - publish events from saga

I want to publish events from my saga implementation.
Like this:
public Task Handle(CancelJob message, IMessageHandlerContext context)
log.Info($“JobRequest #{message.JobRequestId} was cancelled.”);

        var jobRequestCancelled = new JobRequestCancelled
            JobRequestId = message.JobRequestId,
            InstanceId = message.InstanceId

        return Task.CompletedTask;

Is there a way to publish to a different queue than what the endpoint for the saga is configured for?
Or can I change the transport for the publish ?

Maybe this isnt the right question. I want to publish events from my Saga implementation, How do i configure the subscriber endpoint to subscribe to these events and not get get confused with the commands that are meant for the Saga? I am using RabbitMQ in the default transport mode.

****** configuration
var endpointConfiguration = new EndpointConfiguration(“Tamaki.Fibonacci”);
var externalNewtonsoftJson = endpointConfiguration.AddDeserializer();

        TransportExtensions<RabbitMQTransport> transport = endpointConfiguration.UseTransport<RabbitMQTransport>();



        IEndpointInstance endpointInstance = await Endpoint.Start(endpointConfiguration).ConfigureAwait(false);

Hi Joe,

can you explain what you mean with

these events and not get get confused with the commands that are meant for the Saga

I don’t understand there what you mean. NServiceBus uses clear semantics that differentiates between commands and events. Commands are sent to a destination and the routing must be configured to map the command to a logical destination. Events are published by a publisher. With RabbitMQ it is sufficient enough to just handle the event. With AutoSubscribe being on by default the transport will setup the topology on the broker that routes the event to the right input queue.

Let me know if you need more information to clarify the behavior.


Daniel, thanks for your response. I found that the issue was related to priming the queue like the examples show with “sendlocal()”. The “sendlocal” created an Auto Bind situation. To recover from that, i deleted the queues in rabbitmq and removed the “sendlocal()” call from my console app. Events are being published and subscribed to as expected now.

1 Like