-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsend.js
More file actions
29 lines (21 loc) · 739 Bytes
/
send.js
File metadata and controls
29 lines (21 loc) · 739 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import { ServiceBusClient } from '@azure/service-bus'
async function main() {
const client = new ServiceBusClient('Endpoint=sb://localhost:5672;SharedAccessKeyName=RootManageSharedAccessKey;SharedAccessKey=SAS_KEY_VALUE;UseDevelopmentEmulator=true;')
const sender = client.createSender('test-topic')
const message = {
body: 'Hello, World!',
label: 'greeting',
userProperties: {
myCustomPropertyName: 'my custom property value'
}
}
try {
await sender.sendMessages(message)
console.dir(sender.prototype._context.connection, { depth: 10 })
console.log('Sent message:', message)
} catch (error) {
console.log('Error sending message:', error)
}
return client.close()
}
await main()