question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

PubSub consumer never consumes messages with RabbitSubscribe

See original GitHub issue

Hello,

I have an issue with consuming messages in a pubsub maner. I am able to create a connection to the exchange and to publish messages on it (confirmed on the UI).

I do not understand why my function associated with RabbitSubscribe is never called. I have triple checked the exchange and route key and it is correct.

In my Module I use :

		RabbitMQModule.forRoot(RabbitMQModule, {
			exchanges: [
			  {
				name: 'exchange1',
				type: 'fanout',
			  },
			],
			uri: 'amqp://localhost:5672',
			connectionInitOptions: { wait: false },
		  }),

And my service :

import { Injectable } from "@nestjs/common"
import { AmqpConnection, RabbitSubscribe } from "@golevelup/nestjs-rabbitmq"

@Injectable()
export class MailService {
	constructor(private readonly amqpConnection: AmqpConnection) {
		// setTimeout(function() {
		// 	console.log("inside")

		// 	amqpConnection.publish("exchange1", "subscribe-route", { msg: "hello world" })
		// }, 3000)
	}

	@RabbitSubscribe({
		exchange: "exchange1",
		routingKey: "subscribe-route",
		queue: "subscribe-queue",
	})
	public async pubSubHandler(msg: {}) {
		console.log(`Received message: ${JSON.stringify(msg)}`)
	}
}

Is there something I am missing ? Thanks

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
WonderPandacommented, Jun 2, 2021

No problem. I’m going to close this now as the root cause has been identified and will track any additional info in the dedicated issue for microservices support

1reaction
WonderPandacommented, Jun 2, 2021

@LucSalommez Unfortunately the library isn’t a “true” NestJS microservice at the moment so we can’t rely on startAllMicroservicesAsync to establish listeners at the moment. I’ll need to look into this a bit more and see what solutions make sense

Tracking this with #274

Read more comments on GitHub >

github_iconTop Results From Across the Web

Handle message failures | Cloud Pub/Sub
This page explains how to handle such processing failures by using a subscription retry policy or by forwarding undelivered messages to a dead-letter...
Read more >
RabbitMQ tutorial - Publish/Subscribe
A consumer is a user application that receives messages. The core idea in the messaging model in RabbitMQ is that the producer never...
Read more >
RabbitMQ Plugin - GitHub Pages
3 Sending Messages. 4 Consuming Messages. 4.1 Pub-Sub. 4.2 Manual queue management. 4.3 Messages. 5 Using The RabbitTemplate Directly ...
Read more >
Google Pub/Sub Subscriber not receiving messages after a ...
My application uses python and a lot of processing power in a Google Cloud Engine. What do you think would be the best...
Read more >
Cloud Pub/Sub - Spring Boot on GCP
Cloud Pub/Sub delivers messages with guaranteed at-least-once delivery, ... A Spring Cloud Stream consumer to consume messages is simply a Java Consumer ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found