Skip to content

Instantly share code, notes, and snippets.

@djmnz
Last active April 20, 2016 06:09
Show Gist options
  • Save djmnz/28bc981f955d487fa7833b941e41ddfd to your computer and use it in GitHub Desktop.
Save djmnz/28bc981f955d487fa7833b941e41ddfd to your computer and use it in GitHub Desktop.
Cached error from MassTransit 3.2.4
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MassTransit;
using MassTransit.AzureServiceBusTransport;
using MassTransit.Util;
using Microsoft.ServiceBus;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var busControl = Bus.Factory.CreateUsingAzureServiceBus(sbc =>
{
var host = sbc.Host("<connection string>", h =>
{
h.OperationTimeout = TimeSpan.FromSeconds(5);
});
sbc.UseJsonSerializer();
});
using (busControl.Start())
{
TaskStatus first = TaskStatus.Created;
Console.WriteLine("Disable your network now");
Console.ReadLine();
Console.WriteLine("Sending First Message");
busControl.Publish(new FirstMessage()).ContinueWith(t => first = t.Status).Wait();
Console.ReadLine();
Console.WriteLine("You now need to enable your network, sending second type of msg. 1st Status = {0}", first.ToString());
Console.ReadLine();
busControl.Publish(new SecondMessage()).ContinueWith(t => Console.WriteLine("2nd Status = {0}", t.Status.ToString())); //this message should be OK when your network is OK
Console.WriteLine("Second message type sent... now we are going to send the first message again");
Console.ReadLine();
busControl.Publish(new FirstMessage()).ContinueWith(t => Console.WriteLine("3rd Status = {0}", t.Status.ToString())); // this message should fail EVEN when your network is OK
Console.WriteLine("The 3rd status is faulted because of first error being cached?");
Console.ReadLine();
}
Console.ReadLine();
}
}
public class SecondMessage
{
}
public class FirstMessage
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment