Bind customised KeyStore,TrustStore and PoolingHttpClientConnectionManager in Apache Camel
In Apache HTTPClient 4.x, PoolingHttpClientConnectionManager and BasicHttpClientConnectionManager can be used as Connection Managers for HTTP Client. By default, above two Connection Managers load cacerts trust store, from $JRE_HOME/lib/security directory, not programmatically specified.
Since Apache Camel starts supporting HTTP4 Component, camel-http4 is using Apache HTTPClient 4.x. The following is a solution how to customise PoolingHttpClientConnectionManager and SSLContext to use specified KeyStore and TrustStore.
In application.properties file defined environment specified KeyStore and TrustStore:
1 | ... |
Without Connection Managers like PoolingHttpClientConnectionManager and BasicHttpClientConnectionManager in Apache HTTPClient 4.x, Apache Camel Route can be written in this way, binding programmatically specified KeyStore and TrustStore.
References
- Apache Camel HTTP4 Component, http://camel.apache.org/http4.html
- Java SSL with Multiple KeyStores, http://codyaray.com/2013/04/java-ssl-with-multiple-keystores
- Multiple Keystores in Apache Camel/HttpClient, http://codyaray.com/2013/05/multiple-keystores-in-apache-camelhttpclient
Inspirational Thought
Inspirational Thought from Jeff Bezos.
After new Macbook Air, Mac Mini, iPad Pro 2018
最新的苹果发布会是一次团结的大会,求实的大会,胜利的大会。在以苹果总书记库克同志为核心的领导下,Apple Design 拨乱反正,继往开来,重拾经典。
Macbook Air 得以继续,Mac Mini 得到重生。iPad Pro 在经过不断的探索、失败后,终于拿出一款震撼心灵的设计,以及一款与时共进的 Apple Pencil。
新 iPad Pro 的机身背面内置了102 块磁铁,保证了 flat 扁平的这款 Apple Pencil 可牢固吸附在机身上,同时也能给 Apple Pencil 进行无线充电。这个设计优雅,实用,点赞必须。Furthermore, 边框塑性换成了方正的造型,重回 iPhone 5 方正边框的精典设计。从屏幕到外形,从外设到连接性,新 iPad Pro 的所有功能都是朝着高生产力笔记本电脑的 ecosystem 前进。
今天墨尔本赛马节,全维多利亚州人民在春天的草地上撒野。信主也准备潇洒一把。
登上了苹果网站,发现新 Apple Pencil 提供个人定制激光刻字服务。输入洋文 “Best there ever will be“ (后无来者的意思),苹果嫌弃太长。换成国语 “民族英雄 小平赠“,苹果又 handle 不了。无奈只好取消 $2,349.00 新 iPad Pro 和 $199.00 新 Apple Pencil 的订单 。
有钱花不出去,郁闷啊 … …
Setup Lambda migrate & sync AWS DynamoDB to new table
AWS DynamoDB is a good persistence solution for a specific solution. However, it’s not for a growing and changing application that could need new indexes and queries for its ever expanding features at any time. At this moment it is where the flexibility and speed of a relational database really shined through.
Now, a DynamoDB table with Consumers Preferences data urgently needs to update:
- RENAME one EXISTING attribute
- ADD a new attribute
- SET a value in the new attribute for ALL EXISTING items in DynamoDB’s new table
AWS lambda function plays handy here to migrate data, and sync newly inserted, modified / updated, deleted items between existing and new DynamoDB tables.
- Create new DynamoDB table
1 | aws dynamodb create-table \ |
Migrate Data
- Create Migrate Data Lambda function
Increase Memory and Runtime Timeout https://docs.aws.amazon.com/lambda/latest/dg/limits.html in case of execution pre-maturely ended without finishing the migration. Furthermore, in case of overcharging DynamoDB due to its limits https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Limits.html add time delay in Lambda function.
migrate.js
- Add AWS DynamoDB Lambda execution role
userpreferences-ptest-02-migrateRole
- Create a simple test event that can kick off function
1 | { |
Trigger run the function. Should see the data migrated from existing DynamoDB table into new table.
Log can be found at AWS CloudWatch Log Groups /aws/lambda/userpreferences-ptest-02-migrate
Sync Data
- Enable Stream on the existing DynamoDB table
- Add a new trigger for DynamoDB table
- Create a new Lambda function linked to trigger
sync.js
- Trigger Testing
AWS Lambda built-in test can test trigger:
- Logging
Lambda function log can be found on AWS CloudWatch Log Groups /aws/lambda/userpreferences-ptest-02-sync
Counter Data
This Lambda function can count the number of items in DynamoDB table.
counter.js
Async call, callback and Non-blocking, it’s very hard implement so in every applications. In addition, reject promises or async functions, don’t handle them with a catch, NodeJS will raise a warning. In a large complex applications with lots of async, having a single unhandled promise or await function terminate NodeJS, or have to handle them with try and catch in every place (spaghetti code again?) would be very bad.
An example of AWS DynamoDB error:
1 | 2018-11-14T02:20:50.742Z 715f18fb-e7b3-11e8-b5c4-d75f9089dd50 Error thrown: { ProvisionedThroughputExceededException: The level of configured provisioned throughput for the table was exceeded. Consider increasing your provisioning level with the UpdateTable API. |
AWS example doesn’t throw the error in the catch block, it returns error instead, so any errors end up in the catch block. And return promises early and use Promise.all() method.
References
- DynamoDB: Changing table schema, https://www.abhayachauhan.com/2018/01/dynamodb-changing-table-schema/
- Tutorial: Processing New Items in a DynamoDB Table, https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/Streams.Lambda.Tutorial.html
- How to escape async/await hell, https://medium.freecodecamp.org/avoiding-the-async-await-hell-c77a0fb71c4c
- Node.js 8.10 runtime now available in AWS Lambda, https://aws.amazon.com/blogs/compute/node-js-8-10-runtime-now-available-in-aws-lambda/
Apple Designs That Inspire / 吐槽苹果
列举一下我认为的苹果产品设计的经典。我并不是苹果的粉丝,也从来没有拥有过任何一代 iPhone 产品,from first generation iPhone, to latest iPhone XS。
经典的 iPhone 5 / 5s
适合单手操作,体重适中,不打滑,有握持感。
新 iPhone 早已没有了新鲜感。全面屏,无线充电,双卡双待,屏下指纹识别,前后双屏 … 这些都已不再成为苹果的专利。
手机设计还是有很多潜力开发。还没走到尽头。In other words, 手机是现在最具创新和有最多创新的产品了。但苹果现在已经变得保守,中庸,不思进取了。
BTW,耳机 maybe 下一个智能产品竞争领域。Headphones 已经成为手机以外第二个人手必备的设备了。
这是我在 October 23, 2012,the first generation iPad Mini was announced 时写的评论:
“It takes 30 months and 4 generatons since first release of iPad on April 3rd 2010, Apple finally gets the right size, right weight, right price, right design, right OS, right applications, right market niche, right balanced, almost no annoying public complainted issues, nearly all bugs been fixed iPad delivered”
iPad Mini 2 使用上 Retina Display. 至今仍然是轻便的不行,仍然流畅的不行。
新的“全”面屏 iPad Pro 本月要发布了。不明白“全”面屏在大屏幕设备上的意义。个人还是喜欢现在的 iPad pro 10.5. “全”面屏 iPad Pro 追求逼格,Bigger Than Bigger,牺牲掉 home button,少了一“键”钟情。
Why the hell MacBook has removed sleep light / 呼吸灯? Think about it after you have a look Transformers Mac light:
为甚 turn off 信仰灯,信仰的灯塔?有多少用户会在乎多费那么一点点用电。留下的只是深深的执念,蛋蛋的忧伤?
Magsafe 磁吸充电接口一直被认为是饱含创新和智慧设计。论安全性与便捷性还有什么比 MagSafe 做的更好?
Why small is beautiful? 看看 Mac Mini 的结构。
能把一个功能完整的 PC 主机,放进如此狭小的空间内,功耗低又安静,除了 brilliant 还能用什么来形容?
Mac Mini 已经好长时间没有更新换代。不知道苹果是否在考虑砍掉这个产品。
近几年苹果的新产品设计是感觉在吃老本,going downhill. 好的设计没有继承发扬,反而在做减法被一一去掉。新产品亮相后总感觉缺少点什么。也许是一种精神,也许是一颗灵魂。
The 10 Commandments of Good Products
The Vespa scooter is an example of how great design truly transcends time. The Vespa has been relatively unchanged in decades. The simplicity and style of it still make it a desirable item to this day.
- The 10 Commandments of Good Products, https://medium.com/swlh/the-10-commandments-of-good-products-d1d0a97b30ee
A Python script which implements Mantua Cipher
Run output from Console:
1 | PycharmProjects/cipher/venv/bin/python PycharmProjects/cipher/src/cipher.py |
Step by step resetting Bluetooth on Mac OS
Latest Mac OS High Sierra version 10.13.6.
- Open Terminal and login as user “root”:
1 | rm /Library/Preferences/com.apple.Bluetooth.plist |
- Reset the Bluetooth Module with Option + Shift + click on bluetooth icon in taskbar. Click on Debug -> Reset the Bluetooth Module
- Reset PRAM / NVRAM: Shut down; power on, immediately press Command + Option + P + R until it resets itself a couple times. Official guide https://support.apple.com/en-us/HT204063
- Reset SMC: Shut down; hold down Shift + Control + Option while holding the power button for 10 seconds. Official guide https://support.apple.com/en-us/HT201295
Cloudcraft - visualise AWS environment as isometric architecture diagrams
References
- CloudCraft, https://cloudcraft.co/