Thursday, October 17, 2019

Monday, October 14, 2019

JAVA JMS: RocketMQ NameServer Broker Cluster


Simple Note

After bind necessary ports
(see Connect to VirtualBox Guest Machine from Host OS with NAT Port Forwarding)

Creat Docker Image with Dockerfile
(see Create Dockerfile for Docker Image of RocketMQ NameServer)

Can give it a try finally...

Testing Video

https://youtu.be/mHuEyVh0eUk

The command for start broker is slightly different, add -c to use specific config and specify multiple nameServer address

e.g.

mqbroker.cmd -c ../conf/2m-2s-sync/broker-a.properties -n localhost:9487;localhost:9478 autoCreateTopicEnable=true


All files in the test project

RocketMQCluster


Saturday, October 12, 2019

Create Dockerfile for Docker Image of RocketMQ NameServer


Simple Note

Please refer to this Dockerfile  and README.md

References

Docker run reference

docker build

Connect to VirtualBox Guest Machine from Host OS with NAT Port Forwarding


Motivation

I want to connect to NameServers in Docker Containers,
and the Docker installed on Ubuntu 18.04,
and the Ubuntu 18.04 running in VirtualBox on my Windows Host OS,

... so this is required.


Simple Notes

Step 1: Right click on stopped (power off) machine, click "Settings..."



Step 2: Click Network -> Advanced -> Port Forwarding



Step 3: Click the add Sign, input Host Port and Guest Port, click OK



Now the request to localhost:9487 will be forwarded to the Guest Machine

Reference

How to Forward Ports to a Virtual Machine and Use It as a Server

Monday, October 7, 2019

Install Docker on Ubuntu 18.04


Motivation

I want to try RocketMQ Cluster with Multi-NameServers/Brokers, but it seems change port of NameServer is not supported...

So want to run 2 NameServers in 2 Docker Containers and bind to different ports for testing.

Simple Note

Install Docker on Ubuntu 18.04 running in VirtualBox

# Uninstall old versions
sudo apt-get remove docker docker-engine docker.io containerd runc

# SET UP THE REPOSITORY
## Update the apt package index
sudo apt-get update

## Install packages to allow apt to use a repository over HTTPS
sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

## Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

## Verify that you now have the key with the fingerprint 9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88, by searching for the last 8 characters of the fingerprint.
sudo apt-key fingerprint 0EBFCD88

## Use the following command to set up the stable repository
sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"


# INSTALL DOCKER ENGINE - COMMUNITY
## Update the apt package index.
sudo apt-get update

## Install the latest version of Docker Engine - Community and containerd, or go to the next step to install a specific version:
sudo apt-get install docker-ce docker-ce-cli containerd.io

## Verify that Docker Engine - Community is installed correctly by running the hello-world image.
sudo docker run hello-world




Reference

Get Docker Engine - Community for Ubuntu

RocketMQ not support modify nameServer port

Friday, October 4, 2019

JAVA JMS: RocketMQ Getting Started


Simple Notes

1. Download NameServer and Broker
  Go to archive.apache.org
  Download release zip file
  (I choose 4.5.2/rocketmq-all-4.5.2-bin-release.zip)

2. Extract it
  Assume I extract it to
  D:\things\Downloads\rocketmq\rocketmq-all-4.5.2-bin-release

3. Start NameServer
  Open cmd, run commands below
  cd D:\things\Downloads\rocketmq\rocketmq-all-4.5.2-bin-release\bin
  D:
  set JAVA_HOME=D:\things\programs\Java\jdk1.8.0_221
  set ROCKETMQ_HOME=D:\things\Downloads\rocketmq\rocketmq-all-4.5.2-bin-release\
  mqnamesrv.cmd -n localhost:9876


4. Start Broker
  Open cmd, run commands below
  cd D:\things\Downloads\rocketmq\rocketmq-all-4.5.2-bin-release\bin
  D:
  set JAVA_HOME=D:\things\programs\Java\jdk1.8.0_221
  set ROCKETMQ_HOME=D:\things\Downloads\rocketmq\rocketmq-all-4.5.2-bin-release\
  mqbroker.cmd -n localhost:9876 autoCreateTopicEnable=true


5. Write Consumer and Producer for test

  TestConsumer.java ; TestProducer.java ; and this is a maven project, so pom.xml
  Run TestConsumer and TestProducer, you will see something in the console.

References

Quick Start
https://rocketmq.apache.org/docs/quick-start/

Simple Message Example
https://rocketmq.apache.org/docs/simple-example/

Thursday, October 3, 2019

JAVA RSA Sign Data and Verify


Simple Note

Add Sign data by Signature with Private Key and verify data by Signature with Public Key

RSAUtils.java

Also add Test Cases and Performance Testing

TestRSAUtils.java

TestRSAPerformance.java

and update the Performance Testing google sheet

JAVA RSA Performance Testing

Reference

Java Cryptography Architecture (JCA) Reference Guide
Generating and Verifying a Signature Using Generated Keys
https://docs.oracle.com/javase/8/docs/technotes/guides/security/crypto/CryptoSpec.html#SigEx

Java Doc of Signature
https://docs.oracle.com/javase/7/docs/api/java/security/Signature.html