Fire and Forget receive?

51 views
Skip to first unread message

roundcrisis

unread,
Nov 2, 2009, 10:22:07 AM11/2/09
to masstransit-discuss
hi there

(note jsut started playing with MT so bare with me)

I want to implement a simple fire and forget ( based on the simple pub/
sub sample) in MT
The sender looks a bit like this

static void Main(string[] args)
{

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

var container = new DefaultMassTransitContainer
("windsor.xml");
var resolver = container.Resolve<IEndpointFactory>();
var endpoint = resolver.GetEndpoint(new Uri("msmq://
localhost/mt_sender"));

string name;
while ((name = GetName()) != "q")
{
var message = new Message { Name = name };
endpoint.Send(message);
Console.WriteLine("Sent Message with name {0}",
message.Name);
}
container.Dispose();
}

....


How should the consumer look?

My expectation: That i will initialize the consumer and that if the
sender sends a message I will receive it

However it seems like if I have a receiver endpoint :

var endpoint = resolver.GetEndpoint(new Uri("msmq://
localhost/mt_sender"));
endpoint.Receive(MessageReceived);
it will only receive the messages already available in the queue and
if the sender sends new messages, I wont get them .

Question 1: How do i set my receiver so if the sender sends a
message the REceiver will get it?
Question 2: Is my expectation unrealistic and why?

Cheers


Travis Smith

unread,
Nov 2, 2009, 10:42:13 AM11/2/09
to masstrans...@googlegroups.com
http://masstransit.pbworks.com/Consumers

That describes how the consumers work. Basically you implement and interface and register the class to the bus. Take a look at the examples include as well. Our consumers all share the structure (below) that is based off TopShelf hosting. You can create a new instance of this class, passing in the buss, call start, and let it consume the messages, then call stop at some point. Just replace IMessage with your message type.

    public class GenericConsumer : Consumes<IMessage>.All, IServiceInterface
    {
        private readonly IServiceBus _bus;
        private UnsubscribeAction _unsubscribeAction;

        public GenericConsumer(IServiceBus bus)
        {
            _bus = bus;
        }

        public void Consume(IMessage message)
        {
            // do stuff
        }

        public void Start()
        {
            _unsubscribeAction = _bus.Subscribe(this);
        }

        public void Stop()
        {
            var action = _unsubscribeAction;
            if (action != null)
            {
                action();

Dru Sellers

unread,
Nov 2, 2009, 8:53:27 PM11/2/09
to masstrans...@googlegroups.com
did you get it?
-d

roundcrisis

unread,
Nov 3, 2009, 6:46:57 AM11/3/09
to masstransit-discuss
Hi there
Thanks for your answers


that is pretty much what I m doing
Im implementing IBusInterface instad of ISErviceInterface ( its not in
my binaries)
and i can see the consume has started and its usign the right endpoint
address


the consume method is just not beeing called

pointers?

On Nov 3, 1:53 am, Dru Sellers <d...@drusellers.com> wrote:
> did you get it?
> -d
>

Dru Sellers

unread,
Nov 3, 2009, 6:51:41 AM11/3/09
to masstrans...@googlegroups.com
lets start over.

what does your config look like? for the consuming side.
-d

roundcrisis

unread,
Nov 6, 2009, 6:20:44 AM11/6/09
to masstransit-discuss
Sorry for the delay

My receiver windsor.xml looks like this

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

<facilities>

<facility id="masstransit">

<bus id="main" endpoint="msmq://localhost/mt_receiver">
<!--<subscriptionService endpoint="msmq://localhost/
mt_subscriptions" />-->
<managementService heartbeatInterval="3" />
</bus>

<transports>
<transport>MassTransit.Transports.Msmq.MsmqEndpoint,
MassTransit.Transports.Msmq</transport>
</transports>
</facility>

</facilities>

</configuration>

I had to comment the subscriptionService because otherwise I get an
exception of type InvalidOperationException in MassTransit.dll
:(


On Nov 3, 11:51 am, Dru Sellers <d...@drusellers.com> wrote:
> lets start over.
>
> what does your config look like? for the consuming side.
> -d
>

Dru Sellers

unread,
Nov 6, 2009, 7:34:16 AM11/6/09
to masstrans...@googlegroups.com
do you have to have the subscription service running and that line in the config you have commented out needs to not be. 
-d

Dru Sellers

unread,
Nov 6, 2009, 7:34:40 AM11/6/09
to masstrans...@googlegroups.com
er,

you HAVE to have the subscription service running.
do you?
-d

roundcrisis

unread,
Nov 9, 2009, 10:06:00 AM11/9/09
to masstransit-discuss
yes I do =)

http://pic.gd/2b9f91

Sorry for the delayed answers i ll subscribe to the responses now


On Nov 6, 12:34 pm, Dru Sellers <d...@drusellers.com> wrote:
> er,
>
> you HAVE to have the subscription service running.
> do you?
> -d
>
> On Fri, Nov 6, 2009 at 6:34 AM, Dru Sellers <d...@drusellers.com> wrote:
> > do you have to have the subscription service running and that line in the
> > config you have commented out needs to not be.
> > -d
>

roundcrisis

unread,
Nov 9, 2009, 10:16:57 AM11/9/09
to masstransit-discuss
Ok i cansee there is a problem with AMessage ...checking it out

Dru Sellers

unread,
Nov 9, 2009, 10:35:30 AM11/9/09
to masstrans...@googlegroups.com
ok. let me know how it goes.
-d

roundcrisis

unread,
Nov 9, 2009, 11:35:24 AM11/9/09
to masstransit-discuss
Actually getting the same error message in Masstransit.Play, however
the sample does work,
...
will look at this later on



On Nov 9, 3:35 pm, Dru Sellers <d...@drusellers.com> wrote:
> ok. let me know how it goes.
> -d
>

Dru Sellers

unread,
Nov 9, 2009, 11:41:54 AM11/9/09
to masstrans...@googlegroups.com
ok
Reply all
Reply to author
Forward
0 new messages