Comments (10)
Hi, could you provide pubsub message example which client sends?
from nestjs-google-pubsub-microservice.
@p-fedyukovich Sure
message example
{
"broker": "Smart Prime Group Ltd.",
"time": "2022-02-14T00:21:01.137Z",
"symbol": "SPA35",
"ask": 50.25,
"bid": 60.50,
"volume": 6500,
"publisherTime": "2022-02-14T00:21:01.137Z"
}
here is my topic schema
{
"type": "record",
"name": "Avro",
"fields": [
{
"name": "broker",
"type": "string"
},
{
"name": "time",
"type": "string"
},
{
"name": "symbol",
"type": "string"
},
{
"name": "ask",
"type": "double"
},
{
"name": "bid",
"type": "double"
},
{
"name": "volume",
"type": "double"
},
{
"name": "publisherTime",
"type": "string"
}
]
}
p.s I tried with this lib and it's working fine https://github.com/crallen/nestjs-google-pubsub#readme
from nestjs-google-pubsub-microservice.
@p-fedyukovich Sure
message example
{ "broker": "Smart Prime Group Ltd.", "time": "2022-02-14T00:21:01.137Z", "symbol": "SPA35", "ask": 50.25, "bid": 60.50, "volume": 6500, "publisherTime": "2022-02-14T00:21:01.137Z" }
here is my topic schema
{ "type": "record", "name": "Avro", "fields": [ { "name": "broker", "type": "string" }, { "name": "time", "type": "string" }, { "name": "symbol", "type": "string" }, { "name": "ask", "type": "double" }, { "name": "bid", "type": "double" }, { "name": "volume", "type": "double" }, { "name": "publisherTime", "type": "string" } ] }
p.s I tried with this lib and it's working fine https://github.com/crallen/nestjs-google-pubsub#readme
Your message data format is wrong because it should have metadata for correct selecting message handler. If you use your own message dispatcher it should produce message in such format
{
"pattern": "notifications",
"eventId": "any string value for that message which keeps idemopotency",
"data": "Your message payload"
}
from nestjs-google-pubsub-microservice.
Thank you for reply.
So what changes exactly I need to make in my message and schema to make it work?
from nestjs-google-pubsub-microservice.
I provided the message structure, you should update your message producer to fit the message structure
from nestjs-google-pubsub-microservice.
Hi @p-fedyukovich I have trouble publishing the message, could you please provide a working example here or to the ReadMe file?
from nestjs-google-pubsub-microservice.
Hi @p-fedyukovich I have trouble publishing the message, could you please provide a working example here or to the ReadMe file?
Hi, there are examples in test files.
import {
Body,
Controller,
HttpCode,
OnApplicationShutdown,
Post,
Query,
} from '@nestjs/common';
import {
ClientProxy,
EventPattern,
MessagePattern,
} from '@nestjs/microservices';
import { GCPubSubClient } from '../../lib';
@Controller()
export class GCPubSubController implements OnApplicationShutdown {
client: ClientProxy;
constructor() {
this.client = new GCPubSubClient({
client: {
apiEndpoint: 'localhost:8681',
projectId: 'microservice',
},
});
}
onApplicationShutdown(signal?: string) {
return this.client.close();
}
@Post('notify')
async sendNotification(): Promise<any> {
return this.client.emit('notification', true);
}
}
from nestjs-google-pubsub-microservice.
Related Issues (20)
- Please provide a full example HOT 1
- multiple subscribers + Listen to a topic - Difference between emit and send HOT 1
- add replyTo property in client dispatch handler HOT 1
- add support to send attributes along with data object. HOT 1
- Support @google-cloud/pubsub version 3 HOT 3
- Only usable with Pub/Sub Admin permissions HOT 2
- Error: 4 DEADLINE_EXCEEDED: Deadline exceeded Pub Sub & NestJs HOT 2
- request-repsonse pattern with multiple clients and servers HOT 3
- Readme regarding client.close is not quite clear HOT 3
- No DTO validation possible? HOT 1
- Create a Subscription with options
- Support for nest v10 HOT 5
- How to subscribe to multiple pub-sub topics? HOT 3
- Why is server.send called when only listening? HOT 16
- Bug: PubSub client is not connected: topic undefined does not exist HOT 4
- Extend support for Cloud Events
- Add support for ClientsModule.register HOT 3
- Decouple subscription creation from topic creation during "init"?
- Message falls when it is too large HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nestjs-google-pubsub-microservice.