Skip to content

Commit aeb0f83

Browse files
committed
adding POJO example
1 parent a05dc17 commit aeb0f83

File tree

1 file changed

+155
-2
lines changed

1 file changed

+155
-2
lines changed

examples/gemfire/demo/README.md

Lines changed: 155 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ i.e.</br>
1414
wget -c https://github.com/redis-field-engineering/redis-connect-dist/archive/main.zip && \
1515
mkdir -p redis-connect/demo && \
1616
unzip main.zip "redis-connect-dist-main/examples/gemfire/*" -d redis-connect && \
17-
cp -R redis-connect-dist-main/examples/gemfire/demo/* redis-connect/demo && \
18-
rm -rf main.zip redis-connect/redis-connect-dist-main && \
1917
cd redis-connect && \
18+
cp -R redis-connect-dist-main/examples/gemfire/demo/* ./demo && \
2019
chmod a+x demo/*.sh && \
20+
rm -rf ./redis-connect-dist-main && rm ../main.zip && \
2121
cd demo
2222
```
2323

@@ -365,3 +365,156 @@ demo$
365365

366366
</p>
367367
</details>
368+
369+
### More Complex Data Types
370+
371+
This demo also includes an example of using more complex Java types within Gemfire. The `extlib` folder contains 2 jar files:
372+
1. `gemfire-pojo-1.0.jar`
373+
2. `redis-connect-custom-stage-sample-*.jar`
374+
375+
The first contains the code for a `redis.gemfire.Customer` class, which is a very simple POJO containing a name and age, and the later is a build of [redis-connect-custom-stage](https://github.com/redis-field-engineering/redis-connect-custom-stage-sample) containing some custom staging code to transform whatever arbitrary data type (in this case a `Customer`) into a type redis-connect can serialize to `JSON`.
376+
377+
#### Configure Job
378+
379+
On [http://localhost:8282/swagger-ui/index.html]() go to:
380+
381+
**Create Job Configuration** - `/connect/api/vi/job/config/{jobName}`
382+
<br>_For the customer pojo, use the sample `customer-pojo-job.json` configuration:_ <a href="/examples/postgres/demo/config/samples/payloads/cdc-job.json">Gemfire</a>
383+
<br>Use '**customer-pojo-job**' as the _**jobName**_
384+
<br><br><img src="/images/quick-start/Redis Connect Save Job Config.png" style="float: right;" width = 700px height = 375px/>
385+
<br>
386+
387+
Or use `curl` to create the `customer-pojo-job` configuration
388+
389+
`$ curl -v -X POST "http://localhost:8282/connect/api/v1/job/config/customer-pojo-job" -H "accept: */*" -H "Content-Type: multipart/form-data" -F "file=@config/samples/payloads/customer-pojo-job.json;type=application/json"`
390+
391+
#### Start Load Job
392+
393+
<details>
394+
<summary>INSERT customer records into gemfire</summary>
395+
<p>
396+
397+
```bash
398+
$ ./load_customers.sh
399+
Inserting records in session region..
400+
401+
(1) Executing - connect --locator localhost[10334]
402+
403+
Connecting to Locator at [host=localhost, port=10334] ..
404+
Connecting to Manager at [host=749a3ef94bf8, port=1099] ..
405+
Successfully connected to: [host=749a3ef94bf8, port=1099]
406+
407+
You are connected to a cluster of version: 1.15.1
408+
409+
410+
(2) Executing - put --key="customer1" --value=("name":"Jack","age":35) --region=customer --value-class=redis.gemfire.Customer
411+
412+
Result : true
413+
Key Class : java.lang.String
414+
Key : customer1
415+
Value Class : redis.gemfire.Customer
416+
Old Value : null
417+
418+
419+
(3) Executing - put --key="customer2" --value=("name":"Alice","age":36) --region=customer --value-class=redis.gemfire.Customer
420+
421+
Result : true
422+
Key Class : java.lang.String
423+
Key : customer2
424+
Value Class : redis.gemfire.Customer
425+
Old Value : null
426+
427+
428+
(4) Executing - put --key="customer3" --value=("name":"Bob","age":37) --region=customer --value-class=redis.gemfire.Customer
429+
430+
Result : true
431+
Key Class : java.lang.String
432+
Key : customer3
433+
Value Class : redis.gemfire.Customer
434+
Old Value : null
435+
436+
437+
(5) Executing - put --key="customer4" --value=("name":"Carol","age":38) --region=customer --value-class=redis.gemfire.Customer
438+
439+
Result : true
440+
Key Class : java.lang.String
441+
Key : customer4
442+
Value Class : redis.gemfire.Customer
443+
Old Value : null
444+
445+
446+
(6) Executing - put --key="customer5" --value=("name":"David","age":39) --region=customer --value-class=redis.gemfire.Customer
447+
448+
Result : true
449+
Key Class : java.lang.String
450+
Key : customer5
451+
Value Class : redis.gemfire.Customer
452+
Old Value : null
453+
454+
455+
(7) Executing - put --key="customer6" --value=("name":"Eva","age":40) --region=customer --value-class=redis.gemfire.Customer
456+
457+
Result : true
458+
Key Class : java.lang.String
459+
Key : customer6
460+
Value Class : redis.gemfire.Customer
461+
Old Value : null
462+
463+
464+
(8) Executing - put --key="customer7" --value=("name":"Frank","age":41) --region=customer --value-class=redis.gemfire.Customer
465+
466+
Result : true
467+
Key Class : java.lang.String
468+
Key : customer7
469+
Value Class : redis.gemfire.Customer
470+
Old Value : null
471+
472+
473+
(9) Executing - put --key="customer8" --value=("name":"Grace","age":42) --region=customer --value-class=redis.gemfire.Customer
474+
475+
Result : true
476+
Key Class : java.lang.String
477+
Key : customer8
478+
Value Class : redis.gemfire.Customer
479+
Old Value : null
480+
481+
482+
(10) Executing - put --key="customer9" --value=("name":"Henry","age":43) --region=customer --value-class=redis.gemfire.Customer
483+
484+
Result : true
485+
Key Class : java.lang.String
486+
Key : customer9
487+
Value Class : redis.gemfire.Customer
488+
Old Value : null
489+
490+
491+
(11) Executing - put --key="customer10" --value=("name":"Ivy","age":44) --region=customer --value-class=redis.gemfire.Customer
492+
493+
Result : true
494+
Key Class : java.lang.String
495+
Key : customer10
496+
Value Class : redis.gemfire.Customer
497+
Old Value : null
498+
499+
done
500+
```
501+
502+
</p>
503+
</details>
504+
505+
**Start Job -** `/connect/api/vi/job/transition/start/{jobName}/{jobType}`
506+
<br>Use '**load**' as _**jobType**_ and '**customer-pojo-job**' as the _**jobName**_
507+
<br><br><img src="/images/quick-start/Redis Connect Start Job.png" style="float: right;" width = 700px height = 375px/>
508+
509+
**Or Use `curl` to start the initial load for `cdc-job`** <br>
510+
`$ curl -X POST "http://localhost:8282/connect/api/v1/job/transition/start/customer-pojo-job/load" -H "accept: */*"`
511+
512+
#### Query Data in Redis
513+
514+
Your data is now available in Redis at the keys `{gemfireRegionName}:{gemfireKeyName}`, and be queried in redis using the redis-cli:
515+
516+
517+
```bash
518+
$ redis-cli -p 14000 JSON.GET customer:customer1 $
519+
"[{\"name\":\"Jack\",\"age\":35}]"
520+
```

0 commit comments

Comments
 (0)