本文整理汇总了TypeScript中amqp10.Client.connect方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Client.connect方法的具体用法?TypeScript Client.connect怎么用?TypeScript Client.connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类amqp10.Client
的用法示例。
在下文中一共展示了Client.connect方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: connect
connect() {
console.log('CONNECTING..');
return this.client.connect('amqp://apollo:ollopaehcapa@localhost')
.then(() => {
console.log('CONNECTION OK');
return Promise.all([this.client.createReceiver('jms.queue.toto'), this.client.createSender('jms.queue.toto')])
})
.then(results => {
this.receiverDefer.resolve(results[0]);
this.senderDefer.resolve(results[1]);
})
.catch(err => {
console.log("error: ", err);
});
}
示例2: encodeURIComponent
serviceBusHost = settings.serviceBusHost.indexOf(".") !== -1 ?
settings.serviceBusHost :
settings.serviceBusHost + '.servicebus.windows.net',
sasName = settings.SASKeyName,
sasKey = settings.SASKey,
topicName = settings.topicName,
subscriptionName = settings.subscriptionName,
uri = protocol + '://' + encodeURIComponent(sasName) + ':' + encodeURIComponent(sasKey) + '@' + serviceBusHost,
msgVal = Math.floor(Math.random() * 1000000),
client = new amqp.Client(amqp.Policy.ServiceBusTopic);
client.connect(uri)
.then(() => Promise.all([
client.createSender(topicName),
client.createReceiver(topicName + '/Subscriptions/' + subscriptionName)
]))
.then(([sender, receiver]) => {
// error handling
sender.on('errorReceived', tx_err => { console.warn('===> TX ERROR: ', tx_err); });
receiver.on('errorReceived', rx_err => { console.warn('===> RX ERROR: ', rx_err); });
// message event handler
receiver.on('message', message => {
console.log('received: ', message);
if (message.body.DataValue === msgVal) {
client.disconnect().then(() => {
示例3:
/**
* EXAMPLES FROM: https://github.com/noodlefrenzy/node-amqp10#usage
*/
import * as amqp from "amqp10";
import Policy = amqp.Policy;
// Uses PolicyBase default policy
const client = new amqp.Client();
client.connect('amqp://localhost')
.then(() => Promise.all([
client.createReceiver('amq.topic'),
client.createSender('amq.topic')
]))
.then(([receiver, sender]) => {
receiver.on('errorReceived', err => { /** check for errors. */ });
receiver.on('message', message => {
console.log('Rx message: ', message.body);
});
return sender.send({ key: "Value" });
})
.catch(err => {
console.log("error: ", err);
});
const mergedClient = new amqp.Client(Policy.merge({
senderLink: {
callback: Policy.Utils.SenderCallbackPolicies.OnSent
}
示例4: require
/// <reference path="../declarations/node.d.ts" />
var AMQPClient = require('amqp10').Client, Policy = require('amqp10').Policy,
Promise = require('bluebird');
var client = new AMQPClient(Policy.ServiceBusQueue); // Uses PolicyBase default policy
client.connect('amqps://RootManageSharedAccessKey:7Y%2FK3coL51vIPEqg9uELnQwJFllt7QTy7hgts4mMEmg%3D@shcpatientportal-dev.servicebus.windows.net')
.then(function() {
console.log("THEN");
return Promise.all([
client.createReceiver('fhir_datasync_queue_dev', { auto_delete: true })
//client.createSender('fhir_datasync_queue_dev')
]);
})
.spread(function(receiver, sender) {
console.log("SPREAD");
//sender.on('errorReceived', function(tx_err) { console.warn('===> TX ERROR: ', tx_err); });
receiver.on('errorReceived', function(rx_err) { console.warn('===> RX ERROR: ', rx_err); });
var receive_callback = function (message) {
console.log('Rx message: ', message.body);
};
receiver.on('message', receive_callback);
})
.error(function(err) {
console.log("error: ", err);
});