Kevin_M_182964
Jan 16, 2015Nimbostratus
do I need to add a persist entry, or does calling persist suffice?
I am trying to create persistent connections based on a transaction ID that is passed from the server to the client. I first grab the transaction ID in the header of the response from the server:
when HTTP_RESPONSE {
if {[HTTP::header exists Location]} {
get everything right of /transactions/ up to next /
set Transaction_ID [findstr [HTTP::header Location] "/transactions/" 14 /]
if persist record doesn't exist, create one
if {[persist lookup uie $Transaction_ID] equals ""} {
persist add uie $Transaction_ID 60
log local0. "[IP::client_addr]:[TCP::client_port], transaction ID: $Transaction_ID, created persist record: [persist lookup uie $Transaction_ID]"
} else {
log local0. "[IP::client_addr]:[TCP::client_port], transaction ID: $Transaction_ID, existing persist record: [persist lookup uie $Transaction_ID]"
}
}
}
I then check the subsequent requests from the client for the transaction ID in the URI:
when HTTP_REQUEST {
if { [HTTP::uri] contains "/transactions/" } {
get field from /transactions/ to next /
set Transaction_ID [findstr [HTTP::uri] "/transactions/" 14 "/"]
check if persistence record exists for this transaction
if {[persist lookup uie $Transaction_ID] equals ""} {
log local0. "[IP::client_addr]:[TCP::client_port][HTTP::uri], persist record does not exist"
} else {
persist uie $Transaction_ID
log local0. "[IP::client_addr]:[TCP::client_port][HTTP::uri], transactionID: $Transaction_ID, existing persist record: [persist lookup uie $Transaction_ID]"
}
}
}
Am I doing this right? I see two entries for each transaction ID in the persistence table. My interpretation of the persist add uie $Transaction_ID 60 statement is that it is adding an entry to the table, and persist uie $Transaction_ID is assigning this request to the pool member listed in the record. Is that how it works?