Skip to content

Instantly share code, notes, and snippets.

@justincastilla
Created March 8, 2023 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justincastilla/7c64a9f3c400d5532dfe10b2c5bd9f02 to your computer and use it in GitHub Desktop.
Save justincastilla/7c64a9f3c400d5532dfe10b2c5bd9f02 to your computer and use it in GitHub Desktop.

Endpoints, Responses, Triggers, and Redis Logs

Action: Enter 'Pi' into search bar

Endpoint: /search

Response :

[
    {
        "description":"Delivery of groceries",
        "fromAccountName":"<mark>Picnic</mark>",
        "transactionType":"Online payment",
        "_class":"com.redislabs.demos.redisbank.transactions.BankTransaction",
        "amount":"34,50 €",
        "balanceAfter":"100.034,50 €",
        "fromAccount":"NL68REBK732297691",
        "id":"4396696036763886169",
        "toAccount":"NL40REBK110416157",
        "toAccountName":"lars",
        "transactionDate":"2023.03.08 at 17:58:59"},
    ...
]

Location: transactions/TransactionOverviewController.java/TransactionsOverviewController/searchTransactions

Redis Log:

10:56:31.459 [0 172.19.0.3:57728] "HGETALL" "{lars:}spring:session:sessions:3c957c29-a03f-4c9e-9fd2-b7637ecf0ef3"
10:56:31.461 [0 172.19.0.3:57726] "FT.SEARCH" "transaction_description_idx" "Pi*" "HIGHLIGHT" "FIELDS" "3" "description" "fromAccountName" "transactionType" "TAGS" "<mark>" "</mark>"
10:56:31.463 [0 172.19.0.3:57728] "HMSET" "{lars:}spring:session:sessions:3c957c29-a03f-4c9e-9fd2-b7637ecf0ef3" "lastAccessedTime" "\xac\xed\x00\x05sr\x00\x0ejava.lang.Long;\x8b\xe4\x90\xcc\x8f#\xdf\x02\x00\x01J\x00\x05valuexr\x00\x10java.lang.Number\x86\xac\x95\x1d\x0b\x94\xe0\x8b\x02\x00\x00xp\x00\x00\x01\x86\xc2\x95\x04\xe4"
10:56:31.464 [0 172.19.0.3:57728] "APPEND" "{lars:}spring:session:sessions:expires:3c957c29-a03f-4c9e-9fd2-b7637ecf0ef3" ""
10:56:31.465 [0 172.19.0.3:57728] "PEXPIRE" "{lars:}spring:session:sessions:expires:3c957c29-a03f-4c9e-9fd2-b7637ecf0ef3" "1800000"
10:56:31.465 [0 172.19.0.3:57728] "PEXPIRE" "{lars:}spring:session:sessions:3c957c29-a03f-4c9e-9fd2-b7637ecf0ef3" "2100000"
10:56:31.466 [0 172.19.0.3:57728] "HGETALL" "{lars:}spring:session:sessions:3c957c29-a03f-4c9e-9fd2-b7637ecf0ef3"
10:56:31.467 [0 172.19.0.3:57728] "HGETALL" "{lars:}spring:session:sessions:3c957c29-a03f-4c9e-9fd2-b7637ecf0ef3"

Notes:

  • search won't trigger until 2+ characters are entered
  • the <mark> and </mark> are decorators for front end to highlight the word

Action: BankTransactionForwarder triggers

Terminal:

app-redisbank_1  | 2023-03-08 18:11:30.200  INFO 1 --- [MessageBroker-1]
c.r.d.r.t.BankTransactionGenerator: 
    Streamed {
        "id":-4050108148969515941,
        "fromAccount":"NL15REBK240390170",
        "fromAccountName":"BMW FS",
        "toAccount":"NL40REBK110416157",
        "toAccountName":"lars",
        "amount":"144,83 €",
        "description":"Monthly car lease",
        "transactionDate":"2023.03.08 at 18:11:30",
        "transactionType":"Online payment",
        "balanceAfter":"99.576,07 €"
    }

app-redisbank_1  | 2023-03-08 18:11:30.200  INFO 1 --- [cTaskExecutor-1]
c.r.d.r.t.BankTransactionForwarder:
    Message received from stream:       
        MapBackedRecord
        {
            recordId=1678299090199-0,
            kvMap=
            {
                transaction=
                {
                    "id":-4050108148969515941,
                    fromAccount":"NL15REBK240390170",
                    fromAccountName":"BMW FS",
                    toAccount":"NL40REBK110416157",
                    toAccountName":"lars",
                    amount":"144,83 €",
                    description":"Monthly car lease",
                    transactionDate":"2023.03.08 at 18:11:30",
                    transactionType":"Online payment",
                    balanceAfter":"99.576,07 €"
                }
            }
        }

app-redisbank_1  | 2023-03-08 18:11:30.203  INFO 1 --- [cTaskExecutor-1]
c.r.d.r.t.BankTransactionForwarder: 
    Websocket message: 
        {
            "id":-4050108148969515941,
            "fromAccount":"NL15REBK240390170",
            "fromAccountName":"BMW FS",
            "toAccount":"NL40REBK110416157",
            "toAccountName":"lars",
            "amount":"144,83 €",
            "description":"Monthly car lease",
            "transactionDate":"2023.03.08 at 18:11:30",
            "transactionType":"Online payment",
            "balanceAfter":"99.576,07 €"
        }

Redis Log:

1678299089.304344 [0 172.19.0.3:59276] "XREAD" "BLOCK" "1000" "STREAMS" "transactions" "$"
1678299090.198128 [0 172.19.0.3:57726] "TS.ADD" "balance_ts" "*" "99576.06999999998"
1678299090.198905 [0 172.19.0.3:57728] "ZINCRBY" "bigspenders" "-144.83" "BMW FS"
1678299090.199779 [0 172.19.0.3:57728] "XADD" "transactions" "*" "transaction" "{"id":-4050108148969515941,"fromAccount":"NL15REBK240390170","fromAccountName":"BMW FS","toAccount":"NL40REBK110416157","toAccountName":"lars","amount":"144,83\\xc2\\xa0\\xe2\\x82\\xac","description":"Monthly car lease","transactionDate":"2023.03.08 at 18:11:30","transactionType":"Online payment","balanceAfter":"99.576,07\\xc2\\xa0\\xe2\\x82\\xac"}"
1678299090.201656 [0 172.19.0.3:57728] "DEL" "com.redislabs.demos.redisbank.transactions.BankTransaction:-4050108148969515941"
1678299090.202418 [0 172.19.0.3:57728] "HMSET" "com.redislabs.demos.redisbank.transactions.BankTransaction:-4050108148969515941" "_class" "com.redislabs.demos.redisbank.transactions.BankTransaction" "amount" "144,83\\xc2\\xa0\\xe2\\x82\\xac" "balanceAfter" "99.576,07\\xc2\\xa0\\xe2\\x82\\xac" "description" "Monthly car lease" "fromAccount" "NL15REBK240390170" "fromAccountName" "BMW FS" "id" "-4050108148969515941" "toAccount" "NL40REBK110416157" "toAccountName" "lars" "transactionDate" "2023.03.08 at 18:11:30" "transactionType" "Online payment"
1678299090.203020 [0 172.19.0.3:57728] "SADD" "com.redislabs.demos.redisbank.transactions.BankTransaction" "-4050108148969515941"

Endpoint: /api/balance

Response: x y coordinates for special ts visualization library

[{"x":1678298339304,"y":100034.5},...]

Redis Logs:

10:35:39.692 [0 172.19.0.3:57726] "TS.RANGE" "balance_ts" "1677695739691" "1678300539691"

Endpoint: /api/biggest_spenders

Response:

{
    "series":[11.68,148.68,1174.74],
    "labels":["Shell","CZ Insurance","Aegon Mortgages"]
}

Redis Logs:

10:35:39.692 [0 172.19.0.3:57728] "ZRANGEBYSCORE" "bigspenders" "0.0" "1.7976931348623157E308" "WITHSCORES"

Notes:

  • 0.0 is set as min value meaning biggest spenders are all members with a positive score
  • a positive amount on the transaction subtracts from the biggest_spenders sorted set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment