0

I'm getting an error when using Bus.SendToQueues, detailed error at end of question.

I have an azure queue set up with a storage account and key and I'm trying to use Bus.SendToSites to have an on premise servicebus handler using msmq send a message to the azure site.

Trying to get a gateway going, as per: http://support.nservicebus.com/customer/portal/articles/859548-the-gateway-and-multi-site-distribution, and I'm using this configuration:

App.config: (Am I setting up the site correctly?)

<section name="GatewayConfig" type="NServiceBus.Config.GatewayConfig, NServiceBus.Core" />
<GatewayConfig>
  <Sites>
    <Site Key="Azure" Address="http://<!--STORAGE ACCOUNT NAME-->.queue.core.windows.net/<!--STORAGE ACCOUNT KEY-->" ChannelType="Http"/>
  </Sites>
</GatewayConfig>

Handler:

Bus.SendToSites(new[] { "Azure" }, message);

At runtime, I'm getting the following:

error: Failed to send message to address: The distributor's data address, used as the return address of messages sent by this endpoint..gateway@HFORTE

Inner Exception: {"Format name is invalid."}

Stacktrace: at System.Messaging.MessageQueue.MQCacheableInfo.get_WriteHandle() at System.Messaging.MessageQueue.StaleSafeSendMessage(MQPROPS properties, ITransaction transaction) at System.Messaging.MessageQueue.StaleSafeSendMessage(MQPROPS properties, IntPtr transaction) at System.Messaging.MessageQueue.SendInternal(Object obj, MessageQueueTransaction internalTransaction, MessageQueueTransactionType transactionType) at System.Messaging.MessageQueue.Send(Object obj, MessageQueueTransactionType transactionType) at NServiceBus.Transports.Msmq.MsmqMessageSender.Send(TransportMessage message, Address address) in :line 0

I see that the transport is MSMQ - is that the problem, that MSMQ and Azure are different transport protocols, and if so, how is this remedied?

Hugo Forte
  • 5,718
  • 5
  • 35
  • 44

2 Answers2

2

To use gateways you must have NSB hosted on both sides - sender and receiver. Gateways just open WCF service for NSB endpoint so you can send messages using HTTP protocol.

MSMQ and Azure queue transports cannot be combined in one solution because the IBus instance is a singleton per ce. We had to develop our own "bridge" service using RavenDb. We chose Raven since it has RX-driven event subscription mechanism that is also easy to use. We are also able to save messages (wrapped in some containers) as-is without much dance around since RavenDb is a document database.

Alexey Zimarev
  • 17,944
  • 2
  • 55
  • 83
  • Thanks, that was my fear and experience so far as well. I started working on a relay as well. I'm using a webapi to just send messages to azure as I only need one way communication. – Hugo Forte Feb 04 '14 at 14:09
  • 1
    We use NSB solution that is hosted on premises but using AzureSB as a transport. So we use AzureSB for guaranteed delivery from local to the cloud. But all other local services use MSMQ. So we have this RavenDb-based gateway to exchange messages between those two. Since RavenDb can store messages as-is, plus it supports event subscriptions, it was quite easy to implement. – Alexey Zimarev Feb 04 '14 at 22:14
  • @AlexeyZimarev any more details on this solution, did it live up to expectations? gotchas? better solutions? – Stéphane Jun 14 '16 at 07:47
  • @Stephane We managed to develop a real bridge without any intermediaries, by using advance satellites. But I believe that in NSB 6 you can use have it very straightforward by having two bus instances using different transports. – Alexey Zimarev Jun 14 '16 at 08:19
0

The address of your site should not be the address of your Azure queue. It should be the address of the NServiceBus receiving gateway channel.

In this case, it's just a coincidence that both Azure queues and the NSB gateway use HTTP.

Your sender (hosted on premise) will have this config

<GatewayConfig>
<Sites>
<Site Key="Azure" Address="https://some.address.com" ChannelType="Http"/>
</Sites>
</GatewayConfig>

Your NSB endpoint hosted on Azure will have this gateway config

<GatewayConfig>
<Channels>
<Channel ChannelType="Http" Address="https://some.address.com" Default="True"/>
</Channels>
</GatewayConfig>

Chris Bednarski
  • 3,364
  • 25
  • 33