message.setHeader(Message.VALIDATE_ENDPOINT_HEADER, Boolean.TRUE);
message.setHeader(Message.ENDPOINT_HEADER, getId());
if (message instanceof CommandMessage)
{
CommandMessage command = (CommandMessage)message;
// Apply channel endpoint level constraint; always allow login commands through.
int operation = command.getOperation();
if (operation != CommandMessage.LOGIN_OPERATION)
checkSecurityConstraint(message);
// Handle general (not Consumer specific) poll requests here.
// We need to fetch all outbound messages for client subscriptions over this endpoint.
// We identify these general poll messages by their operation and a null clientId.
if (operation == CommandMessage.POLL_OPERATION && message.getClientId() == null)
{
verifyFlexClientSupport(command);
FlexClient flexClient = FlexContext.getFlexClient();
ack = handleFlexClientPollCommand(flexClient, command);
}
else if (operation == CommandMessage.DISCONNECT_OPERATION)
{
ack = handleChannelDisconnect(command);
}
else if (operation == CommandMessage.TRIGGER_CONNECT_OPERATION)
{
ack = new AcknowledgeMessage();
}
else
{
// Block a subset of commands for legacy clients that need to be recompiled to
// interop with a 2.5+ server.
if (operation == CommandMessage.SUBSCRIBE_OPERATION || operation == CommandMessage.POLL_OPERATION)
verifyFlexClientSupport(command);
ack = getMessageBroker().routeCommandToService((CommandMessage) message, this);
// Look for client advertised features on initial connect.
if (operation == CommandMessage.CLIENT_PING_OPERATION || operation == CommandMessage.LOGIN_OPERATION)
{
Number clientVersion = (Number)command.getHeader(CommandMessage.MESSAGING_VERSION);
handleClientMessagingVersion(clientVersion);
// Also respond by advertising the messaging version on the
// acknowledgement.
ack.setHeader(CommandMessage.MESSAGING_VERSION, new Double(messagingVersion));