// Route the message and the MessageClient (subscription) to the FlexClient to
// queue the message for delivery to the remote client.
// Reset the thread local FlexClient and FlexSession to be specific to the client
// we're pushing to, and then reset the context back to its original request handling state.
FlexClient requestFlexClient = FlexContext.getFlexClient();
FlexSession requestFlexSession = FlexContext.getFlexSession();
FlexClient pushFlexClient = messageClient.getFlexClient();
FlexContext.setThreadLocalFlexClient(pushFlexClient);
FlexContext.setThreadLocalSession(null); // Null because we don't have a currently active endpoint for the push client.
pushFlexClient.push(message, messageClient);
// and reset thread locals.
FlexContext.setThreadLocalFlexClient(requestFlexClient);
FlexContext.setThreadLocalSession(requestFlexSession);
}