onebeyond/rascal

[ERROR] - rascal error not sending queue using typescript

restuwahyu13 opened this issue · 0 comments

Error: Unknown publication: demo_pub
    at Broker.publish (/home/antimalware/Desktop/real-project/hydeliving-api/node_modules/rascal/lib/amqp/Broker.js:156:42)
    at Broker.publish (/home/antimalware/Desktop/real-project/hydeliving-api/node_modules/rascal/lib/amqp/Broker.js:154:45)
    at /home/antimalware/Desktop/real-project/hydeliving-api/node_modules/rascal/lib/amqp/BrokerAsPromised.js:42:23
    at new Promise (<anonymous>)
    at BrokerAsPromised.self.<computed> [as publish] (/home/antimalware/Desktop/real-project/hydeliving-api/node_modules/rascal/lib/amqp/BrokerAsPromised.js:41:14)
    at Timeout._onTimeout (/home/antimalware/Desktop/real-project/hydeliving-api/index.ts:33:38)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502:7)

i try this code from example documentation, why this not working for me ?

import Broker from 'rascal'
;(async () => {
	try {
		const broker = await Broker.BrokerAsPromised.create({
			vhosts: {
				'/': {
					connection: {
						hostname: 'localhost',
						user: 'restuwahyu13',
						password: 'restuwahyu13',
						port: 5672,
						protocol: 'amqp'
					}
				}
			}
		})
		broker.on('error', console.error)

		try {
			const subscription = await broker.subscribe('demo_sub')
			subscription
				.on('message', function (message, content, ackOrNack) {
					console.log(content)
					ackOrNack()
				})
				.on('error', console.error)
		} catch (err) {
			console.error(err)
		}

		setInterval(async function () {
			try {
				const publication = await broker.publish('demo_pub', new Date().toISOString() + ': hello world')
				publication.on('error', console.error)
			} catch (err) {
				console.error(err)
			}
		}, 1000)
	} catch (err) {
		console.error(err)
	}
})()