Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8154939
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T16:31:07+00:00 2026-06-06T16:31:07+00:00

I am not able to send publish message via kaazing javascript AMPQ library. Below

  • 0

I am not able to send publish message via kaazing javascript AMPQ library. Below code works perfectly fine for the FANOUT exchange but it doesnt work for DIRECT exchange. I am able to connect but not able to publish message to DIRECT exchange.

function amqpTest(){
load();
var $ = function(s) { return document.getElementById(s); };
var console = $("console");

var log = function(message){
var pre = document.createElement("pre");
pre.style.wordWrap = "break-word";
pre.innerHTML = message;
console.insertBefore(pre, console.firstChild);
while(console.childNodes.length > 500){
console.removeChild(console.lastChild);
}
}

var url = "ws://localhost:8000/amqp";
var username = "guest";
var password = "guest";
var connect = $("connect");
var disconnect= $("disconnect");

var consumeExchange = "demo_direct_exchange";
var consumeMessageText = "call";
var alias = "player";

var myQueueName = "clientqueue";
var myConsumerTag = "clientkey";
var routingKey = "broadcastkey";
var exchangeName = consumeExchange;
var send = $("send");

connect.onclick = function(){
log("Connecting: "+ url + " " + username);
myQueueName = "client" + Math.floor(Math.random() * 1000000);
myConsumerTag = "client" + Math.floor(Math.random() * 1000000);

var version = "0-9-0";
amqp = new AmqpClient();
amqp.addEventListener("close", function(){
log("Disconnected");
});

amqp.connect(url, '/', {username:username, password:password}, version, openHandler);
}

var openHandler = function(){
log("CONNECTED");
log("Open Publish Channel...");
publishChannel = amqp.openChannel(publishChannelOpenHandler);
log("Open Consume Channel...");
consumeChannel = amqp.openChannel(consumeChannelOpenHandler);
};

var publishChannelOpenHandler = function(channel) {
log("Opened Publish Channel");
publishChannel.declareExchange(exchangeName, "direct", false, false, false);
publishChannel.addEventListener("declareexchange", function(){log("Exchange Declared : "+exchangeName)});
publishChannel.addEventListener("close", function() { log("Channel Closed : Publish Channel" )});

};

var consumeChannelOpenHandler = function(channel) {
log("Opened Consumed Channel");
consumeChannel.addEventListener("declarequeue", function(){ log("Queue Declared : " +myQueueName); });
consumeChannel.addEventListener("bindqueue", function() { log("QUEUE BOUND: " + exchangeName + " " + myQueueName)});
consumeChannel.addEventListener("subscribe", function() { log("CONSUME: " + myQueueName)});
consumeChannel.addEventListener("close", function() {log("CHANNEL CLOSED: consume channel");});
        consumeChannel.addEventListener("message", messageHandler);

consumeChannel.declareQueue(myQueueName, false, false, false, false, false)
 .bindQueue(myQueueName, exchangeName, routingKey, false)
 .consumeBasic(myQueueName, myConsumerTag, false, true, true, false);
}

var messageHandler = function(m){
alert("A");
var body  = m.body.getString(Charset.UTF8);


if (body == "start_auction"){
ss();
}
if (body == "new_bidder"){
alert("New Bidder");
}

//log(body);
};

disconnect.onclick = function() { 
log("DISCONNECT");
amqp.disconnect();
};

send.onclick = function(){
log ("SENDING MESSAGE ....");
var body = new ByteBuffer();
body.putString("new_bidder", Charset.UTF8);
body.flip();
var headers = {};
publishChannel.publishBasic(body, headers, consumeExchange, routingKey, false, false);

};

$("clear").onclick = function() { while (console.childNodes.length > 0)
{
console.removeChild(console.lastChild);
}
};

}

any help would be highly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T16:31:08+00:00Added an answer on June 6, 2026 at 4:31 pm

    Got it…had to remove code for the declareExchange as exchange already exist. However, strange error was thrown only for direct exchange not for fanout .. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not able to build my application via Ant build.xml file when I
DDMS is not able to send location to the emulator. I have tried sending
I am using Ajax POST method to send data, but i am not able
I am not able to send the data on the second instance. The server
I'm trying to send message using tibrvsend command. The scenarios is like below ,
I am not able to send email from my yahoo id using Java mail
DDMS is not able to send location to the emulator. I have tried sending
Why I am not able to send POST request using the following command and
Not able to download artifacts from central maven repository. <mirrors> <!-- mirror | Specifies
Not able to store all binary data values into sqlite3 table using QT. For

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.