Reader small image

You're reading from  JBoss: Developer's Guide

Product typeBook
Published inAug 2017
Reading LevelIntermediate
PublisherPackt
ISBN-139781788296199
Edition1st Edition
Languages
Right arrow
Author (1)
Elvadas Nono Woguia
Elvadas Nono Woguia
author image
Elvadas Nono Woguia

Elvadas Nono Woguia is a software engineer, consultant and Open Source tech enthusiast living in Paris area. Elvadas studied computer sciences at Ecole Polytechnique Yaounde in Cameroon and also hold a Specialized Master in IT systems Management from Ecole Centrale Paris. He has been working for 10 years now in EMEA IT industry for various companies and customers and currently employed by Red Hat as Middleware and PAAS consultant. Elvadas is Certified Oracle Web Component Developer Expert , Certified Red Hat Platform As a Service Delivery Specialist. He currently helps Red Hat customers on their open source journey to design modern and scalable architectures; build customize and integrate various Middleware and cloud technologies and products around JBoss and Openshift ecosystems. In his free time, Elvadas loves playing and watching soccer. He shared tech posts with the open source community on his blog on the red hat developers website. He cares about care about humanitarian causes ; he founded and worked to bring peace and light among the needy his charity UrgenceSolidaires.
Read more about Elvadas Nono Woguia

Right arrow

Storing and Accessing Distributed Data

In this chapter, users will learn how to deal with data caching in the JBoss ecosystem using Infinispan/JBoss Data Grid. Various configuration tips will be experimented with through labs and coding sessions. The chapter also shows how to store and retrieve data from local and remote cache, how to develop and deploy cache-based applications, how to listen to caches event, and how to leverage the Advanced Cache API to query caches. The topics covered throughout the chapter are as follows:

  • JBoss Data Grid/Infinispan architecture
    • Versioning from an upstream Infinispan project to Enterprise versions
    • JBoss Data Grid Library and Client-Server mode
  • Working with caches
    • Cache operations
    • Cache monitoring/listeners: synchronous and asynchronous
  • Cache Configuration: XML and API
  • Advanced Cache API
  • Cache visualization
  • Data replication across multiple...

JBoss Data Grid architecture

Today, data is present everywhere. We are producing and consuming more and more data. At the same time, applications need to access, process, and analyze data faster to deliver a superior user experience. In this context, data caching and in-memory processing have become very interesting options to improve applications' responsiveness. JBoss is present in the data processing and data analytics market through several products, including JBoss Data Grid. JBoss Data Grid is an in-memory, distributed, NoSQL datastore platform; it is the commercial version of the Infinispan project.

Versioning

Infinispan is the community edition on top of which Red Hat builds JBoss Data Grid.
The following table...

Working with caches

A JBoss Datagrid can be accessed in two ways. In the following section, we will explore cache management with Jboss datagrid in both Library and Client-Server topologies.

Library mode in Java SE

In Java SE, Infinispan can be used as a simple jar dependency in your project. Some applications in the BeosBank landscape may want to keep the results of the MoneyTransfer GetById operation in an Infinispan/JBoss Data Grid cache to improve their performance.

How can this be implemented using JBoss Datagrid? While calling the web service, applications can receive output similar to the following:

<?xml version="1.0" encoding="UTF-8" ?>
<MoneyTransferStream>
<moneytransfer>
<...

Clustering and visualizing caches

In the BeosBank business, as soon as a user sends a money transfer, the receiver should be able to collect the sent amount from an agency worldwide. The money transfer agency office has a client application which interacts with the global BeosBank IT database to check and validate the information provided by users. To improve this process, we can imagine a set of Data Grid servers in each country/region, where the money transfer that should be paid in the region is cached as soon as the sender validates his request. To route the Money transfer data into the proper caches, we can rely on a JBoss Fuse Enterprise Service Bus application.

This router application will send the money transfer to the target cache so that the remittance application in a different geo has direct access to the money transfer data through HotRod/Memcached or the REST protocol...

Cache advanced usages

Datagrid provides a set of features to facilitate cache usage within applications: REST API, Programmatic, and XML configuration.

REST API

JBoss Datagrid provides users with a REST API to interact with cache objects. This feature is available on the /rest context and exposes each cache resource through SERVER:PORT/rest/${CacheName}. By default, the rest-connector is protected. Edit the clustered.xml file to temporarily disable the security configuration on the REST connector:

$cd jboss-datagrid-7.0.0-server/Africa
<rest-connector socket-binding="rest" cache-container="clustered" security-domain="other" auth-method="BASIC"/>
<rest-connector socket...

XML configuration

While working with Infinispan/JBoss Datagrid, a cache configuration through Java code is the most simple option if the configuration through Java API is more suitable for simple use case and demonstration purposes. There are various constraints where considering the declarative XML configuration options may be the best option for you. Infinispan/Jboss datagrid aims to reduce at least the configuration part while dealing with the solution. By default, Infinispan will load the infinispan.xml configuration file from the application classpath.

The infinispan.xml configuration file can be performed using an XML schema. Each Infinispan version is shipped with a specific XML schema. You can find the schema for version 8.2, for example, at the following addresses:

Grid computing

JBoss DataGrid is also a computing grid; nodes can be used to perform distributed computing. JBoss Datagrid provides various mechanisms to empower data stored in these nodes:

  • Distributed streams that aim to transform a cache entry set into a Java 8 Stream
  • Distributed executors that extend the Java Executor stack to schedule tasks on cache instances

Distributed Streams

Data grid can also be used as a grid computing engine to perform various computation tasks on large and distributed datasets. Users can turn all the cache entries of a local, replication, or invalidation cache into a regular Java Stream using the following operations:

cache.entrySet().stream()
cache.entrySet().parallelStream()

So, instead of iterating...

Cache security

In the real world, some applications such as MoneyTransferAgency, used in different offices to check money transfer status and validate remittances, will only have read-only access to predefined JBoss datagrid caches. On the other hand, the ESB flow that pushed money transfer objects into the cache will at least have write access to the cache to be able to insert new transactions. Infinispan/JBoss datagrid leverages Java standards, such as JAAS and Security Manager, to protect access to caches and cache manager.

Different mechanisms can be used depending on your topologies: While using REST API to put/get entries, you can enable security on the REST connector using a custom security-domain and authentication method:

<rest-connector socket-binding="rest" cache-container="clustered" security-domain="other" auth-method="BASIC"...

Summary

Caches play an important role in modern applications and systems architecture. They are mostly used to improve applications' response times, but also as highly available grids and distributed computing engines. Infinispan/JBoss Datagrid provides a powerful architecture on which an application can rely for caching data easily. Interconnections with the existing and new systems are facilitated by a variety of protocols: REST, HotRod, and MemCached. Applications can embark cache instances in Library mode or consume data exposed by remote caches in a secure manner. Developers have access to a full XML configuration and advanced programmatic API to leverage infinispan/Jboss Datagrid features, while cache content can be monitored using Infinispan-visualizer.

With JBoss DataGrid, client applications willing to consume cached data must at least know the physical address of...

lock icon
The rest of the chapter is locked
You have been reading a chapter from
JBoss: Developer's Guide
Published in: Aug 2017Publisher: PacktISBN-13: 9781788296199
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Elvadas Nono Woguia

Elvadas Nono Woguia is a software engineer, consultant and Open Source tech enthusiast living in Paris area. Elvadas studied computer sciences at Ecole Polytechnique Yaounde in Cameroon and also hold a Specialized Master in IT systems Management from Ecole Centrale Paris. He has been working for 10 years now in EMEA IT industry for various companies and customers and currently employed by Red Hat as Middleware and PAAS consultant. Elvadas is Certified Oracle Web Component Developer Expert , Certified Red Hat Platform As a Service Delivery Specialist. He currently helps Red Hat customers on their open source journey to design modern and scalable architectures; build customize and integrate various Middleware and cloud technologies and products around JBoss and Openshift ecosystems. In his free time, Elvadas loves playing and watching soccer. He shared tech posts with the open source community on his blog on the red hat developers website. He cares about care about humanitarian causes ; he founded and worked to bring peace and light among the needy his charity UrgenceSolidaires.
Read more about Elvadas Nono Woguia