-
Notifications
You must be signed in to change notification settings - Fork 94
Open
Description
Expected Behavior
Subscribe made before daprServer.start()
Actual Behavior
Subscribe after before daprServer.start()
Steps to Reproduce the Problem
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { DaprServer } from '@dapr/dapr';
import * as express from 'express';
import { ExpressAdapter } from '@nestjs/platform-express';
async function bootstrap() {
const port = '3002';
const server = express();
const pubsubName = 'pubsub-name';
// I'using JetStream as queue
const topic1 = 'xxx.>';
const topic2 = 'yyy.>';
server.use((req, res, next) => {
if (req.path.startsWith('/dapr') || req.path.startsWith('/events/'))
return next();
return next();
});
const daprServer = new DaprServer({
serverHost: 'localhost',
serverPort: port,
serverHttp: server,
clientOptions: {
daprHost: 'localhost',
daprPort: '3502',
},
});
await daprServer.pubsub.subscribe(
pubsubName,
topic1,
async (data) => console.log(topic1),
undefined,
{ rawPayload: true },
);
await daprServer.start();
await daprServer.pubsub.subscribe(
pubsubName,
topic2,
async (data) => console.log(topic2),
undefined,
{ rawPayload: true },
);
const app = await NestFactory.create(AppModule, new ExpressAdapter(server));
await app.init();
}
bootstrap();
Proposed fix
Fix server subscribe documentation and move subscribe before daprSever.start()
Metadata
Metadata
Assignees
Labels
No labels