This commit is contained in:
Tomi Turtiainen 2024-12-16 12:18:34 +02:00
parent 410ea9a2ef
commit 52cad150e8
5 changed files with 234 additions and 0 deletions

108
config.json Normal file
View file

@ -0,0 +1,108 @@
{
"UserConfig": {
"Namespaces": [
{
"Name": "sbemulatorns",
"Queues": [
{
"Name": "queue.1",
"Properties": {
"DeadLetteringOnMessageExpiration": false,
"DefaultMessageTimeToLive": "PT1H",
"DuplicateDetectionHistoryTimeWindow": "PT20S",
"ForwardDeadLetteredMessagesTo": "",
"ForwardTo": "",
"LockDuration": "PT1M",
"MaxDeliveryCount": 10,
"RequiresDuplicateDetection": false,
"RequiresSession": false
}
}
],
"Topics": [
{
"Name": "topic.1",
"Properties": {
"DefaultMessageTimeToLive": "PT1H",
"DuplicateDetectionHistoryTimeWindow": "PT20S",
"RequiresDuplicateDetection": false
},
"Subscriptions": [
{
"Name": "subscription.1",
"Properties": {
"DeadLetteringOnMessageExpiration": false,
"DefaultMessageTimeToLive": "PT1H",
"LockDuration": "PT1M",
"MaxDeliveryCount": 10,
"ForwardDeadLetteredMessagesTo": "",
"ForwardTo": "",
"RequiresSession": false
},
"Rules": [
{
"Name": "app-prop-filter-1",
"Properties": {
"FilterType": "Correlation",
"CorrelationFilter": {
"ContentType": "application/text",
"CorrelationId": "id1",
"Label": "subject1",
"MessageId": "msgid1",
"ReplyTo": "someQueue",
"ReplyToSessionId": "sessionId",
"SessionId": "session1",
"To": "xyz"
}
}
}
]
},
{
"Name": "subscription.2",
"Properties": {
"DeadLetteringOnMessageExpiration": false,
"DefaultMessageTimeToLive": "PT1H",
"LockDuration": "PT1M",
"MaxDeliveryCount": 10,
"ForwardDeadLetteredMessagesTo": "",
"ForwardTo": "",
"RequiresSession": false
},
"Rules": [
{
"Name": "user-prop-filter-1",
"Properties": {
"FilterType": "Correlation",
"CorrelationFilter": {
"Properties": {
"prop3": "value3"
}
}
}
}
]
},
{
"Name": "subscription.3",
"Properties": {
"DeadLetteringOnMessageExpiration": false,
"DefaultMessageTimeToLive": "PT1H",
"LockDuration": "PT1M",
"MaxDeliveryCount": 10,
"ForwardDeadLetteredMessagesTo": "",
"ForwardTo": "",
"RequiresSession": false
}
}
]
}
]
}
],
"Logging": {
"Type": "File"
}
}
}

42
data.json Normal file
View file

@ -0,0 +1,42 @@
{
"typecode": 117,
"content": {
"type": "Buffer",
"data": [
123, 34, 69, 118, 101, 110, 116, 83, 111, 117, 114, 99, 101, 34, 58, 110, 117, 108, 108, 44,
34, 69, 118, 101, 110, 116, 86, 101, 114, 115, 105, 111, 110, 34, 58, 49, 44, 34, 69, 118,
101, 110, 116, 78, 97, 109, 101, 34, 58, 34, 85, 115, 101, 114, 85, 112, 100, 97, 116, 101,
100, 34, 44, 34, 82, 101, 97, 115, 111, 110, 34, 58, 34, 85, 115, 101, 114, 32, 104, 97, 115,
32, 117, 112, 100, 97, 116, 101, 100, 32, 116, 104, 101, 105, 114, 32, 112, 114, 111, 102,
105, 108, 101, 34, 44, 34, 65, 99, 116, 111, 114, 34, 58, 34, 57, 52, 54, 51, 49, 101, 102,
57, 45, 101, 52, 50, 53, 45, 52, 55, 52, 49, 45, 57, 57, 55, 52, 45, 99, 53, 100, 53, 100, 50,
48, 53, 51, 55, 56, 48, 34, 44, 34, 69, 118, 101, 110, 116, 84, 105, 109, 101, 34, 58, 34, 50,
48, 50, 52, 45, 49, 49, 45, 50, 57, 84, 48, 50, 58, 53, 48, 58, 53, 55, 46, 56, 52, 55, 52,
54, 55, 53, 90, 34, 44, 34, 67, 111, 114, 114, 101, 108, 97, 116, 105, 111, 110, 73, 100, 34,
58, 34, 51, 102, 50, 54, 55, 48, 100, 53, 45, 101, 100, 52, 97, 45, 52, 101, 53, 57, 45, 97,
98, 53, 52, 45, 52, 56, 98, 97, 52, 53, 53, 100, 102, 52, 54, 52, 34, 44, 34, 79, 112, 101,
114, 97, 116, 105, 111, 110, 73, 100, 34, 58, 110, 117, 108, 108, 44, 34, 80, 97, 114, 101,
110, 116, 73, 100, 34, 58, 110, 117, 108, 108, 44, 34, 83, 101, 115, 115, 105, 111, 110, 73,
100, 34, 58, 110, 117, 108, 108, 44, 34, 80, 97, 121, 108, 111, 97, 100, 34, 58, 123, 34, 86,
101, 114, 115, 105, 111, 110, 34, 58, 49, 44, 34, 68, 97, 116, 97, 34, 58, 123, 34, 85, 115,
101, 114, 34, 58, 123, 34, 85, 115, 101, 114, 73, 100, 34, 58, 34, 100, 52, 50, 56, 100, 48,
48, 97, 45, 50, 97, 98, 100, 45, 52, 56, 99, 49, 45, 57, 56, 56, 101, 45, 53, 49, 53, 53, 100,
56, 57, 53, 53, 97, 48, 51, 34, 44, 34, 69, 109, 97, 105, 108, 34, 58, 34, 116, 101, 115, 116,
116, 109, 110, 122, 99, 117, 115, 116, 111, 109, 101, 114, 64, 103, 109, 97, 105, 108, 46, 99,
111, 109, 34, 44, 34, 70, 105, 114, 115, 116, 78, 97, 109, 101, 34, 58, 34, 116, 101, 115,
116, 84, 77, 78, 90, 34, 44, 34, 76, 97, 115, 116, 78, 97, 109, 101, 34, 58, 34, 67, 117, 115,
116, 111, 109, 101, 114, 34, 44, 34, 68, 97, 116, 101, 79, 102, 66, 105, 114, 116, 104, 34,
58, 34, 50, 48, 48, 49, 45, 48, 49, 45, 48, 49, 84, 48, 48, 58, 48, 48, 58, 48, 48, 90, 34,
44, 34, 83, 117, 98, 115, 99, 114, 105, 98, 101, 100, 84, 111, 77, 97, 114, 107, 101, 116,
105, 110, 103, 73, 110, 102, 111, 34, 58, 116, 114, 117, 101, 44, 34, 73, 115, 65, 99, 116,
105, 118, 101, 34, 58, 102, 97, 108, 115, 101, 44, 34, 85, 115, 101, 114, 84, 121, 112, 101,
73, 100, 34, 58, 51, 125, 125, 44, 34, 65, 100, 100, 105, 116, 105, 111, 110, 97, 108, 73,
110, 102, 111, 34, 58, 123, 125, 125, 44, 34, 77, 101, 116, 97, 100, 97, 116, 97, 34, 58, 123,
125, 44, 34, 65, 112, 112, 108, 105, 99, 97, 116, 105, 111, 110, 34, 58, 34, 84, 97, 120, 77,
97, 110, 97, 103, 101, 114, 32, 67, 117, 115, 116, 111, 109, 101, 114, 32, 65, 112, 112, 34,
44, 34, 68, 111, 109, 97, 105, 110, 34, 58, 34, 73, 100, 101, 110, 116, 105, 116, 121, 34, 44,
34, 69, 110, 118, 105, 114, 111, 110, 109, 101, 110, 116, 34, 58, 34, 65, 122, 117, 114, 101,
32, 68, 101, 118, 32, 69, 110, 118, 105, 114, 111, 110, 109, 101, 110, 116, 34, 125
]
}
}

31
docker-compose.yml Normal file
View file

@ -0,0 +1,31 @@
name: microsoft-azure-servicebus-emulator
services:
emulator:
container_name: 'servicebus-emulator'
image: mcr.microsoft.com/azure-messaging/servicebus-emulator:latest
volumes:
- './config.json:/ServiceBus_Emulator/ConfigFiles/Config.json'
ports:
- '5672:5672'
environment:
SQL_SERVER: sqledge
MSSQL_SA_PASSWORD: 'Abd@123456!'
ACCEPT_EULA: 'Y'
depends_on:
- sqledge
networks:
sb-emulator:
aliases:
- 'sb-emulator'
sqledge:
container_name: 'sqledge'
image: 'mcr.microsoft.com/azure-sql-edge:latest'
networks:
sb-emulator:
aliases:
- 'sqledge'
environment:
ACCEPT_EULA: 'Y'
MSSQL_SA_PASSWORD: 'Abd@123456!'
networks:
sb-emulator:

View file

@ -0,0 +1,53 @@
const rhea = require('rhea');
// Define connection options
const connectionOptions = {
host: 'localhost', // Azure Service Bus emulator runs on localhost
hostname: 'localhost',
port: 5672, // Default AMQP port for the emulator
};
const container = rhea.create_container();
// Establish the connection
const connection = rhea.connect(connectionOptions);
// Handle connection events
connection.on('connection_open', () => {
console.log('Connected to Azure Service Bus emulator!');
// connection.close();
// // Create a receiver
// const receiver = connection.open_receiver('queue.1'); // Replace with your queue name
// receiver.on('message', (message) => {
// console.log('Received message:', message);
// });
// Create a sender
const sender = connection.open_sender('queue.1'); // Replace with your queue name
sender.on('sendable', () => {
const body = JSON.parse(
'{"EventSource":null,"EventVersion":1,"EventName":"UserUpdated","Reason":"User has updated their profile","Actor":"94631ef9-e425-4741-9974-c5d5d2053780","EventTime":"2024-11-29T02:50:57.8474675Z","CorrelationId":"3f2670d5-ed4a-4e59-ab54-48ba455df464","OperationId":null,"ParentId":null,"SessionId":null,"Payload":{"Version":1,"Data":{"User":{"UserId":"d428d00a-2abd-48c1-988e-5155d8955a03","Email":"testtmnzcustomer@gmail.com","FirstName":"testTMNZ","LastName":"Customer","DateOfBirth":"2001-01-01T00:00:00Z","SubscribedToMarketingInfo":true,"IsActive":false,"UserTypeId":3}},"AdditionalInfo":{}},"Metadata":{},"Application":"TaxManager Customer App","Domain":"Identity","Environment":"Azure Dev Environment"}',
);
const messageBuffer = Buffer.from(JSON.stringify(body), 'utf-8');
// Send a message
sender.send({
body: {
content: messageBuffer,
},
});
console.log('Message sent!');
connection.close();
});
});
connection.on('connection_error', (err) => {
console.error('Connection error:', err);
});
connection.on('connection_close', () => {
console.log('Connection closed.');
});