WebLogic Messaging API Class Library |

# IConnection.CreateSession Method

Creates an `ISession` object.

Warning: While an `IConnection` object supports multi-threaded access, an `ISession` object only supports single threaded access and multi-threaded behavior is undefined. If an application requires multiple concurrently active consumers and/or producers, then the application must create multiple sessions. See the WebLogic .NET programmer's guide best practices section for additional details on properly coding applications for thread safety when using sessions and their child messages, consumers, and producers; also see the API class doc for WebLogic.Messaging.ISession.

ISession CreateSession(
Constants.SessionMode sessionMode
);

#### Parameters

Constants.SessionMode
  Indicates either if session is transacted or if the consumer or the client will Acknowledge any messages it receives; Legal values are `Constants.SessionMode.AUTO_ACKNOWLEDGE`, `Constants.SessionMode.CLIENT_ACKNOWLEDGE`, `Constants.SessionMode.DUPS_OK_ACKNOWLEDGE`, `Constants.SessionMode.NO_ACKNOWLEDGE`, and `Constants.SessionMode.SESSION_TRANSACTED`.

#### Return Value

a newly created session

#### Exceptions

Exception Type | Condition
--- | ---
MessageException | if the `IConnection` object fails to create a session due to some internal error or lack of support for the specific SessionMode.

#### See Also

IConnection Interface | WebLogic.Messaging Namespace | AUTO_ACKNOWLEDGE | CLIENT_ACKNOWLEDGE | NO_ACKNOWLEDGE | DUPS_OK_ACKNOWLEDGE | SESSION_TRANSACTED