nServiceBus registering subscribers but subscribers not receiving messages
My subscriber queue isn't picking up messages. It looks like they're ending up in the error queue.
The only unusual aspect to this is that the publisher is receiving messages which are generated from a website (and then a class library) which are then WCF'd to the publisher who publishes on behalf of the website/class library.
If I remove the publisher's <add Messages="">
then I get an error saying the publisher doesn't know where to route the messages.
No destination specified for message Messages.ContactRequest. Message cannot be sent. Check the UnicastBusConfig section in your config file and ensure that a MessageEndpointMapping exists for the message type.
Help! I've almost cut'n'pasted the WcfIntegration and PubSub samples, so I don't know why it isn't working!
PUBLISHER:
<MsmqTransportConfig
InputQueue="RSApp_InputQueue"
ErrorQueue="error"
NumberOfWorkerThreads="1"
MaxRetries="5"
/>
<UnicastBusConfig
DistributorControlAddress=""
DistributorDataAddress=""
ForwardReceivedMessagesTo="">
<MessageEndpointMappings>
<add Messages="Messages" Endpoint="RSApp_InputQueue" />
</MessageEndpointMappings>
</UnicastBusConfig>
SUBSCRIBER:
<!-- SUBSCRIBER -->
<MsmqTransportConfig
InputQueue="RSApp_SubscriberQueue"
ErrorQueue="error"
NumberOfWorkerThreads="1"
MaxRetries="5"
/>
<UnicastBusConfig
DistributorControlAddress=""
DistributorDataAddress=""
ForwardReceivedMessagesTo="">
<MessageEndpointMappings>
<add Messages="Messages" Endpoint="RSApp_InputQueue" />
</MessageEndpointMappings>
</UnicastBusConfig>
p.s. does the WCF endpoint automatically created by nservicebus also automatically bus.publish<>() the message?
p.s. I don't understand what I need to do with this:-
[ServiceContract] public interface IContactRequestService { [OperationContract(Action = "http://tempuri.org/IWcfServiceOf_ContactRequest_ErrorCodes/Process", ReplyAction = "http://tempuri.org/IWcfServiceOf_ContactRequest_ErrorCodes/ProcessResponse")] ErrorCodes Process(Messages.ContactRequest request); }
Here's my client calling code:-
public void MakeContactRequest(int id, Guid RequestingUserId, Guid RequesteeUserId, Messages.ContactRequestType type)
{
//get extra information
var u = Services.UserService.FetchUserProfile(id);
//add it to local database
var RequestIdentifier = Guid.NewGuid();
//create message
var req = new ContactRequest()
{
contactRequestType = type,
Name = u.DisplayName,
RequestCreationDate = DateTime.Now,
TagLine = u.Tagline,
RequesterUserId = RequestingUserId,
RequesteeUserId = RequesteeUserId,
RequestIdentifier = RequestIdentifier
};
//drop it onto distributed message queue
IContactRequestService client = ChannelFactory.CreateChannel();
try
{
ErrorCodes returnCode = client.Process(req);
}
finally
{
try
{
((IChannel)client).Close();
}
catch
{
((IChannel)client).Abort();
}
}
}
What is wierd is that putting a message on the bus without using WCF works a treat!!
public void Run()
{
Console.WriteLine("This will publish IEvent and EventMessage alternately.");
Console.WriteLine("Press 'Enter' to publish a message.To exit, Ctrl + C");
bool publishIEvent = true;
while (Console.ReadLine() != null)
{
var eventMessage = publishIEvent ? Bus.CreateInstance<ContactRequest>() : new ContactRequest();
Bus.Publish(eventMessage);
Console.WriteL开发者_如何学Cine("Published event ");
publishIEvent = !publishIEvent;
}
NSB will not do the Publish() for you, you have to put that in your message handler just like any NSB endpoint. Exposing the endpoint via WCF doesn't require you to do anything except implement the abstract class WcfService<TRequest,TResponse>. You shouldn't need that other code, since NSB handles it internally. Technically the Publisher shouldn't need a message mapping since it manages subscriptions internally so I'm not sure why you are getting an error there.
If the messages are in the error queue, then you should see an exception in the log. You many want to configure the logging to point to a file or something durable if you are using the Lite(default profile).
精彩评论