Skip to content

Commit

Permalink
Split servicebus component into three separate components and add a f…
Browse files Browse the repository at this point in the history
…ourth 'glacial' topic that gets used once every 12 hours (#157)

Signed-off-by: John Ewart <[email protected]>

Signed-off-by: John Ewart <[email protected]>
  • Loading branch information
johnewart authored Dec 14, 2022
1 parent c510cd2 commit 35663f1
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 9 deletions.
56 changes: 54 additions & 2 deletions longhaul-test/azure-service-bus-pubsub.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: longhaul-sb
name: longhaul-sb-rapid
namespace: longhaul-test
spec:
type: pubsub.azure.servicebus
Expand All @@ -17,4 +17,56 @@ spec:
name: sb-conn
key: sb-conn
auth:
secretStore: longhaul-kv
secretStore: longhaul-kv

---
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: longhaul-sb-medium
namespace: longhaul-test
spec:
type: pubsub.azure.servicebus
version: v1
metadata:
- name: connectionString
secretKeyRef:
name: sb-conn
key: sb-conn
auth:
secretStore: longhaul-kv

---
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: longhaul-sb-slow
namespace: longhaul-test
spec:
type: pubsub.azure.servicebus
version: v1
metadata:
- name: connectionString
secretKeyRef:
name: sb-conn
key: sb-conn
auth:
secretStore: longhaul-kv

---
apiVersion: dapr.io/v1alpha1
kind: Component
metadata:
name: longhaul-sb-glacial
namespace: longhaul-test
spec:
type: pubsub.azure.servicebus
version: v1
metadata:
- name: connectionString
secretKeyRef:
name: sb-conn
key: sb-conn
auth:
secretStore: longhaul-kv

16 changes: 13 additions & 3 deletions pubsub-workflow/Controllers/PubsubController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public class PubsubController : ControllerBase
internal static DateTime lastRapidCall = DateTime.Now;
internal static DateTime lastMediumCall = DateTime.Now;
internal static DateTime lastSlowCall = DateTime.Now;
internal static DateTime lastGlacialCall = DateTime.Now;

[Topic("longhaul-sb", "rapidtopic")]
[Topic("longhaul-sb-rapid", "rapidtopic")]
[HttpPost("rapidMessage")]
public IActionResult RapidMessageHandler() {
var lastHit = lastRapidCall;
Expand All @@ -27,7 +28,7 @@ public IActionResult RapidMessageHandler() {
return Ok();
}

[Topic("longhaul-sb", "mediumtopic")]
[Topic("longhaul-sb-medium", "mediumtopic")]
[HttpPost("mediumMessage")]
public IActionResult MediumMessageHandler() {
var lastHit = lastMediumCall;
Expand All @@ -36,13 +37,22 @@ public IActionResult MediumMessageHandler() {
return Ok();
}

[Topic("longhaul-sb", "slowtopic")]
[Topic("longhaul-sb-slow", "slowtopic")]
[HttpPost("slowMessage")]
public IActionResult SlowMessageHandler() {
var lastHit = lastSlowCall;
lastSlowCall = DateTime.Now;
Console.WriteLine($"Slow subscription hit at {lastSlowCall}, previous hit at {lastHit}");
return Ok();
}

[Topic("longhaul-sb-glacial", "glacialtopic")]
[HttpPost("glacialMessage")]
public IActionResult GlacialMessageHandler() {
var lastHit = lastGlacialCall;
lastGlacialCall = DateTime.Now;
Console.WriteLine($"Glacial subscription hit at {lastGlacialCall}, previous hit at {lastHit}");
return Ok();
}
}
}
14 changes: 10 additions & 4 deletions pubsub-workflow/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@

namespace PubsubWorkflow
{

class PubsubWorkflow
{
private static string pubsubName = "longhaul-sb";
private static string rapidPubsubName = "longhaul-sb-rapid";
private static string mediumPubsubName = "longhaul-sb-medium";
private static string slowPubsubName = "longhaul-sb-slow";
private static string glacialPubsubName = "longhaul-sb-glacial";

static void Main(string[] args)
{
Expand All @@ -29,9 +33,10 @@ static void Main(string[] args)

var host = CreateHostBuilder(args).Build();

var rapidTimer = StartPublishingMessages(10, pubsubName, "rapidtopic");
var mediumTimer = StartPublishingMessages(300, pubsubName, "mediumtopic");
var slowTimer = StartPublishingMessages(3600, pubsubName, "slowtopic");
var rapidTimer = StartPublishingMessages(10, rapidPubsubName, "rapidtopic");
var mediumTimer = StartPublishingMessages(300, mediumPubsubName, "mediumtopic");
var slowTimer = StartPublishingMessages(3600, slowPubsubName, "slowtopic");
var glacialTimer = StartPublishingMessages(3600*12, glacialPubsubName, "glacialtopic");

host.Run();

Expand All @@ -40,6 +45,7 @@ static void Main(string[] args)
rapidTimer.Dispose();
mediumTimer.Dispose();
slowTimer.Dispose();
glacialTimer.Dispose();
}

public static IHostBuilder CreateHostBuilder(string[] args) =>
Expand Down

0 comments on commit 35663f1

Please sign in to comment.