Open stephanyes opened 9 months ago
I don';t know anythnig about NestJS, or if there are specific requirements in there. I'd suggest taking a trace of the app (MQIJS_TRACE=true) so get a better idea of the flow. As a standalone program, this seems to work.
I suspect that when your code is nested inside the Nest.JS class that the environment variables are not visible. In lieu of setting
process.env['MQIJS_NOUSECTL'] = 'true';
before the ibmmq module is loaded, you may need to set
mq.setTuningParameters({useCtl:false});
in the constructor, or maybe even closer to the get
.
Just took a closer look at your code. I think you need to rearrange your imports to set the environment variable before loading ibmmq. ie.
process.env['MQIJS_NOUSECTL'] = 'true';
import * as mq from 'ibmmq';
import { MQC, MQCD, MQCNO, MQCSP, MQMD, MQGMO, MQSD, MQQueueManager } from 'ibmmq';
...
Please include the following information in your ticket.
ibmmq: 2.0.2 nestjs: 8.2.8
Its the first time im opening a github issue so hopefully you can help me out.
At work we are trying to use this package and add it to our own libraries but I'm not sure why I cant make it work with NestJS.
We managed to reproduce the sample on how to subscribe to a topic and listen to messages with a .js script and works like a charm. The problem is when we generate a package with a module, a service and everything we need to have the same with Nestjs.
The
ibmmq.module.ts
is a normal module that has auseFactory
that starts ourConnectionService
so far so good. Ourconnection.service.ts
has anonModuleInit
that creates the connection to our broker and other methods likeonApplicationShutdown
. Again so far so good here.Then the magic happends in our
ibmmq.ts
were we basically copy the script I described above to retrieve messages from a topic, almost the same example provided in this repository. Once all modules in our application are loaded included the IBM (without any errors) the behaviour of getting messages its not working as intended.Specifically the callback the
mq.Get()
we are sending it never gets executed and we don't understand why.I can provide how are code looks but I don't think anybody tried to do this in nest so far (at least I went through the issues page and I don't find another example with nestjs)
Can you guide me with my problem? Again ill provide any code neccesary so you can see it. This is our
ibmmq.ts
:Im open to any kind of suggestions and sorry if it looks messy, thanks in advance.