Tuesday, September 10, 2019

Conventional Architectures and Modern Architectures

Fundamental structure developed with a set of abstract layers that connect together to develop a logical body called as the architecture.  The architecture is a blueprint to develop a working system.  The architecture required to confirm conceptually the output of the physical (software or hardware) body to produce the required results.  The architecture are required because, it helps making fundamental structural choices that are costly to change once implemented.  Software architecture is the conceptual glue that holds every phase of the project together for all of its stakeholders. Architecture is an artifact for early analysis to make sure that a design approach will yield an acceptable system. By building an effective architecture, you can identify design risks and mitigate them early in the development process.
The architecture of a software system describes its major components and their relationships how they interact with each other. Software architecture and design includes several factors such as Organization Strategy and Guidelines, Market Agility, quality and security, open Standards, Standard Protocols, and IT environment and support as shown below.

In order to achieve the best results from the products, architecture defines a structured solution to meet all the technical and operational requirements, while optimizing the common quality attributes like performance and security with possible lease cost.

Business function of a company always look for innovative way to solve the daily problems.  Teams coming with innovative ideas to solve the business problem identified with business functions and capabilities of the new idea.  The products developed using those ideas. While developing products some architectural decisions made during the early phases of the innovation process.  To develop the business functional supporting product, the product architecture defines the components for a business, their configurations, and how are interconnected to implement using the technology.  Most widely accepted definitions of product architecture given by Ulrich () as “the scheme by which the function of a product is allocated to physical components,” more precisely as:
1.       the arrangement of functional elements
2.      the mapping from functional elements to physical components
3.      the specification of the interfaces among interacting physical components
The conventional architectures developed using the patterns that play an abstract role to develop the architecture blue print.  There are some famous patters given below are used by the industry for decades. 
·         Client- Service Architectures
·         Layered (N-tier) architectures
·         Event-driven architecture
·         Service Oriented Architectures
·         MVC Architecture for Web applications
·         Microservices architecture
Starting from the Client service architectures, which greatly supported for the product development approaches, continuous change and continuous need of evolvement of architectures, become part of daily routine of the IT world.
Even though the convention designs still used in the latest architectures, every architecture patter has its own advantages and disadvantages.  There are multiple high-level architecture patterns and principles commonly used in modern systems. These often referred to as architectural styles. The architecture of a software system is rarely limited to a single architectural style. Instead, a combination of styles often make up the complete system.
The architectures were not only limited to the software products, it also includes the software platforms.  “The software platforms majorly affected the recent thinking with cloud, big data, artificial intelligence, streaming approaches, and mobile platform support”. With the evolvement of the cloud bases services now the HAAS, PAAS, SAAS, DAAS, etc. patterns within the cloud stagey greatly appreciated by the IT world.  With the cloud solutions, every solution greatly supporting the market agility, quick go to market, and quick roll off while addressing the common concerns by using the expert level services is possible by separating the general operation and platform setup and security out of the core business while reducing the turnaround time and implementation cost. Similarly, the Streaming platforms designed to solve these problems in a modern, distributed architecture. The main benefits are Sending Right Message, transferring message fast, and scalable data integration.  The artificial intelligence is there in the computer world from the beginning.  However in the recent solutions it becoming possible to find out the new business pattern using the archived data, comparing the unstructured (images, voices) data, detailed insight analysis of data (medical x-ray, building damages, theft analysis using videos, facial expressions analysis, etc.) is becoming modern needs which ultimately causing to think the modern product architecture styles.
In simple, conventional product architectures used to think solving only the business problem, but the latest product architectures trying to analyse its own generated archive data and generate more business opportunities, it is also trying to support the operational teams by making self-decisions on scalability, informing the errors by alerts etc.
Irrespective of either the conventional or the recent architecture certainly follow the below five core steps to develop its architecture. However, the future analysis step may change to the traditional process improvement approach.
1.       Define – determine the goals (reduce time/cost, gain quality/flexibility etc.)
2.      Analyse – decompose the product specification into data elements and identify the associated business rules.
3.      Evaluate – conduct a gap analysis, compare existing and redesign process measurements, and build a credible business case.
4.      Implement – establish urgency for change, manage resistance, train staff, and implement the redesigned process.
5.      Control – create a dashboard of trend and control reports.
6.      Monitoring – Self monitoring and sending alerts in advance to take proactive actions
For the easy and quick software development, the design principles also follow:
1.       Maintainable - Easy way maintaining the code, deployments
2.      Testable – Easy and automated testing mechanisms
3.      Separation of Roles -- During development reducing the dependency among the teams is important by separating the "roles"
4.      Automated Deployments – Making easy and quick deployment with automating scripts
5.      Small components -- Websites with small components, micro services
6.      API – Sharing the corporate data securely over the API gateways.
7.      Rapid Development – Using reusable platforms and tools
8.     Integrated communication – It is important to have the correct and integrated communication and data sharing among the teams by using the integrated development platforms.

Conclusion:
Defining the architecture then developing the product by following it is highly adopted by the industry as the best approach.  This will help the business to fail fast with less cost, analyse with logical conclusions.  While developing a product analysing and using the latest trends and standards, as the best practices will help the products to sustain in the market for a longer time as it supports the future enhancements of the technology.  There is no single architecture that suitable for all products, so as the business changes its dimensions the technology and architectures keep change their dimensions and it continues.

The conventional approach built around the database, business logic, and presentation but the recent applications started thinking on cloud, big data, mobile, Artificial Intelligence, and Streaming aspects.

Monday, December 3, 2018

Loading TrustStore and KeyStore from an external directory Sample Code

package com.sample.khavara;

import java.security.KeyStore;
import java.util.ArrayList;
import java.util.List;

import org.apache.http.client.HttpClient;
import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.ssl.SSLContextBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.core.io.Resource;
import org.springframework.http.client.ClientHttpRequestFactory;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.HttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.web.client.RestTemplate;
import com.fasterxml.jackson.databind.ObjectMapper;

@Configuration
@Profile({"dev", "test", "prod"})
public class RestTemplateSecureConfiguration {

@Autowired
private ApplicationContext context;

@Autowired
private ObjectMapper objectMapper;

@Value("${spring.resttemplate.ssl.client.keystore}")
private String keyStoreFile;
@Value("${spring.resttemplate.ssl.client.key-store-password}")
private String keyStorePassword;
@Value("${server.ssl.trust-store}")
private String trustStoreFile;
@Value("${server.ssl.trust-store-password}")
private String trustStorePassword;

private static final String KEYSTORE_TYPE = "JKS";

@Bean
public RestTemplate restTemplate() throws Exception {
RestTemplate restTemplate = new RestTemplate(clientHttpRequestFactory());
List> messageConverters = new ArrayList<>();
MappingJackson2HttpMessageConverter jsonMessageConverter = new MappingJackson2HttpMessageConverter();
jsonMessageConverter.setObjectMapper(objectMapper);
messageConverters.add(jsonMessageConverter);
restTemplate.setMessageConverters(messageConverters);
return restTemplate;
}

private ClientHttpRequestFactory clientHttpRequestFactory() throws Exception {
ClientHttpRequestFactory requestFactory = new HttpComponentsClientHttpRequestFactory(httpClient());
return requestFactory;
}

private HttpClient httpClient() throws Exception {
KeyStore keyStore = loadKeyStore();
KeyStore trustStore = loadTrustStore();
SSLConnectionSocketFactory socketFactory = createSSLConnectionSocketFactory(keyStore, trustStore);
HttpClient httpClient = HttpClients.custom().setSSLSocketFactory(socketFactory).build();
return httpClient;
}

private KeyStore loadTrustStore() throws Exception {
Resource resource = context.getResource(trustStoreFile);
KeyStore trustStore = KeyStore.getInstance(KEYSTORE_TYPE);
trustStore.load(resource.getInputStream(), trustStorePassword.toCharArray());
return trustStore;
}

private KeyStore loadKeyStore() throws Exception {
Resource resource = context.getResource(keyStoreFile);
KeyStore keyStore = KeyStore.getInstance(KEYSTORE_TYPE);
keyStore.load(resource.getInputStream(), keyStorePassword.toCharArray());
return keyStore;
}

private SSLConnectionSocketFactory createSSLConnectionSocketFactory(KeyStore keyStore, KeyStore trustStore) throws Exception {
SSLConnectionSocketFactory socketFactory = new SSLConnectionSocketFactory(new SSLContextBuilder()
.loadTrustMaterial(trustStore, new TrustSelfSignedStrategy())
.loadKeyMaterial(keyStore, keyStorePassword.toCharArray()).build());
return socketFactory;
}
}

Monday, February 5, 2018

Reading exclamation mark (!) from command line on windows for scala script

Hi,
I was wondering while I was able to send the ! character as part command line argument to scala script on Linux shell but not on Windows.

Here is my Scala Script in Hello.scala file

object Hello extends App{
args.foreach( println(_))
}


Execution command from the command prompt on linux is

$scala  Hello.scala  This is my input!

Expected out is coming fine with ! mark, however the same thing on Windows machine the ! mark is not coming.  Here is the reason the windows shall take the input characters with escaped ^ and the command needs to be with in the string.  So the below command will come fine on the windows.

C:\>scala  Hello.scala  This is my "input^!"


====================== ENJOY LEARNING ==================

Thursday, December 7, 2017

WSO2 not getting carbon login page with host name or IP address but works well for localhost

I have started exploring the WSO2 Enterprise Integrator.  I am happy that the installation is as simple as tomcat installation (just copy the the root folder on to your system and start running it.) with prior JDK on your system.  After starting the server I am able to login to the Management console using the https://localhost:9443/carbon  or  https://127.0.0.1:9443/carbon URL.  However if I try to access the same with system name or the system dynamic IP when I am inside the intranet then say https://lpt-systemesb:9443/carbon   or  https://175.23.4.56:9443/carbon  then I am not able to access the server.  I didn't see any request going to the server as well.

After trying several blogs and documentations we have to set the  HostName  or the MgtHostName  values.  But still the issue is not resolved.  because the issue is not with this setting.  We don't have to do any changes in the WSO2 related any config files.

The resolution for this issue is DISABLE the firewall or allow the access on the ports. Uncheck the Enable Firewall checkbox. (Means disable the firewall). Now you should be able to access the WSO2 Management console without any issues on the same system during the development.



In the above image the Enable Firewall is checked, to work properly it needs to be unchecked.

Monday, October 30, 2017

How to consume NTLM (MSDynamics) authentication based SOAP services in JAVA using httpclient

I have a need to consume the Webservices published in MSDynamics applications.  This uses the Microsoft specific NTLM based authentication and authorization mechanism.  However to consume the SOAP services I did find any direct solution.  Below is the code that is working.  You have to change the credentials and the input SOAP message formation strings remaining all you can use as it is.

Note: Use the latest httpclient-4.2.3.jar or above ,  commons-codec-1.11  or above.  Few more other jars which you can take from Axis application.

CODE  ( TestCustomerRead.java )
============================

import java.io.InputStream;

import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.NTCredentials;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.client.protocol.HttpClientContext;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;

public class TestCustomerRead {

static String HOST  = "120.142.157.189";
static int    PORT  = 81;
static String USER  = "yourusername";
static String PWD   = "slf#pwd";
static String DOMAIN    = "mcpdl";
static String PROTOCOL  = "http";
static String WSDL_PATH = "/MicrosoftDynamicsAXAif60/AXCustomerService/xppservice.svc?wsdl";
static String SERVICE_ENDPOINT = "/MicrosoftDynamicsAXAif60/AXCustomerService/xppservice.svc";

// soap action you can find in the WSDL at the action attribute of the operation you want to consume //
static String SOAP_ACTION    = "http://schemas.microsoft.com/dynamics/2008/01/services/CustomerService/read";

public static void main(String[] args) {

try {
CloseableHttpClient httpclient = HttpClientBuilder.create().build();
BasicCredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(AuthScope.ANY, new NTCredentials(USER, PWD, HOST, DOMAIN));
HttpHost target = new HttpHost(HOST, PORT , PROTOCOL);

HttpClientContext context = HttpClientContext.create();
context.setCredentialsProvider(credsProvider);

System.out.println("authenticated started");

// Execute a cheap method first. This will trigger NTLM
// authentication  (optional )
HttpGet httpget = new HttpGet( WSDL_PATH );
CloseableHttpResponse response1 = httpclient.execute(target,
httpget, context);
try {
HttpEntity entity1 = response1.getEntity();
System.out.println("=====GET=======>>>>" + response1.toString());
} finally {
response1.close();
}

// Execute an expensive method next reusing the same context (and
// connection)
HttpPost httppost = new HttpPost( SERVICE_ENDPOINT );
httppost.setHeader("SOAPAction",SOAP_ACTION );
httppost.setHeader("Content-Type", "text/xml; charset=utf-8");
StringEntity stringEntity = new StringEntity(getReadRequestSOAP().toString(), "UTF-8");
stringEntity.setChunked(true);
httppost.setEntity(stringEntity);

CloseableHttpResponse response2 = httpclient.execute(target, httppost, context);
try {
HttpEntity entity2 = response2.getEntity();

if(response2.getStatusLine().getStatusCode()== 200){
System.out.println("=====POST=======>>>>HTTP Response Status :"
+ response2.getStatusLine().toString());

System.out.println("RESPONSE MESSAGE IS \n ===================="  );
InputStream in = entity2.getContent();
String body = IOUtils.toString(in, "UTF-8");
System.out.println(body);
System.out.println("\n ===================="  );

}else{
System.out.println("AUTHENTICATION ERROR WITH CODE " + response2.getStatusLine().toString());
}

} catch (Exception ex) {
ex.printStackTrace();
} finally {
response2.close();
System.out
.println("COMPLETED THE REQUEST/RESONSE.");
}

} catch (Exception ex) {
ex.printStackTrace();
}
}

  // replace the SOAP message with your request messages.
// change the the input values as per your request data

private static String getReadRequestSOAP() {
// Below just form the complete SOAP message as a string
String statusRequest = " "
+ "    "
+ "         "
+ "               mcpl"
+ "       
" + "   
" + "    "
+ "          "
+ "              "
+ "              "
+ "                "
+ "                      "
+ "                           AccountNum "
+ "                           C-1008 "
+ "                     
" + "               
" + "             
" + "             
" + "               
" + "             
" + "         
"; return statusRequest;
}

}

=====================END =============
References:

http://hc.apache.org/httpcomponents-client-ga/

https://hc.apache.org/httpcomponents-client-ga/tutorial/html/authentication.html

http://hc.apache.org/httpcomponents-client-4.5.x/ntlm.html


https://www.mkyong.com/java/apache-httpclient-examples/

https://rathinasaba.wordpress.com/2013/02/01/call-webservice-wsdl-based-using-apache-httpconnection/

https://stackoverflow.com/questions/12561503/how-to-call-a-soap-webservice-with-a-simple-string-xml-in-string-format 

Tuesday, August 29, 2017

SOA 11g Transaction timing configuration

Reference taken from other blog. at ( http://soadiscovery.blogspot.in/2011/04/soa-11g-configuring-transaction-timeout.html )

We have set our environment with below values and worked fine.

The gist of the blog the following value should be set (SyncMaxWaitTime < BPEL EJB's transaction timeout < Global Transaction)

SyncMaxWaitTime à300

All the EJB Beans values à 1200

JTA (Global Transaction Timeout)à1800


================================================================

SOA 11g : Configuring Transaction timeout in BPEL
Transaction timeout can be configured for BPEL in 11g using the below properties.
1. SyncMaxWaitTime
Maximum time BPEL process wait before returning result to client(or another Sync process)
To set this property
a. Login to EM console
b. Expand SOA and right click on “soa-infra”
c. From context menu, select SOA Administration –> BPEL properties
d. Click on “More BPEL Configuration properties…”
 SyncMaxWaitTime
 2.Transaction Time-out for BPEL EJB’s
The following EJB’s need to be configured for transaction time outs.
  • BPELActivityManagerBean
  • BPELDeliveryBean
  • BPELDispatcherBean
  • BPELEngineBean
  • BPELFinderBean
  • BPELInstanceManagerBean
  • BPELProcessManagerBean
  • BPELSensorValuesBean
  • BPELServerManagerBean
To change time out for these beans ,
a. Login to Administration Console
b. Click on Deployments
c. Expand soa-infra –> EJB’s
Transaction-EJB1of3 Transaction-EJB2of3
d. Click on EJB for which you want to change the timeout
e. Click on Configuration
f. Change value for field “Transacion Timeout”
g. Click Save.
Transaction-EJB3of3
 3. Global Transaction Timeout
This property is timeout in seconds for active transactions. After this time, if the transaction is still “Active”, then it gets rolled back.
To change this value
a. Login to Administration Console
b. Expand “Services” –> Click on “JTA”
c. Click on “JTA” tab if it’s on a different tab
d. Change value for field “Timeout Seconds”
GlobalTransactionTimeout
Very Important :
SyncMaxWaitTime < BPEL EJB's transaction timeout <  Global Transaction Timeout

Monday, May 22, 2017

SOA 11g BPEL process or the Sub Process goes in recovery mode resolution

In the SOA if a BPEL process is always going in recovery mode then the main problem would be one of the end points inside the BPEL process consuming services is not reachable.

Check if your deployment configuration file has the right targets when moving from one environment to another environment.

Check if the external service that is pointing is up and running.