Examples of Ninject configuration?

321 views
Skip to first unread message

Sean Chambers

unread,
Jul 31, 2009, 10:19:15 AM7/31/09
to masstransit-discuss
I have seen the samples of how to configure MT with windsor, but I am
trying to use ninject and seem to be running into some configuration
problems. I run the runtimeservice, the queues are all there but my
message never gets sent/received. Here is my configuration I am doing
in global.asax:

var massTransitModule = new MassTransitModule();
var buildModule = new BuildModule();

var kernel = new StandardKernel(massTransitModule, buildModule);

MsmqEndpointConfigurator.Defaults(config =>
{
config.CreateMissingQueues = true;
});

massTransitModule.AddTransport<MsmqEndpoint>();
massTransitModule.AddBus("nexus_queue", new Uri("msmq://localhost/
nexus_queue"));


StandardKernel is the start point of ninject and you can pass as many
modules in as you wish. That being said, is there anything else I need
to configure in MassTransit other then calling AddTransport and
AddBus?

Thanks

Sean

Dru Sellers

unread,
Jul 31, 2009, 10:28:29 AM7/31/09
to masstrans...@googlegroups.com
so yeah, my ninject chops are not the best. If you have ninject experience you might be better off digging into that area and making it awesome. :)

-d

Dru Sellers

unread,
Jul 31, 2009, 10:29:01 AM7/31/09
to masstrans...@googlegroups.com
take a look at some of the other containers windsor and structure map
-d

Sean Chambers

unread,
Jul 31, 2009, 11:15:21 AM7/31/09
to masstransit-discuss
After glancing at the Windsor facility it seems like it is adding
buses for each of the mt queues? Is this required during the container
setup to register all the different endpoints via container config?

Chris Patterson

unread,
Jul 31, 2009, 11:28:08 AM7/31/09
to masstrans...@googlegroups.com
If you can host some code that uses NInject somewhere that is not working, I'd be happy to dig in and troubleshoot why things are not working for you. I don't have the Ninject Ninja skills, but I should be able to figure out any MT issues.


On Fri, Jul 31, 2009 at 9:19 AM, Sean Chambers <dko...@gmail.com> wrote:

Chris Patterson

unread,
Jul 31, 2009, 11:37:15 AM7/31/09
to masstrans...@googlegroups.com
You don't have to register endpoints, but if you have an endpoint that you want to deploys services behind, you need to create an instance of a service bus that listens to that endpoint. Your service would then subscribe to that service bus to handle messages sent to that endpoint.

Sean Chambers

unread,
Jul 31, 2009, 12:06:00 PM7/31/09
to masstransit-discuss
Ok,

thats what I'm trying to do. It seems like I have everything setup
correctly but my messages never get to my queue that I added. Here is
the configuration code when ninject is setup:

protected override IKernel CreateKernel()
{
var massTransitModule = new MassTransitModule();
var buildModule = new BuildModule();

var kernel = new StandardKernel(massTransitModule, buildModule);

MsmqEndpointConfigurator.Defaults(config =>
{
config.CreateMissingQueues = true;
});

massTransitModule.AddTransport<MsmqEndpoint>();
massTransitModule.AddBus("nexus_builds", new Uri("msmq://localhost/
nexus_builds"));

return kernel;
}

Here is my service that is being called from a controller publishing
the message:

Guid buildId = Guid.NewGuid();
ServiceBus.Publish(new BuildRequestMessage(buildId));

And here is the code of the consumer of the message:

public class BuildAgentService : Consumes<BuildRequestMessage>.All,
IBuildAgent
{
public BuildAgentService(IServiceBus serviceBus)
{
ServiceBus = serviceBus;
}

protected IServiceBus ServiceBus { get; set; }
protected UnsubscribeAction UnsubscribeAction { get; set; }

public void Dispose()
{
ServiceBus.Dispose();
}

public void Consume(BuildRequestMessage message)
{
var buildResult = new BuildResult(true, "got it!!!");
var buildResponseMessage = new BuildResponseMessage
(message.CorrelationId, buildResult);

CurrentMessage.Respond(buildResponseMessage);
}

public void Start()
{
UnsubscribeAction = ServiceBus.Subscribe(this);
}

public void Stop()
{
UnsubscribeAction();
}
}

I start the MassTransit.RuntimeServices.exe and it seems to startup
fine exception it does give one exception:

An exception occurred receiving a message from 'msmq://lenovo-pc/
mt_subscriptions'
SQL Server Compact timed out waiting for a lock. The default lock time
is 2000ms
for devices and 5000ms for desktops. The default lock timeout can be
increased
in the connection string using the ssce: default lock timeout
property. [ Sessio
n id = 2,Thread id = 5992,Process id = 5892,Table name =
SubscriptionSaga,Confli
ct type = x lock (s blocks),Resource = RID: 1054:8 ]


And thats as far as I get. I can zip the code and e-mail it to you if
that would work better? Thank you for taking the time to try to help
me. I appreciate it.

Sean

Chris Patterson

unread,
Jul 31, 2009, 12:20:50 PM7/31/09
to masstrans...@googlegroups.com
SQL Ce is pretty lame and you need to run it a few times before it catches up. If you have a SQL server, follow that setup and it works a million times better.

Sean Chambers

unread,
Jul 31, 2009, 12:34:05 PM7/31/09
to masstransit-discuss
I'll give it a shot with sql server.
Reply all
Reply to author
Forward
0 new messages