### Run Docker Compose for Obvs Examples Source: https://github.com/christopherread/obvs/blob/master/README.md This snippet shows how to navigate to the examples directory and start the services defined in the Docker Compose file. It assumes Docker and Docker Compose are installed and configured. ```bash cd examples docker-compose up ``` -------------------------------- ### Obvs.NetMQ Publisher Example Source: https://github.com/christopherread/obvs/blob/master/Obvs.NetMQ/README.md This snippet demonstrates the setup for a publisher using the Obvs.NetMQ library. It is part of the test console applications provided within the project. ```C# Obvs.NetMQ.Tests.Console.Publisher ``` -------------------------------- ### Obvs.NetMQ Subscriber Example Source: https://github.com/christopherread/obvs/blob/master/Obvs.NetMQ/README.md This snippet demonstrates the setup for a subscriber using the Obvs.NetMQ library. It is part of the test console applications provided within the project. ```C# Obvs.NetMQ.Tests.Console.Subscriber ``` -------------------------------- ### Define and Use Custom Service Endpoint in C# Source: https://github.com/christopherread/obvs/blob/master/README.md Provides an example of defining a custom service endpoint (`MyCustomEndpoint`) that can wrap external API calls or integrations. It demonstrates how to integrate this custom endpoint into the Obvs ServiceBus configuration. ```C# public class MyCustomEndpoint : IServiceEndpointClient { Type _serviceType = typeof(IMyServiceMessage); public IObservable Events { get { // subscribe to external MQ broker } } public Task SendAsync(ICommand command) { // call external API } public IObservable GetResponses(IRequest request) { // call external API and wrap response in observable } public bool CanHandle(IMessage message) { return _serviceType.IsInstanceOfType(message); } } IServiceBus serviceBus = ServiceBus.Configure() .WithActiveMQEndpoints() .Named("MyService") .UsingQueueFor() .ConnectToBroker("tcp://localhost:61616") .SerializedAsJson() .AsClientAndServer() .WithEndpoints(new MyCustomEndpoint()) .Create(); ``` -------------------------------- ### Run Obvs Client with .NET Core Source: https://github.com/christopherread/obvs/blob/master/README.md This snippet demonstrates how to run the Obvs client application using the .NET Core runtime. It specifies the target framework netcoreapp3.1. ```csharp cd client dotnet run -f netcoreapp3.1 ``` -------------------------------- ### Implement Request-Response Pattern with Obvs in C# Source: https://github.com/christopherread/obvs/blob/master/README.md Details the implementation of a request-response pattern using Obvs. It shows how to subscribe to incoming requests, reply with a response, and how a client can send a request and handle the response, including error management. ```C# serviceBus.Requests .OfType() .Subscribe(request => serviceBus.ReplyAsync(request, new MyResponse())); serviceBus.GetResponses(new MyRequest()) .OfType() .Take(1) .Timeout(TimeSpan.FromSeconds(1)) .Subscribe(r => Console.WriteLine("Received a response!"), err => Console.WriteLine("Oh no!")); ``` -------------------------------- ### Send Commands with Obvs in C# Source: https://github.com/christopherread/obvs/blob/master/README.md Shows how to send a command using the Obvs ServiceBus. It includes subscribing to incoming commands for logging and then asynchronously sending a `MyCommand` instance. ```C# serviceBus.Commands.Subscribe(c => Console.WriteLine("Received a command!")); await serviceBus.SendAsync(new MyCommand()); ``` -------------------------------- ### Publish Events with Obvs in C# Source: https://github.com/christopherread/obvs/blob/master/README.md Illustrates publishing an event using the Obvs ServiceBus. It involves subscribing to incoming events for logging and then asynchronously publishing a `MyEvent` instance. ```C# serviceBus.Events.Subscribe(e => Console.WriteLine("Received an event!")); await serviceBus.PublishAsync(new MyEvent()); ``` -------------------------------- ### Configure and Create Service Bus with ActiveMQ in C# Source: https://github.com/christopherread/obvs/blob/master/README.md Demonstrates how to configure an Obvs ServiceBus using ActiveMQ as the transport. It specifies the message type, service name, queue usage for commands, broker connection details, JSON serialization, and client/server roles. ```C# IServiceBus serviceBus = ServiceBus.Configure() .WithActiveMQEndpoints() .Named("MyService") .UsingQueueFor() .ConnectToBroker("tcp://localhost:61616") .SerializedAsJson() .AsClientAndServer() .Create(); ``` -------------------------------- ### Define Message Contracts in C# Source: https://github.com/christopherread/obvs/blob/master/README.md Defines the base interface for service messages and specific command, event, request, and response types that inherit from it. These contracts are essential for message identification and type safety within the Obvs framework. ```C# public interface IMyServiceMessage : IMessage { } public class MyCommand : IMyServiceMessage, ICommand { } public class MyEvent : IMyServiceMessage, IEvent { } public class MyRequest: IMyServiceMessage, IRequest { } public class MyResponse : IMyServiceMessage, IResponse { } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.