Skip to content

Instantly share code, notes, and snippets.

View andreasohlund's full-sized avatar

Andreas Öhlund andreasohlund

View GitHub Profile
@andreasohlund
andreasohlund / excersise1.md
Created September 30, 2024 11:07
Excersise

JSON serializer

SimpleBus serializes and deserializes objects for sending and receiving them as messages. Serialization is abstracted, and concrete types are chosen by the user in endpoint configuration. SimpleBus ships with a built-in XML serializer, and other serializers are provided by other packages. Due to the widespread use of JSON, we would like to add a built-in JSON serializer to SimpleBus.

  • Have explicit dependencies passed in via Initialize
  • Should be used for non optional core "things"
  • Can provide public api via FeatureSetupContext
  • Uses the SettingsHolder to hold onto settings
    • Provided via the ctor
    • Should be exposed as ReadOnlySettings internally
  • Can be started and stopped
var routerConfiguation = new RouterConfiguration("Router");
routerConfiguation.AddInterface<MsmqTransport>("MSMQ").DisableMessageDrivenPublishSubscribe();
routerConfiguation.AddInterface<SqlServerTransport>("SQL", t => t.ConnectionString(myConnectionString)).DisableMessageDrivenPublishSubscribe();
routerConfiguation.Chains.AddRule(c => new MetricsPreroutingTerminator("MSMQ", "Particular.Monitoring@some-machine"));
routerConfiguation.UseStaticRoutingProtocol();
var router = Router.Create(routerConfiguation);
await router.Start().ConfigureAwait(false);
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using NServiceBus;
using NServiceBus.MessageInterfaces;
using NServiceBus.Serialization;
Projects ChangesAgents6Build Queue0
Andreas Öhlund  Administration
Run...
Actions
Edit Configuration Settings  
NServiceBusNServiceBus.Gateway3.1 Test (.NET Framework on Windows)
#3.0.1-PullRequest0099.30 (28 Sep 18 11:20)
Overview
//this is called to push messages onto ASQ from the browser
sendMessage(queueKey, message) {
let json = this.orderedJsonStringify(message);
let encodedMessage = btoa(json);
let url = this.tokens[queueKey]; //this is the url for the queue including SAS token for auth. This is stored in a JWT token created at login
this.fetch(url,
{
method: 'post',
public static async Task<InventoryStatusResponse> GetInventoryStatus(string id)
{
var numRetries = 0;
var siteId = "228202-91B";
do
{
try
{
using (var client = new HttpClient())
using System;
using MSMQ;
class Program
{
static void Main(string[] args)
{
//add ref to mqoa30.tlb https://stackoverflow.com/a/8258952/236004
var localMsmq = new MSMQApplication();
@andreasohlund
andreasohlund / TimeoutHandlerBugDetector.cs
Created December 16, 2016 13:37
Detects and throws an exception if the endpoint is exposed to the timeout handler issue
class TimeoutHandlerIssueDetector : Feature
{
public TimeoutHandlerIssueDetector()
{
EnableByDefault();
}
protected override void Setup(FeatureConfigurationContext context)
{
context.RegisterStartupTask(b => new DetectReusedMessages(b.Build<MessageHandlerRegistry>()));

The following types are no longer available

NServiceBus.BinarySerializer

No upgrade instructions provided.

NServiceBus.BsonSerializer

No upgrade instructions provided.

NServiceBus.CircuitBreakers.RepeatedFailuresOverTimeCircuitBreaker

No upgrade instructions provided.