Thursday, August 20, 2015

Why is Messaging considered superior to Shared DB? Messaging vs Shared DB?(102/285 tech notesfor 2015)

DB is good solution for a low traffic application:
If you are building a simple application with low traffic, there is
something to be said about keeping another component out of your system. It
is very likely not using a message bus is the right answer for you.

However, I would suggest building your system in a way you could swap out
the database based queue system for middleware solution. I agree with the
article. A database is not the right tool for queue based system, but it
may be good enough for you.

Advantages of Queue based systems:
Queue based system like RabbitMq are built around massive scale on moderate
hardware. Their architecture is able to achieve this by avoiding processes
which make ACID compliant database system slow by their nature. Since a

Message bus -
only needs to ensure a message is stored and successfully processed,
it doesn’t need to bother with locking and writing transaction logs.

Both of these concepts are absolutely required for an ACID system but are
often a cause of contention.

Issue with DB:
Performance wise it comes down to, you have a SQL table. Lots of reads and
lots of writes. Both require some sort of locking to update rows, pages and
indexes. Your polling mechanisms is constantly locking an index to do look
ups on it. This prevents writes from happening, at best they are queued.
The code doing the processing is also locking to update the status on the
queue as they complete or fail. Yes, you can do query optimization after
optimization to get this to work, or you can use a system specifically
designed for the work load you are asking.

A RabbitMq eats up this type of workload without even breaking a sweat.
On top of that you get to save your database from the workload giving it
more room to scale doing other things.

Polling:
Another thing to consider is most queue system typically do not use a
polling technique (some allow for HTTP, but recommend to avoid using for
the receive side). RabbitMq uses network protocols specifically designed
for message buses such as AMPQ.

References:

http://mikehadlow.blogspot.fr/2012/04/database-as-queue-anti-pattern.html
brianfeucht in stackoverflow -
http://programmers.stackexchange.com/questions/231410/why-database-as-queue-so-bad

Why is Messaging considered superior to Shared DB (102/285 technotes for 2015)

DB is good solution for a low traffic application:
If you are building a simple application with low traffic, there is something to be said about keeping another component out of your system. It is very likely not using a message bus is the right answer for you. 

Friday, August 14, 2015

How To Set Up GUI On Amazon EC2 Ubuntu server?(101/285 technotes for 2015).

This was published in http://bit.ly/1LaP9tT. Based on the comments and minor changes (maked in bold) the below worked for me.

-------------------------------

This can be done. Following are the steps to setup the GUI

* Create new user with password login

How To Set Up GUI On Amazon EC2 Ubuntu server?(101/285 technotes for 2015).

This was published in http://bit.ly/1LaP9tT. Based on the comments and minor changes (maked in bold) the below worked for me.


This can be done. Following are the steps to setup the GUI

* Create new user with password login

sudo useradd -m awsgui
sudo passwd awsgui
sudo usermod -aG admin awsgui
su - awsgui

sudo vim /etc/ssh/sshd_config # edit line "PasswordAuthentication" to yes

sudo /etc/init.d/ssh restart

* Setting up ui based ubuntu machine on AWS.

* In security group open port 5901. Then ssh to the server instance. Run following commands to install ui and vnc server:

sudo apt-get update
sudo apt-get install ubuntu-desktop
sudo apt-get install vnc4server

* Then run following commands and enter the login password for vnc connection:

vncserver

vncserver -kill :1

vim awsgui/.vnc/xstartup

* replace the text with the text below (make sure u have a copy)

#!/bin/sh
def
export XKL_XMODMAP_DISABLE=1
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS

gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &

* When you’re done, hit Ctrl + C on the keyboard, type :wq and hit Enter.

* Restart the server

* Then start vnc server again.

vncserver

In the vnc client, give public DNS plus “:1” (e.g. www.example.com:1) or private ip address. Enter the vnc login password. Make sure to use a normal connection. Don’t use the key files.

Thursday, August 6, 2015

ParseMFCFile.java (101/285 technotes for 2015)

The sample output shows that the MFC file had 2 operations and the various types of artificats used and the number of times they were used.

name=“callAddressValidation”
Req:{Trace=5, Input=1, XSLTransformation=3, BOMapper=3, Stop=3, InputFault=1, ServiceInvoke=3, InputResponse=1, CustomMediation=5}
Err:{Trace=1, XSLTransformation=1, BOMapper=1, Stop=1, InputFault=1, ServiceInvoke=1, ErrorInput=1, InputResponse=1, CustomMediation=1}
name=“findStateCountyCity”
Req:{Trace=3, Input=1, BOMapper=2, XSLTransformation=2, Stop=1, InputFault=1, ServiceInvoke=1, Callout=1, InputResponse=1, CustomMediation=4}
Res:{InputFault=1, InputResponse=1}
Err:{Trace=1, XSLTransformation=1, BOMapper=1, Stop=1, InputFault=1, ServiceInvoke=1, ErrorInput=1, InputResponse=1, CustomMediation=1}

ParseMFCFile.java (101/285 technotes for 2015)

Friday, July 31, 2015

The declared package does not match the expected package “”? (100/285 technotes for 2015)

The issue description:

The declared package “org.jboss.as.quickstarts.helloworld” does not match the expected package “main.java.org.jboss.as.quickstarts.helloworld” HelloService.java /jboss-helloworld/src/main/java/org/jboss/as/quickstarts/helloworld line 17 Java Problem

image




Resolution:


To resolve this issue.

Right click on the the project → Properties → Java Build Path → Source

Click on the project →


image


Add a new Source folder src/main/java


image


Remove the old src folder


image

Thursday, July 30, 2015

What is JBOSS EAP? (99/285 technotes for 2015)



JBoss Enterprise Application Platform is a rigorously tested, stable, supported platform for developing and deploying mission critical Java applications and services. 

It integrates code from the 

JBoss EAP is certified on 17 operating systems, 5 Database Management systems and JVM combinations. It also integrates with 


Advantages:

  • 0 licence fee, significantly lower Total Cost of Ownership (TCO)- upto 70% savings.
  • avoid vendor lock in ?????


  • With 24x7x365 support with 1 hour SLA you are guaranteed support when you need it.

Monday, July 27, 2015

Useful Java syntaxes.

org.apache.commons.lang3.Validate

This class assists in validating arguments. The validation methods are based along the following principles:  

———————————————————————————

Wednesday, July 22, 2015

What is the difference between JAXB and JAXP? (98/285 technotes for 2015)

JAXP (Java API for XML Processing) is a rather outdated umbrella term covering the various low-level XML APIs in JavaSE, such as DOM, SAX and StAX.

  1. Create a SAX Parser or DOM Parser and then PArse the data, if we use DOM, it may be memory intensive if the document is too big. Suppose if we use SAX parser, we need to identify the beginning of the document. When it encounters something significant (in SAX terms, an “event”) such as the start of an XML tag, or the text inside of a tag, it makes that data available to the calling application.
  2. Then Create a content handler that defines the methods to be notified by the parser when it encounters an event. These methods, known as callback methods, take the appropriate action on the data they receive.

JAXB (Java Architecture for XML Binding) is a specific API (the stuff under javax.xml.bind) that uses annotations to bind XML documents to a java object model.

  1. Bind the schema for the XML document.
  2. Unmarshal the document into Java content objects. The Java content objects represent the content and organization of the XML document, and are directly available to your program. After unmarshalling, your program can access and display the data in the XML document simply by accessing the data in the Java content objects and then displaying it. There is no need to create and use a parser and no need to write a content handler with callback methods. What this means is that developers can access and process XML data without having to know XML or XML processing

References: 

http://stackoverflow.com/questions/2801502/what-is-the-difference-between-jaxp-and-jaxb

Increase Heap Memory in Websphere(97/285 technotes fpr 2015)

Method 1: Using the administrative console

Open the administrative console.

Navigate to Servers > Server Types > WebSphere application servers > <servername>

Navigate to Server Infrastructure > Java and Process Management > Process Definition

Navigate to Additional Properties > Java Virtual Machine > General Properties

Define the values (in MB) for ‘Maximum heap size’ and/or ‘Initial heap size’.

Restart the server.

Note: If the heap size is already low, the administrative console might not open. In such cases, use some other method to configure the heap size.

Method 2: By editing the configuration files

This method should be used with caution.

Search for a file named server.xml in your WebSphere installation.

Generally, the location of this file is as follows:

<profilehome>/config/cells/<cellname>/nodes/<nodename>/servers/<servername>/server.xml

Select the server.xml specific to your server and edit it to add/modify/delete the attributes @initialHeapSize and @maximumHeapSize of the element <jvmEntries> The value of these attributes is the heap size in MB.

For example:

<jvmEntries ... initialHeapSize="2048" maximumHeapSize="3072" ...>
...
</jvmEntries>

Restart the server after saving the changes to server.xml.


References:

https://blakboard.wordpress.com/2013/05/15/how-to-configure-heap-size-for-websphere-application-server/