GithubHelp home page GithubHelp logo

Comments (10)

mayorandrew avatar mayorandrew commented on April 25, 2024 5

Based on https://github.com/fwoelffel/nest-bull/blob/master/lib/bull.providers.ts#L39 it looks like that you should have name property defined outside of the useFactory, like this:

@Module({
  imports: [
    ConfigModule,
    BullModule.forRootAsync({
      imports: [ConfigModule],
      name: 'slack-announce',
      useFactory: (configService: ConfigService) => ({
        options: {
          redis: {
            port: 6379,
          },
        },
      }),
      inject: [ConfigService],
    }),
  ],
  providers: [SlackAnnounceRankingProcessor],
  controllers: [],
})
export class SlackModule {}

This works. It doesn't seem quite right though...

from bull.

fwoelffel avatar fwoelffel commented on April 25, 2024 1

Hi @joshuajung 👋
I've look into the code and I'm affraid it won't be possible to define the queue name from the useFactory. If you take a look at https://github.com/fwoelffel/nest-bull/blob/master/lib/bull.providers.ts#L46 (or https://github.com/fwoelffel/nest-bull/blob/13-async-array-configuration/lib/bull.providers.ts#L45 which will soon be merged into master) you can see by your self that I need the queue name to build the injection token. Thus, I can't wait for the result of the useFactory function.
If you have an idea on how to do this, feel free to submit a PR 🙂

from bull.

fwoelffel avatar fwoelffel commented on April 25, 2024

@joshuajung Sorry I didn't have quite the time to investigate on this issue yet. Could you confirm that @mayorandrew's answer is fixing your issue?

@mayorandrew yup, you're right, I don't know why I implemented this non-sense. Sorry for that, I'll try to deprecate this and provide a non-breaking solution to this. Thanks for taking some of your time to have a look on this.

from bull.

joshuajung avatar joshuajung commented on April 25, 2024

@fwoelffel Happy to confirm this did the trick!
@mayorandrew Thanks a lot for your effort! I would have never found that myself.

from bull.

fwoelffel avatar fwoelffel commented on April 25, 2024

Awesome, thanks for your feedback. I feel like I should add a forRootAsync example in the README.
I'm closing this.

from bull.

joshuajung avatar joshuajung commented on April 25, 2024

Hey @fwoelffel, Thanks a lot for taking the time and looking into it! Now that I know that name is defined outside useFactory, that's perfectly fine for me. Unfortunately, my skills won't suffice for making a meaningful contribution here. Thanks again!

from bull.

JVMartin avatar JVMartin commented on April 25, 2024

Just ran into this now in 2020.

The docs do not detail this at all:
https://docs.nestjs.com/techniques/queues

Would someone with the appropriate power be able to update the docs to include a name property in the proper location in the .registerQueueAsync section? This would have taken me many hours to figure out without this thread.

from bull.

kamilmysliwiec avatar kamilmysliwiec commented on April 25, 2024

@JVMartin I've just pushed an update to the docs. Thanks!

from bull.

investeusa avatar investeusa commented on April 25, 2024

@JVMartin Acabei de enviar uma atualização aos documentos. Obrigado!

Did you test this? The documentation is not clear to those who are starting.

I have the same problem.

**queues.config.module.ts**

@Module({
    imports: [
        BullModule.forRootAsync({
            imports: [ConfigModule],
            inject: [ConfigService],
            useFactory: async (configService: ConfigService) => ({
                redis: {
                    host: configService.get('REDIS_HOST'),
                    port: configService.get('REDIS_PORT'),
                },
            }),
        }),
        QuotesQueueModule
    ]
})
export class QueuesModule {}
**queues.service.ts**

@Injectable()
class BullConfigService implements BullOptionsFactory {
  createBullOptions(): BullModuleOptions {
    return {
      redis: {
        host: 'localhost',
        port: 6379,
      },
    };
  }
}
**error:**

(node:261) UnhandledPromiseRejectionWarning: Error: connect ECONNREFUSED 0.0.0.0:6379
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1129:14)
(node:261) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)

from bull.

kamilmysliwiec avatar kamilmysliwiec commented on April 25, 2024

Please, use our Discord channel (support) for such questions. We are using GitHub to track bugs, feature requests, and potential improvements.

from bull.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.