Dispatch messages from a single connection to pool members
I'm trying to write irules to do message-based load balancing. I am not using SIP/radius/diameter, so cannot use an existing profile. The request messages are all sent over a single TCP connection. Each message has a 8-byte header, of which the last 4 bytes store the length of the message body. I want the load balancer to forward messages to pool members in a round-robin manner. Currently, the problem is after "TCP::notify request" is executed, the USER_REQUEST won't fire. The irules are pasted below:
when CLIENT_ACCEPTED {
log local0.debug "Get a connection"
TCP::collect
}
when CLIENT_DATA {
log local0.debug "in CLIENT_DATA"
binary scan [TCP::payload] II head rlen
if {($head & 0x3) == 1} {
if {[TCP::payload length] < $rlen} {
TCP::collect $rlen
log local0.debug "a message is received"
TCP::release $rlen
TCP::notify request
log local0.debug "requested"
}
}
}
when USER_REQUEST {
Dispatch to the pool
log local0.debug "in USER_REQUEST"
pool my_pool
}
Thank you for your help!
Shu