Skip to content
Mats Alm edited this page Apr 30, 2014 · 16 revisions

In your *.config file, first add the RabbitMQUtil config section.

<configSections>
  <section name="rabbitMq" type="RabbitMQUtil.Configuration.RabbitMqConfigSection, RabbitMQUtil" />
</configSections>

Then configure one or more endpoints:

<rabbitMq>
    <endpoints>
      <add name="my.subscribing.endpoint" host="localhost" port="" user="" password="" routingKey="" virtualHost="" pubSubType="Subscribe">
        <subscription queueName="my.local.queue" noAck="false" durable="true">
          <exchangeBindings>
            <add name="order" type="Fanout" routingKey="shipped" declareExchange="false"></add>
          </exchangeBindings>
          <errorConfig errorQueueName="my.error.queue" enableErrorQueue="true" rethrowExceptions="false" />
        </subscription>
      </add>
    </endpoints>
</rabbitMq>

add element This element is the main element of an endpoint.

Attribute Description Sample value
name Name of the endpoint, used to access the endpoint from code. my.endpoint
host RabbitMQ host localhost
port RabbitMQ port 55113
user RabbitMQ user guest
password RabbitMQ password guest
user RabbitMQ virtual host, if omitted the default host '/' will be used. myVhost
pubSubType Either 'Publish' or 'Subscribe'. Subscribe

subscription element This element represents a subscription and can only be added if pubSubType of the add element is Subscribe.

Attribute Description Sample value
queueName Name of the queue for this subscription. If this queue does not exist it will be created. my.queue
noAck If true, all messages will be removed from the queue when the receiver connects. If false each message will be acked when it has been processed. true
durable If true, the queue will be durable (persistent), otherwise it will be transient. true

exchangebindings.add element This element represents a binding between a queue (via the subscription) and an exchange. Multiple exchanges/routingKeys mappings can be added.

Attribute Description Sample value
name Name exchange. my.exchange
type Exchange type (Fanout or Direct or Topic or Headers) Fanout
routingKey routingKey of the binding a.routing.key.#
declareExchange If the exchange does not exist, it will be created. false

errorconfig element Configure behaviour for errorhandling.

Attribute Description Sample value
errorQueueName Name of the error queue (where messages that causes an error will be stored) my.errorqueue
enableErrorQueue If true, the error queue will be created if it does not exist and messages that will cause an error will be stored in the queue). true
rethrowExceptions if true, exceptions will be rethrown after the message has been written to the error queue. false
declareExchange If the exchange does not exist, it will be created. false

See also:

  • [Subscribe with a blocking receiver in code](Subscribe with a blocking receiver)
  • [Subscribe with a non blocking receiver in code](Subscribe with a non blocking receiver)
  • [Read metadata, properties and headers from a message](Read metadata, properties and headers)

« Back