Created
June 29, 2011 00:54
-
-
Save jrutley/1052659 to your computer and use it in GitHub Desktop.
MassTransit 2.0 beta questions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using MassTransit; | |
using MassTransitExperimentShared; | |
using System.Threading; | |
namespace MassTransitExperiment | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Bus.Initialize(sbc => | |
{ | |
sbc.UseMsmq(); | |
sbc.VerifyMsmqConfiguration(); | |
sbc.UseMulticastSubscriptionClient(x => x.SetNetworkKey("MyNetwork")); | |
sbc.ReceiveFrom("msmq://localhost/ping_queue"); | |
sbc.Subscribe(subs => | |
{ | |
subs.Handler<PongMessage>(msg => Console.WriteLine("Response: " + msg.Counter)); | |
}); | |
}); | |
Console.WriteLine("Press ENTER to send"); | |
Console.ReadLine(); | |
int i = 0; | |
while (true) | |
{ | |
i++; | |
Console.WriteLine("Queuing message #{0}", i); | |
Bus.Instance.Publish<PingMessage>(new PingMessage { Text = "Hi " + i }); | |
Console.ReadLine(); | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using MassTransit; | |
using MassTransitExperimentShared; | |
using System.Threading; | |
namespace MassTransitConsumer | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int responseNumber = 0; | |
Bus.Initialize(sbc => | |
{ | |
sbc.UseMsmq(); | |
sbc.VerifyMsmqConfiguration(); | |
sbc.UseMulticastSubscriptionClient(x => x.SetNetworkKey("MyNetwork")); | |
sbc.ReceiveFrom("msmq://localhost/pong_queue"); | |
sbc.Subscribe(subs => | |
{ | |
subs.Handler<PingMessage>(msg => | |
{ | |
Console.WriteLine(msg.Text); | |
Bus.Instance.Publish<PongMessage>(new PongMessage { Counter = Interlocked.Increment(ref responseNumber) }); | |
}); | |
}); | |
}); | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment