Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ERNI-Academy/assets-cloud-servicebus-abstraction
With this package we standardize the usage and implementation of Azure Service bus in all your code.
https://github.com/ERNI-Academy/assets-cloud-servicebus-abstraction
azure events servicebus
Last synced: 3 months ago
JSON representation
With this package we standardize the usage and implementation of Azure Service bus in all your code.
- Host: GitHub
- URL: https://github.com/ERNI-Academy/assets-cloud-servicebus-abstraction
- Owner: ERNI-Academy
- License: mit
- Created: 2022-02-16T08:53:05.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-07-07T08:38:46.000Z (over 2 years ago)
- Last Synced: 2024-05-12T06:34:03.452Z (6 months ago)
- Topics: azure, events, servicebus
- Language: C#
- Homepage:
- Size: 214 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
- awesome-resources - assets-cloud-servicebus-abstraction
README
# About
**Service Bus Topic/Subscriptions Abstraction** is a small dll ( on the next iteration, it will be a nuget package) that provides a robust and reusable implementations.
the main focus of this dll is add the publish and listener features to your owns projects.
[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors)
## Built With
- [.Net Core 3.1](https://docs.microsoft.com/es-es/dotnet/core/whats-new/dotnet-core-3-1)
- [c# 8](https://docs.microsoft.com/es-es/dotnet/csharp/whats-new/csharp-8)## Features
- ServiceBusClient abstraction
- Message abstraction
- Listener client
- Publisher client## Getting Started
At this point, we have to use this project like dll or directly on our production projects.
On next releases, we transform the solution into nuget.
## Prerequisites
- [.Net Core 3.1](https://docs.microsoft.com/es-es/dotnet/core/whats-new/dotnet-core-3-1)
- [c# 8](https://docs.microsoft.com/es-es/dotnet/csharp/whats-new/csharp-8)## Dependencies
- Newtonsoft nuget
- Azure.Messaging.ServiceBus nuget
- .NETStandard 2.0
- System.Text.Json## Installation
At this point, it is possible to use that asset:
- Cloning the repo and use it directly on you solution. On this way, you will have access too entire code.
```sh
git clone https://github.com/ERNI-Academy/assets-cloud-servicebus-abstraction.git
```- Using the dll located on Release folder
## Notes
- At this point only can be used with ServiceBus. On next iteration, it'll be implemented a development mode to be used on localhost environments.
## Object definitions
### ServiceBusClient
```c#
public interface ISBServiceClient
{
IListener GetListener(string topicName = "");
IPublisher GetPublisher(string topicName = "");
}
```### ISBClientConfig client
```c#
public interface ISBConfig
{
public string ConnectionString { get; set; }
public string Topic { get; set; }
public string Subscription { get; set; }
}
```### Listener client
```c#
public interface IListener:IClient
{
void Run(Action callback);
}
```### Publisher client
```c#
public interface IPublisher:IClient
{
void SendAsync(dynamic message);
}
```### IMessage
```c#
public interface IMessage : IAbstractMessage
{
dynamic Value { get; }
}
```### IAbstractMessage
```c#
public interface IAbstractMessage
{
Guid Id { get; }
}
```## Samples
### Create ServiceBusClient
The ServiceBusClient is the services that will create the proper clients( listener or publisher).This service use like configuration a own object **SBConfig** that implement **ISBConfig**, so, if you want to change the end implementation of that object you should implement a new one and resolve it on IoC .
```c#
ISBServiceClient service = new ServiceBusClient(new SBConfig()
{
ConnectionString = "Endpoint=sb://sbasset.servicebus.windows.net/;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=+lS3xJGQRsMeucKYHt2SG08VhRGCLZA++CqJm7lhlrQ=",
Topic = "assetsample",
Subscription = "assetsubs"
});
```- To find the correct connectionstring you should go to azure portal -> ServiceBus account -> Shared access policies and there , choose the **primary key**
### Create Listener Client
The listener client is an artifact that bring you the capability to be connected on streaming to the concrete subscription.Once you add a callback to this artifact, your software received all messages sent it to the Topic related with the subscription configured.
```c#
IListener listener = service.GetListener("assetsample");
listener.Run((message) => { Console.WriteLine(message.ToString()); });
```In this sample we have created a lambda function, but you can use more traditional mechanism.
Take aware about you will receive an **IMessage** object
### Create Publisher client
The Publisher is an artefact that bring you the capability to send messages to a concrete Topic.
The object are abtracted into **IMessage** internal model.
```c#
IPublisher publisher = service.GetPublisher("assetsample");
for (int i = 0; i < 20; i++)
{
publisher.SendAsync(new { prop1 = i.ToString(), prop2 = "2" });
System.Threading.Thread.Sleep(100);
}
```## Contributing
Please see our [Contribution Guide](CONTRIBUTING.md) to learn how to contribute.
## License
![MIT](https://img.shields.io/badge/License-MIT-blue.svg)
(LICENSE) © 2022 [ERNI - Swiss Software Engineering](https://www.betterask.erni)
## Code of conduct
Please see our [Code of Conduct](CODE_OF_CONDUCT.md)
## Stats
![https://repobeats.axiom.co/api/embed/40ef16dfb701ec4dad65007c5888910f45265d44.svg](https://repobeats.axiom.co/api/embed/40ef16dfb701ec4dad65007c5888910f45265d44.svg)## Follow us
[![Twitter Follow](https://img.shields.io/twitter/follow/ERNI?style=social)](https://www.twitter.com/ERNI)
[![Twitch Status](https://img.shields.io/twitch/status/erni_academy?label=Twitch%20Erni%20Academy&style=social)](https://www.twitch.tv/erni_academy)
[![YouTube Channel Views](https://img.shields.io/youtube/channel/views/UCkdDcxjml85-Ydn7Dc577WQ?label=Youtube%20Erni%20Academy&style=social)](https://www.youtube.com/channel/UCkdDcxjml85-Ydn7Dc577WQ)
[![Linkedin](https://img.shields.io/badge/linkedin-31k-green?style=social&logo=Linkedin)](https://www.linkedin.com/company/erni)## Contact
📧 [[email protected]](mailto:[email protected])
Manu Delgado - [@mdelgadodiaz83](https://twitter.com/MDelgadoDiaz83) - [email protected]
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
mdelgadodiaz83-erni
💻 🖋 📖 🎨 🤔 🚧 ⚠️ 💡 👀
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!