Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bin/simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ function Proxy(config, bridgehost) {
} else if (bridgeconfig.type === "amqp_to_tcp") {
bridges.amqp_to_tcp(bridgeconfig.source, bridgehost, bridgeconfig.target)
} else if (bridgeconfig.type === "http_to_amqp") {
bridges.http_to_amqp(bridgeconfig.source, bridgeconfig.target);
bridges.http_to_amqp(bridgeconfig.source, bridgeconfig.target, bridgehost);
} else if (bridgeconfig.type === "http2_to_amqp") {
bridges.http2_to_amqp(bridgeconfig.source, bridgeconfig.target);
} else if (bridgeconfig.type === "tcp_to_amqp") {
Expand Down
9 changes: 5 additions & 4 deletions lib/bridges.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,14 @@ AmqpToHttpBridge.prototype.stop = function () {
this.connection.close();
};

function HttpToAmqpBridge(port, address) {
function HttpToAmqpBridge(port, address, amqphost) {
log.info('Created HTTP to AMQP bridge %s => %s', port, address);
this.port = port;
this.address = address;
var container = rhea.create_container({enable_sasl_external:true});
container.id = process.env.HOSTNAME + '_http:' + this.port + '=>amqp:' + address;
this.client = rclient.create(container.connect(), address);
const option = amqphost ? { host: amqphost } : {}
this.client = rclient.create(container.connect(option), address);

//listen for http requests
this.server = http.createServer(this.request.bind(this));
Expand Down Expand Up @@ -257,8 +258,8 @@ module.exports.amqp_to_tcp = function (address, host, port) {
return new AmqpToTcpBridge(address, host, port);
};

module.exports.http_to_amqp = function (port, address) {
return new HttpToAmqpBridge(port, address);
module.exports.http_to_amqp = function (port, address, amqphost) {
return new HttpToAmqpBridge(port, address, amqphost);
};

module.exports.http2_to_amqp = function (port, address) {
Expand Down
44 changes: 44 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
},
"dependencies": {
"debug": "*",
"http2": "^3.3.7",
"rhea": "*"
}
}