WebLogic Messaging API Class Library |

# ISession.CreateConsumer Method (IDestination, String, Boolean)

Creates `IMessageConsumer` for the specified destination, using a message selector. This method can specify whether messages published by its own connection should be delivered to it, if the destination is a topic.

Since `IQueue` and `ITopic` both inherit from `IDestination`, they can be used in the destination parameter to create a `IMessageConsumer`.

A client uses a `IMessageConsumer` object to receive messages that have been published to a destination.

In some cases, a connection may both publish and subscribe to a topic. The consumer `NoLocal` attribute allows a consumer to inhibit the delivery of messages published by its own connection. The default value for this attribute is False. The `noLocal` value is supported by destinations that are topics.

IMessageConsumer CreateConsumer(
IDestination destination,
String messageSelector,
Boolean noLocal
);

#### Parameters

IDestination
  the `IDestination` to access
String
  only messages with properties matching the message selector expression are delivered. A value of null or an empty string indicates that there is no message selector for the message consumer.
Boolean
  - if true, and the destination is a topic, inhibits the delivery of messages published by its own connection. The behavior for `NoLocal` is not specified if the destination is a queue.

#### Return Value

An `IMessageConsumer` for the specified destination

#### Exceptions

Exception Type | Condition
--- | ---
MessageException | if the session fails to create a IMessageConsumer due to some internal error.
InvalidDestinationException | if an invalid destination is specified.
InvalidSelectorException | if the message selector is invalid.

#### See Also

ISession Interface | WebLogic.Messaging Namespace | ISession. Overload List | Message selector syntax.