Skip to content

Commit

Permalink
Merge branch 'EventGridExplorer' of https://github.com/paolosalvatori…
Browse files Browse the repository at this point in the history
…/ServiceBusExplorer into EventGridExplorer
  • Loading branch information
harrieoriowo committed May 29, 2024
2 parents 1d43822 + e143794 commit f1ed2e4
Show file tree
Hide file tree
Showing 32 changed files with 976 additions and 825 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
name: Build and run unit tests
runs-on: windows-2022
env:
NUnitVersion: '3.15.2'
NUnitVersion: '3.16.3'
steps:
- name: Install NUnit Console Runner and VS project extension
run: |
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ The default location of the executable is C:\ProgramData\chocolatey\lib\ServiceB

More information on our [Chocolatey page](https://chocolatey.org/packages/ServiceBusExplorer).

## Using [Scoop](https://scoop.sh)

```
scoop install extras/servicebusexplorer
```

The default location of the executable is %USERPROFILE%\scoop\apps\servicebusexplorer\current\tools\ServiceBusExplorer.exe.

## Using GitHub
```
curl -s https://api.github.com/repos/paolosalvatori/ServiceBusExplorer/releases/latest | grep browser_download_url | cut -d '"' -f 4
Expand Down
50 changes: 50 additions & 0 deletions src/Common/Abstractions/EventDataMessage.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
namespace ServiceBusExplorer.Abstractions
{
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.Azure.Amqp;
using Microsoft.ServiceBus.Messaging;

public class EventDataMessage : IDisposable
{
readonly EventData eventData;
Stream stream;

public EventDataMessage(EventData eventData)
{
this.eventData = eventData;
stream = eventData.GetBodyStream();
Properties = eventData.Properties;
PartitionKey = eventData.PartitionKey;
SequenceNumber = eventData.SequenceNumber;
Offset = eventData.Offset;
SerializedSizeInBytes = eventData.SerializedSizeInBytes;
EnqueuedTimeUtc = eventData.EnqueuedTimeUtc;
SystemProperties = eventData.SystemProperties;
}

public string PartitionKey { get; private set; }
public long SequenceNumber { get; private set; }
public long SerializedSizeInBytes { get; private set; }
public string Offset { get; private set; }
public DateTime EnqueuedTimeUtc { get; private set; }
public IDictionary<string, object> Properties { get; private set; }
public IDictionary<string, object> SystemProperties { get; private set; }

public Stream GetBodyStream()
{
var memoryStream = new MemoryStream();

stream.CopyTo(memoryStream);
stream.Seek(0L, SeekOrigin.Begin);

return memoryStream;
}

public void Dispose()
{
eventData.Dispose();
}
}
}
2 changes: 1 addition & 1 deletion src/Common/Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

<PackageReference Include="Microsoft.Azure.NotificationHubs" Version="1.0.9" />

<PackageReference Include="WindowsAzure.ServiceBus" Version="6.2.2" />
<PackageReference Include="WindowsAzure.ServiceBus" Version="7.0.1" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Configuration" />
Expand Down
20 changes: 16 additions & 4 deletions src/Common/Helpers/DeadLetterMessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ public DeadLetterMessageHandler(WriteToLogDelegate writeToLog, ServiceBusHelper
#endregion

#region Public methods
public async Task<DeletedDlqMessagesResult> DeleteMessages(List<long?> sequenceNumbers)
public async Task<DeletedDlqMessagesResult> DeleteMessages(List<long?> sequenceNumbers,
bool TransferDLQ)
{
var sequenceNumbersToDeleteList = new List<long?>();
foreach (var number in sequenceNumbers)
Expand All @@ -96,7 +97,7 @@ public async Task<DeletedDlqMessagesResult> DeleteMessages(List<long?> sequenceN
}

var timedOut = false;
var dlqEntityPath = GetDlqEntityPath();
var dlqEntityPath = TransferDLQ ? GetTransferDlqEntityPath() : GetDlqEntityPath();

var messageReceiver = await serviceBusHelper.MessagingFactory.CreateMessageReceiverAsync(
dlqEntityPath,
Expand Down Expand Up @@ -185,7 +186,7 @@ public async Task<DeletedDlqMessagesResult> DeleteMessages(List<long?> sequenceN


public async Task<DeletedDlqMessagesResult> MoveMessages(MessageSender messageSender,
List<long> sequenceNumbers, List<BrokeredMessage> messagesToSend = null)
List<long> sequenceNumbers, bool transferDLQ, List<BrokeredMessage> messagesToSend = null)
{
if (messagesToSend != null)
{
Expand All @@ -196,7 +197,7 @@ public async Task<DeletedDlqMessagesResult> MoveMessages(MessageSender messageSe
}
}

var dlqEntityPath = GetDlqEntityPath();
var dlqEntityPath = transferDLQ ? GetTransferDlqEntityPath() : GetDlqEntityPath();

var messageReceiver = serviceBusHelper.MessagingFactory.CreateMessageReceiver(
dlqEntityPath,
Expand Down Expand Up @@ -368,6 +369,17 @@ string GetDlqEntityPath()
sourceSubscriptionWrapper.SubscriptionDescription.TopicPath,
sourceSubscriptionWrapper.SubscriptionDescription.Name);
}

string GetTransferDlqEntityPath()
{
if (sourceQueueDescription != null)
{
return QueueClient.FormatTransferDeadLetterPath(sourceQueueDescription.Path);
}

throw new Exception("It is currently not supported getting a Transfer Dead-letter queue for a subscription.");
}

void WriteToLog(string message)
{
if (writeToLog != null && !string.IsNullOrWhiteSpace(message))
Expand Down
Loading

0 comments on commit f1ed2e4

Please sign in to comment.