Skip to main content

Posts

Hands on Project Reactor

Cold Publisher Creating publisher which emits update every second: Flux.interval(Duration.ofSeconds(1L)) .map(element->{ return new Update(element.toString(),UUID.randomUUID().toString()); }).doOnNext(onNext->{ print("Publishing new element with key "+onNext.getKey()); }); Note: complete code is availeble at following git repository  git-repo Above flux will only start emitting elements post subscription only, and for multiple subscriptions it will replay the elements from start. Hot Publisher Creating published which doesn't wait for subscribers to subscribe, instead keeps on emitting elements and subscribers will be able catch elements which are emitted post subscription as below: hotUpdate=DirectProcessor.create(); new Thread(() -> { int state=0; do { print("generator with state "+state); hotUpdate.onNext(new Update(Integer.toString(state),UUID.randomUUID().toString())); hotUpdate.delaySequence(Duratio...
Recent posts

Communication among micro-services

Below are good articles to read on communication among micro-services. 1.  docs@microsoft.com 2.  https://dzone.com/articles/microservices-why-asynchronous-communications 3.  microservice-design-patterns 4.  https://vertx.io/docs/vertx-amqp-bridge/java/ 5.  developers.redhat.com/blog

JSR 354 Java money api indian format

 JSR 354 – is proposed as standard api for  Currency and Money handling in java. Here is how we can format amount to indian format as by default indian currency is formatted as US currency. Dependency setup: javax.money money-api 1.0.3 org.javamoney moneta 1.3 pom Default formatting: @Test public void defaultIndianFormat() { MonetaryAmount indianMoney = Monetary.getDefaultAmountFactory() .setCurrency("INR").setNumber(100000.12345).create(); MonetaryAmountFormat amountFormat=MonetaryFormats.getAmountFormat(new Locale("en-IN")); System.out.println("Default indian money format ->"+amountFormat.format(indianMoney)); } Output: Default indian money format ->INR 100,000.12 @Test public void testIndianFormat() { AmountFormatQuery query = AmountFormatQueryBuilder.of(new Locale("en","IN")) .set(AmountFormatParams.GROUPING_SIZES,...

Using Activiti with spring mvc

Follow below steps to create web application using spring mvc and activiti in background steps :1 create maven project with following pom 4.0.0 com.gk activitiMakerChecker war 0.0.1-SNAPSHOT activitiMakerChecker Maven Webapp http://maven.apache.org 4.2.4.RELEASE 1.6 4.0.5.RELEASE 1.2 3.1.0 4.0.1.Final 3.5.6-Final org.activiti activiti-engine 5.14 org.activiti activiti-spring 5.14 org.springframework spring-beans ${org.springframework.version} org.springframework spring-context 4.2.4.RELEASE org.springframework spring-jdbc 4.2.4.RELEASE org.springframework spring-tx 4.2.4.RELEASE org.springframework spring-orm ${org.springframework.version} org.slf4j slf4j-api 1.7.2 org.hibernate hibernate-core ${org.hibernate.version} org.hibernate hibernate-entitymanager ${org.h...

Reactive programming

As per wikipedia reactive programming is declarative programming paradigm concerned with data streams and the propagation of change. Reactive programming is about having an architecture which has below four key components: Message driven  Scalable Resilient Responsive There lot of libraries/frameworks available which enable doing reactive programming across programming languages for ex in java we have RxJava, Project Reactor. Also spring 5 on wards spring framework also supports reactive programming.