Beispiel #1
0
 */

// Simple client for use with server.js illustrating request/response

// Check if the environment is Node.js and if not log an error and exit.
if (typeof process === 'object' && typeof require === 'function') {
    var proton = require("qpid-proton");

    var address = "amqp://0.0.0.0";
    var subject = "UK.WEATHER";
    var replyTo = "~/replies";
    var msgtext = "Hello World!";
    var tracker = null;

    var message = new proton.Message();
    var messenger = new proton.Messenger();

    var pumpData = function() {
        while (messenger.incoming()) {
            var t = messenger.get(message);

            console.log("Reply:");
            console.log("Address: " + message.getAddress());
            console.log("Subject: " + message.getSubject());

            // body is the body as a native JavaScript Object, useful for most real cases.
            //console.log("Content: " + message.body);

            // data is the body as a proton.Data Object, used in this case because
            // format() returns exactly the same representation as recv.c
            console.log("Content: " + message.data.format());
Beispiel #2
0
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 *
 */

// Simple server for use with client.js illustrating request/response

// Check if the environment is Node.js and if not log an error and exit.
if (typeof process === 'object' && typeof require === 'function') {
    var proton = require("qpid-proton");

    var address = "amqp://~0.0.0.0";
    var message = new proton.Message();
    var reply   = new proton.Message();
    var messenger = new proton.Messenger();

    var dispatch = function(request, response) {
        var subject = request.getSubject();
        if (subject) {
            response.setSubject('Re: ' + subject);
        }
        response.properties = request.properties
        console.log("Dispatched " + subject + " " + JSON.stringify(request.properties));
    };

    var pumpData = function() {
        while (messenger.incoming()) {
            var t = messenger.get(message);
    
            var replyTo = message.getReplyTo();
Beispiel #3
0
// Check if the environment is Node.js and if not log an error and exit.
if (typeof process === 'object' && typeof require === 'function') {
    var proton = require("qpid-proton");

    console.log("spout not implemented yet");
    process.exit(0);
    
    var address = "amqp://0.0.0.0";
    var subject = "UK.WEATHER";
    var msgtext = "Hello World!";
    var tracker = null;
    var running = true;
    
    var message = new proton.Message();
    var messenger = new proton.Messenger();

    function pumpData() {
        var status = messenger.status(tracker);
        if (status != proton.Status.PENDING) {
console.log("status = " + status);

            if (running) {
console.log("stopping");
                messenger.stop();
                running = false;
            } 
        }
    
        if (messenger.isStopped()) {
console.log("exiting");