How to send message within Satellite OnMessage

Hi,

When the OnMessage triggered within a Satellite feature, I want to send message to another endpoint, but it doesn’t look like I have IMessageHandlerContext , how can I do the .Send in OnMessage?

Task OnMessage(IBuilder builder, MessageContext context)
{
var newMessage = New NSBMessage();

//this doesn’t work:
context.Send(newMessage );
}

Thanks.

Hi Todd,

By design, satellites should only ingest data. Can you explain why you are thinking about using a satellite?

Satellites need to be registered in a feature. Features allow registering startup tasks. You can capture the message session of a startup task and provide that message session to the OnMessage function. The order of execution will guarantee that feature startup tasks run before the messages start coming into the satellite.

Another alternative is to use NServiceBus.Raw community package.

Regards
Daniel

Hi Daniel,

Thanks for your reply I will try the message session.

What I’m trying to do is having a satellite monitoring audit queue, so every messages goes to audit queue OnMessage will be triggered, and I will look into the message type, if the message comes to audit queue match certain type, then I will create another message and send that message to a different endpoint.

Thanks a lot.

Hi Todd,

What thus that other endpoint do with the message that is forwarded to it? And what type of messages are those?

Regards
Daniel

Hi Daniel,

What I’m trying to do is something like this:

Task OnMessage(IBuilder builder, MessageContext context)
{
if(context.Header[“Nservicebus.EnvelopedMessageType”].Contains(“transaction”))
{
var newMessage = New NSBMessage();

       context.Send("AnotherEndPoint", newMessage );

}

}

And on “AnotherEndPoint” it has public class Handler :
IHandleMessages ‘<‘NSBMessage’>’ and do some extra process according to business requirement.

Basically the satellite need to monitor audit queue and identify transaction type, then create a nservicebus message send to another endpoint.

Thanks.

Hi Todd,

It’s really hard to understand why you’re trying to achieve what you wrote down here. Perhaps there is a feature inside NServiceBus that already does this, or a much simpler way to achieve what you’re trying to do.

Audit messages are only send when an incoming messages is successfully processed. Are you trying to forward specific messages somewhere? For what reason? Perhaps you want all messages of a specific type to also end up in a different endpoint? If you tell us what you’re trying to achieve, perhaps there’s a better solution then checking for audit messages in a satellite?