WebLogic Messaging API Class Library |

# ISession.CreateConsumer Method (IDestination, String)

Creates an `IMessageConsumer` for the specified destination, using a message selector. 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 sent to a destination.

IMessageConsumer CreateConsumer(
IDestination destination,
String messageSelector
);

#### 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.

#### 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.