forked from hibernating-rhinos/rhino-esb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Philip Hoy
authored and
Philip Hoy
committed
Jul 1, 2010
1 parent
1430fd5
commit c82b050
Showing
27 changed files
with
1,540 additions
and
388 deletions.
There are no files selected for viewing
This file contains 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
98 changes: 98 additions & 0 deletions
98
Rhino.ServiceBus.Tests/CanSendMsgsFromOneWayBusUsingRhinoQueues.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
using System; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Transactions; | ||
using Castle.Windsor; | ||
using Castle.Windsor.Configuration.Interpreters; | ||
using Rhino.ServiceBus.Impl; | ||
using Rhino.ServiceBus.Internal; | ||
using Rhino.ServiceBus.RhinoQueues; | ||
using Rhino.ServiceBus.Tests.RhinoQueues; | ||
using Xunit; | ||
|
||
namespace Rhino.ServiceBus.Tests | ||
{ | ||
public class CanSendMsgsFromOneWayBusUsingRhinoQueues : WithDebugging,IDisposable | ||
{ | ||
private WindsorContainer container; | ||
|
||
public CanSendMsgsFromOneWayBusUsingRhinoQueues() | ||
{ | ||
if (Directory.Exists("one_way.esent")) | ||
Directory.Delete("one_way.esent", true); | ||
if (Directory.Exists("test_queue.esent")) | ||
Directory.Delete("test_queue.esent", true); | ||
if (Directory.Exists("test_queue_subscriptions.esent")) | ||
Directory.Delete("test_queue_subscriptions.esent", true); | ||
container = new WindsorContainer(new XmlInterpreter("OneWayBusRhinoQueues.config")); | ||
container.Kernel.AddFacility("rhino.esb", new RhinoServiceBusFacility()); | ||
container.AddComponent<StringConsumer>(); | ||
StringConsumer.Value = null; | ||
StringConsumer.Event = new ManualResetEvent(false); | ||
} | ||
|
||
|
||
|
||
[Fact] | ||
public void SendMessageToRemoteBus() | ||
{ | ||
using (var bus = container.Resolve<IStartableServiceBus>()) | ||
{ | ||
bus.Start(); | ||
var transport = new RhinoQueuesTransport(new Uri("null://nowhere:24689/middle"), | ||
new EndpointRouter(), container.Resolve<IMessageSerializer>(), | ||
1, "one_way.esent", IsolationLevel.ReadCommitted, 5); | ||
var oneWay = new RhinoQueuesOneWayBus(new[] | ||
{ | ||
new MessageOwner | ||
{ | ||
Endpoint = bus.Endpoint.Uri, | ||
Name = "System", | ||
}, | ||
}, transport); | ||
|
||
oneWay.Send("hello there, one way"); | ||
|
||
StringConsumer.Event.WaitOne(); | ||
|
||
Assert.Equal("hello there, one way", StringConsumer.Value); | ||
} | ||
} | ||
|
||
[Fact] | ||
public void SendMessageToRemoteBusFromConfigDrivenOneWayBus() | ||
{ | ||
using (var bus = container.Resolve<IStartableServiceBus>()) | ||
{ | ||
bus.Start(); | ||
|
||
using (var c = new WindsorContainer(new XmlInterpreter("OneWayBusRhinoQueues.config"))) | ||
{ | ||
c.Kernel.AddFacility("one.way.rhino.esb", new OnewayRhinoServiceBusFacility()); | ||
c.Resolve<IOnewayBus>().Send("hello there, one way"); | ||
StringConsumer.Event.WaitOne(); | ||
Assert.Equal("hello there, one way", StringConsumer.Value); | ||
} | ||
|
||
|
||
} | ||
} | ||
|
||
public class StringConsumer : ConsumerOf<string> | ||
{ | ||
public static ManualResetEvent Event; | ||
public static string Value; | ||
|
||
public void Consume(string pong) | ||
{ | ||
Value = pong; | ||
Event.Set(); | ||
} | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
container.Dispose(); | ||
} | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<castle> | ||
<facilities> | ||
<facility id="rhino.esb" > | ||
<bus name="test_queue" | ||
threadCount="1" | ||
numberOfRetries="5" | ||
endpoint="rhino.queues://localhost/test_queue" | ||
queueIsolationLevel="ReadCommitted" /> | ||
<messages> | ||
<add name="Rhino.ServiceBus.Tests" | ||
endpoint="rhino.queues://localhost/test_queue"/> | ||
</messages> | ||
</facility> | ||
<facility id="one.way.rhino.esb" > | ||
<messages> | ||
<add name="System.String" | ||
endpoint="rhino.queues://localhost/test_queue"/> | ||
</messages> | ||
</facility> | ||
</facilities> | ||
</castle> |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
using System; | ||
|
||
namespace Rhino.ServiceBus | ||
{ | ||
public interface IOnewayBus | ||
|
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using Rhino.ServiceBus.Impl; | ||
using Rhino.ServiceBus.Internal; | ||
|
||
namespace Rhino.ServiceBus.RhinoQueues | ||
{ | ||
public class RhinoQueuesOneWayBus : IOnewayBus | ||
{ | ||
private MessageOwnersSelector messageOwners; | ||
private ITransport transport; | ||
|
||
public RhinoQueuesOneWayBus(MessageOwner[] messageOwners, ITransport transport) | ||
{ | ||
this.messageOwners = new MessageOwnersSelector(messageOwners, new EndpointRouter()); | ||
this.transport = transport; | ||
this.transport.Start(); | ||
} | ||
|
||
public void Send(params object[] msgs) | ||
{ | ||
transport.Send(messageOwners.GetEndpointForMessageBatch(msgs), msgs); | ||
} | ||
} | ||
} |
Oops, something went wrong.