Skip Headers

# Session Broker Architecture

Previous

Next

As Figure: TopLink Session Broker with Server Session Architecture illustrates, a session broker contains a broker object that acts as an intermediary between the application and the multiple sessions added to the session broker.

To construct a session broker, use TopLink Workbench to modify your `sessions.xml` file as follows:

1. Define two or more sessions (of the same type, either server sessions or database sessions).

2. Define a session broker.

3. Add the sessions to the session broker.

When you use `SessionManager` method `getSession(sessionBrokerName)` where `sessionBrokerName` is the name of the session broker you defined, the session manager returns the corresponding session broker session (call it `mySessionBroker`) that contains an instance of each of the sessions you added to it. When you use `mySessionBroker` method `login`, it logs into each defined session. Thereafter, you use `mySessionBroker` as you would any other session: TopLink transparently handles access to the multiple databases.

In the case of a three-tier architecture where the session broker contains two or more server sessions, you use session broker method `acquireClientSessionBroker` to acquire a single client session that lets you query across all the data sources managed by the various server sessions. You use this client session as you would any other client session.