graphql-rabbitmq-subscriptions
graphql-rabbitmq-subscriptions copied to clipboard
How to pass in a named queue to rabbitmq-pub-sub
Default behavior of rabbitmq-pub-sub is generate a random named queue like amq.gen--8B_yHhahOGcnAo7zNWK_A every time make subscription. This will cause huge number of queues generated, how to avoid this ?
Isn't it ok to have a separate queue for distinct subscription?
I think it's better have a way i can specify all subscriptions or a group of subscriptions use one queue. i have not find a way to bind subscription to fixed queue in rabbitmq-pub-sub
@groundmuffin
@developerworks This package use <cdmbase/rabbitmq-pubsub>-RabbitMqSubscriber instance to create a new subscription. It's
@groundmuffin I kown this, i means it's good if the configuration options can be pass to rabbitmq-pub-sub throuth AmqpPubSub configurations or something else, because i have not use rabbitmq-pub-sub directly.
@developerworks I think triggerTransform method signature can be changed to return
give me scenario how you want to add the configuration, so I can make the current package compatible. Feel free to open a PR.
May be the config key of AmqpPubSub configuration object is the place to rabbitmq configurations, such as: host, port, username,password, exchange, queue, durability, auto_delete and so on.
const pubsub = new AmqpPubSub({
config: {
host: RABBITMQ_DOMAIN_NAME, // Could connect rabbitmq server from remote client with `username:password@hostname`, but could specify independently is better in config
port: PORT_NUMBER,
username: String, // optional
password: String, // optional
//
exchange: {
name: String,
type: headers | fanout | topic | direct
durability: Boolean,
autodelete: Boolean,
internal: Boolean,
arguments: {
"alternate-exchange": String
}
},
// Object, Queue creation params
queue: {
name: '',
durability: Boolean,
autodelete: Boolean,
// If exists, shoud be pass to rabbitmq server
arguments: {
"x-message-ttl": Number,
"x-expires": Number,
"x-max-length": Number,
"x-max-length-bytes": Number,
"x-dead-letter-exchange": String,
"x-dead-letter-routing-key": String,
"x-max-priority": Number
}
},
},
logger,
});
This is exported definitions of rabbitmq, i think most of these is configuable.
{
"rabbit_version": "3.5.7",
"users": [
{
"name": "notification",
"password_hash": "bjI3Bv7PnxcbBRhB3znGmT++uWw=",
"tags": "administrator"
},
{
"name": "register_notice",
"password_hash": "kmCJDlEoiK716RcEXY9YWIVKi6c=",
"tags": "administrator"
},
{
"name": "guest",
"password_hash": "Cz+gtiAstAx3gYqulClXE64bgGM=",
"tags": "administrator"
}
],
"vhosts": [
{
"name": "/"
}
],
"permissions": [
{
"user": "register_notice",
"vhost": "/",
"configure": ".*",
"write": ".*",
"read": ".*"
},
{
"user": "notification",
"vhost": "/",
"configure": ".*",
"write": ".*",
"read": ".*"
},
{
"user": "guest",
"vhost": "/",
"configure": ".*",
"write": ".*",
"read": ".*"
}
],
"parameters": [],
"policies": [],
"queues": [
{
"name": "graphql",
"vhost": "/",
"durable": true,
"auto_delete": false,
"arguments": {}
},
{
"name": "graphql-operations",
"vhost": "/",
"durable": true,
"auto_delete": false,
"arguments": {}
},
{
"name": "user-register-notification",
"vhost": "/",
"durable": true,
"auto_delete": false,
"arguments": {}
}
],
"exchanges": [
{
"name": "ON_WECHAT_USER_LOGIN.DLQ.Exchange",
"vhost": "/",
"type": "fanout",
"durable": false,
"auto_delete": false,
"internal": false,
"arguments": {}
},
{
"name": "ON_WECHAT_USER_AUTHORIZED.DLQ.Exchange",
"vhost": "/",
"type": "fanout",
"durable": false,
"auto_delete": false,
"internal": false,
"arguments": {}
},
{
"name": "orderCreated.DLQ.Exchange",
"vhost": "/",
"type": "fanout",
"durable": false,
"auto_delete": false,
"internal": false,
"arguments": {}
}
],
"bindings": [
{
"source": "amq.topic",
"vhost": "/",
"destination": "user-register-notification",
"destination_type": "queue",
"routing_key": "#an125",
"arguments": {}
},
{
"source": "amq.topic",
"vhost": "/",
"destination": "graphql-operations",
"destination_type": "queue",
"routing_key": "#graphql_operations",
"arguments": {}
}
]
}
I'm having the same issue here, is there a recommended way to connect to an existing exchange and queue? I can't find it in the README. Any help is appreciated.
is there any way to consume an existing queue?
same issue (also have queues that match patterns), I also have the issue that I'm using multiple exchanges, so would this mean multiple pubsub objects? and what's being published to them right now isn't exactly what I want published to graphql, I need to transform the inbound to the outbound.
I'm having the same issue here, is there a recommended way to connect to an existing exchange and queue? I can't find it in the README. Any help is appreciated.
Have you gotten this to work? The default behavior of the lib creates a new channel per event and most end up being idle and I want to pass in one specific channel to use. Is seems this project is not being maintained as this issue's been around for years without answer :(