Previous topic

The nova.rpc.amqp Module

Next topic

The nova.rpc.impl_carrot Module

This Page

Psst... hey. You're reading the latest content, but it might be out of sync with code. You can read Nova 2011.2 docs or all OpenStack docs too.

The nova.rpc.common Module

class Connection

Bases: object

A connection, returned by rpc.create_connection().

This class represents a connection to the message bus used for rpc. An instance of this class should never be created by users of the rpc API. Use rpc.create_connection() instead.

close()

Close the connection.

This method must be called when the connection will no longer be used. It will ensure that any resources associated with the connection, such as a network connection, and cleaned up.

consume_in_thread()

Spawn a thread to handle incoming messages.

Spawn a thread that will be responsible for handling all incoming messages for consumers that were set up on this connection.

Message dispatching inside of this is expected to be implemented in a non-blocking manner. An example implementation would be having this thread pull messages in for all of the consumers, but utilize a thread pool for dispatching the messages to the proxy objects.

create_consumer(topic, proxy, fanout=False)

Create a consumer on this connection.

A consumer is associated with a message queue on the backend message bus. The consumer will read messages from the queue, unpack them, and dispatch them to the proxy object. The contents of the message pulled off of the queue will determine which method gets called on the proxy object.

Parameters:
  • topic – This is a name associated with what to consume from. Multiple instances of a service may consume from the same topic. For example, all instances of nova-compute consume from a queue called “compute”. In that case, the messages will get distributed amongst the consumers in a round-robin fashion if fanout=False. If fanout=True, every consumer associated with this topic will get a copy of every message.
  • proxy – The object that will handle all incoming messages.
  • fanout – Whether or not this is a fanout topic. See the documentation for the topic parameter for some additional comments on this.
exception RemoteError(exc_type=None, value=None, traceback=None)

Bases: nova.exception.NovaException

Signifies that a remote class has raised an exception.

Contains a string representation of the type of the original exception, the value of the original exception, and the traceback. These are sent to the parent as a joined string so printing the exception contains all of the relevant info.

message = 'Remote error: %(exc_type)s %(value)s\n%(traceback)s.'
exception Timeout(message=None, **kwargs)

Bases: nova.exception.NovaException

Signifies that a timeout has occurred.

This exception is raised if the rpc_response_timeout is reached while waiting for a response from the remote side.

message = 'Timeout while waiting on RPC response.'