Add Pub/Sub (RSB) to an existing WCF service

40 views
Skip to first unread message

Eric Quist

unread,
Jun 17, 2011, 6:38:34 AM6/17/11
to Rhino Tools Dev
I have never used RSB or Rhino queues, and I've had a hard time to
find an example of how to configure and set up RSB 1.8 correctly for
what I want to do. I have an existing WCF service code base and as a
first step I want to add some events to this code and have subscribers
that do some things delayed from the normal flow.

I have a solution with multiple projects, and the published of the
events and the subscribers of the events is not in the same project,
and I would prefer them to run in the same process. The service is now
hosted in IIS (ASP.NET Development Server in development environment).

Sp project E has event messages defined.
Project X does a bus.Notify() with an event.
Project Y has a class that implements ConsumerOf<> for this event.

Project W is the web project referenceing both X and Y, and also the
project doing the configuration. This is what I do now (and this does
not cause any Consume methods in project Y to be called (aka does not
work)).

I have a ServerInstaller inheriting from AbstractBootStrapper, but the
class is empty.
I have a AppInitialize code that runs:

var host = new Rhino.ServiceBus.Hosting.DefaultHost();
host.Start<ServerInstaller>();

My web.config has the following:

<castle>
<facilities>
<facility id="rhino.esb" >
<bus threadCount="1"
numberOfRetries="5"
endpoint="rhino.queues://localhost:31312/Server"
name="IRMA_Server"
queueIsolationLevel="ReadCommitted"
transactional="true"
/>

<messages>
<add
name="E.Events"
endpoint="rhino.queues://localhost:31312/Server" />
</messages>
</facility>
</facilities>
</castle>

I get no errors when calling start and there have been folders created
(Server.esent and Server_subscriptions.esent).

Can anyone show me how to do the propper configuration or point me to
any documentation?
I have already checked http://hibernatingrhinos.com/open-source/rhino-service-bus
including the links provided there.

I also tried to use RemoteAppDomainHost and a second configuration
file for the event consumers, inspired by
https://github.com/BjRo/LearningRhinoServiceBus/blob/master/Source/E8_Inprocess_deployment_of_multiple_endpoints_using_Rhino.Queues_as_transport
but I did not get that working. It failed fast, complaining about
assemblies not beeing available under the ASP.NET temporary directory.

Any help would be appreciated.
Thanks, Eric

René M. A

unread,
Jun 18, 2011, 2:38:00 PM6/18/11
to rhino-t...@googlegroups.com
Well your second approach with the RemoteAppDomainHost should be the way to go. You need to have a host for both the publisher of the events and the consumers of the events. And if you want them in the same process I guess the only way is to have the service bus for the event consumers hosted in a remote appdomain.

I have never tried to to use the RemoteAppDomainHost in a web application, maybe the appdomain created doesn't get the applicationbase path set correctly? Try using the constructor where you can specify the bin path of your web application along with the bootstrapper type:

public RemoteAppDomainHost(string assemblyPath, Type boosterType)

You then need to specify your configuration file using the following method on the RemoteAppDomainHost:

public RemoteAppDomainHost Configuration(string configFile)

It would then look something like this in your code:
var consumerHost = new RemoteAppDomainHost("path to web app assemblies",  typeof(ConsumerBootStrapper))
                .Configuration("Consumers.config");
consumerHost .Start();


Don't know if it will solve your problem, but its worth a shot...

Eric Quist

unread,
Jun 19, 2011, 4:21:13 PM6/19/11
to Rhino Tools Dev
I reverted to more of a step by step approach, instead of trying to
put it in place in my "big" code base immediately and I blogged about
it here:
http://blog.irm.se/blogs/eric/archive/2011/06/18/Getting-Started-with-Pub_2F00_Sub-using-Rhino-Service-Bus.aspx
http://blog.irm.se/blogs/eric/archive/2011/06/19/Consuming-Events-in-the-Same-Process-as-the-Publisher-with-Rhino-Service-Bus.aspx
http://blog.irm.se/blogs/eric/archive/2011/06/19/Hosting-Rhino-Service-Bus-in-IIS.aspx

In short I get it working with DefaultHost, but I think it could be
interesting to get it working with RemoteAppDomainHost too.
I tried your suggestion and it stops complaining about assmebly load
exception, but instead I get a ArgumentException complaining that the
string can't be empty. I then tried to send the path to the assembly
(and not just the folder) but that gives me a
ConfigurationErrorsException saying "could not find facility
configuration section with the same name of the facility". I'm to new
to RSB and Castle to have any real clue. When searching the exception
I found a tip too check the casing of the facility id, but that is
correct in my config-files.

Any suggestions on how to get the code running with
RemoteAppDomainHost instead of DefaultHost is apprecieated.

Thanks, Eric

René M. Andersen

unread,
Jun 21, 2011, 2:29:38 PM6/21/11
to rhino-t...@googlegroups.com
Did you remenber to set the Configuration property of the RemoteAppDomainHost to point to your config file?
Could you post the stack trace from the ArgumentException?

-René

Daniel Auger

unread,
Jun 24, 2011, 2:32:31 PM6/24/11
to Rhino Tools Dev
I've been tinkering around with the same thing over the past few
weeks. I'm hosting RSB in an asp.net MVC 3 app using MSMQ. I decided
to give up on the remote app domain approach, as it seems to be an
endless rabbit hole of issues due to the temporary folders the spawned
app domains run in, especially if you are doing a lot of IoC. It was
getting to be too much trouble for the simple single app instance
queuing that I want. A host that lives and dies with the application's
app domain is fine for what I am doing.

It might be worth mentioning that I have successfully hosted multiple
DefaultHost instances at the same time in the application. I have one
host for standard messaging, and another host for things that need to
be throttled.

In general, everything seems to work fine when running the site under
full IIS. However, I run into weird subscription issues when using IIS
7 express or Cassini via Visual Studio. After the app goes idle and it
receives a new request, the host start / bootstrapping code gets
called, but a subscription isn't created. Restarting visual studio
fixes this. I'm not very concerned about this however since I can use
IIS as my host during development.

- Dan

On Jun 19, 3:21 pm, Eric Quist <equ...@hotmail.com> wrote:
> I reverted to more of a step by step approach, instead of trying to
> put it in place in my "big" code base immediately and I blogged about
> it here:http://blog.irm.se/blogs/eric/archive/2011/06/18/Getting-Started-with...http://blog.irm.se/blogs/eric/archive/2011/06/19/Consuming-Events-in-...http://blog.irm.se/blogs/eric/archive/2011/06/19/Hosting-Rhino-Servic...
Reply all
Reply to author
Forward
0 new messages