Hi,

I'm just having a play with RabbitMQ and I'm getting some connection
issues when connecting with Java, however, if I connect with a Ruby
client to the same channel it's fine, and then it seems to create the
channel and the Java client plays nicely after that. Am I missing
some 'create channel' call?

Cheers Robbie

ConnectionParameters params = new ConnectionParameters();
params.setRequestedHeartbeat(0);
ConnectionFactory factory = new ConnectionFactory(params);
Connection conn = factory.newConnection("localhost");
Channel channel = conn.createChannel();
channel.exchangeDeclare("allqueues", "direct");
channel.queueDeclare("queue name");
channel.queueBind("queue name", "all queues", "routingKey");
byte[] messageBodyBytes = "Hello, world!".getBytes();
channel.basicPublish("all queues", "routingKey", null, messageBodyBytes);

Ruby:

require 'mq'
require 'pp'
EM.run do
connection = AMQP.connect(:host => 'localhost', :logging => false)
channel = MQ.new(connection)
queue = MQ::Queue.new(channel, 'queue name')
exchange = MQ::Exchange.new(channel, :fanout, 'all queues')
queue.bind(exchange)
exchange.publish('<transcribe id=\"something\"/>')
exchange.publish('some more stuff')
end

Here's the exception I get from the Java client:

com.rabbitmq.client.ShutdownSignalException (channel error; reason:
{#method<channel.close>(reply-code@4,reply-text=NOT_FOUND - no
exchange 'all queues' in vhost '/',class-idP,method-id ),null,""})
at com.rabbitmq.client.impl.ChannelN.processAsync(ChannelN.java:191)
at com.rabbitmq.client.impl.AMQChannel.handleCompleteInboundCommand(AMQChannel.java:159)
at com.rabbitmq.client.impl.AMQChannel.handleFrame(AMQChannel.java:110)
at com.rabbitmq.client.impl.AMQConnection$MainLoop.run(AMQConnection.java:456)

Search Discussions

  • Matthias Radestock at Feb 2, 2009 at 8:12 am
    Robbie,

    Robbie Clutton wrote:
    channel.exchangeDeclare("allqueues", "direct");
    ...
    channel.basicPublish("all queues", "routingKey", null, messageBodyBytes); [...]
    com.rabbitmq.client.ShutdownSignalException (channel error; reason:
    {#method<channel.close>(reply-code@4,reply-text=NOT_FOUND - no
    exchange 'all queues' in vhost '/',class-idP,method-id ),null,""})
    The server tells you exactly what is wrong :)

    You are declaring an exchange "allqueues" but try to publish to an
    exchange "all queues".


    Matthias.
  • Robbie Clutton at Feb 2, 2009 at 8:17 am
    2009/2/2 Matthias Radestock <matthias at lshift.net>:
    Robbie,

    Robbie Clutton wrote:
    channel.exchangeDeclare("allqueues", "direct");
    ...
    channel.basicPublish("all queues", "routingKey", null,
    messageBodyBytes); [...]
    com.rabbitmq.client.ShutdownSignalException (channel error; reason:
    {#method<channel.close>(reply-code@4,reply-text=NOT_FOUND - no
    exchange 'all queues' in vhost '/',class-idP,method-id ),null,""})
    The server tells you exactly what is wrong :)

    You are declaring an exchange "allqueues" but try to publish to an exchange
    "all queues".
    that's definitely an 'aha' moment. Thanks.
    Matthias.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprabbitmq-discuss @
categoriesrabbitmq
postedFeb 2, '09 at 8:03a
activeFeb 2, '09 at 8:17a
posts3
users2
websiterabbitmq.com
irc#rabbitmq

People

Translate

site design / logo © 2022 Grokbase