tag:blogger.com,1999:blog-84624052626180858642024-03-05T13:20:44.596-08:00Java Programming NotesJava, Oracle, DB2 and Java related technology blogSanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.comBlogger59125tag:blogger.com,1999:blog-8462405262618085864.post-18917761994913459922021-01-10T02:54:00.004-08:002021-01-10T02:56:18.999-08:00TOGAF 9.2 - STUDY [ The Open Group Architecture Framework ] - Chap 01 - Introduction<p><b><u>100 Feet View of TOGAF</u></b></p><p><b><u> What is Enterprise?</u></b></p><p>Collection of Organization that has common set of Goals.</p><p>Enterprise has</p><p></p><ul style="text-align: left;"><li>People - organized by company, business division or project team.</li><li><span>Platform - building, infrastructure, equipments and technology.</span></li><li><span>Purpose - to run a business - which good be a NGO or private establishment</span></li></ul>And Enterprise can be a company, a business division in an company or a project being executed in a company.<p></p><div>Enterprise Architecture bridges the gap between Business Strategy and IT Infrastructure and needs.<div class="separator" style="clear: both; text-align: left;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUO8ZQnPP23b_knEOM-M7Ta3i4Tz_BHH6wpz6SIJqlkxaLhvqIkGHGZdw8NdG5yq_0wFyEy8qU-F9IoIne8zO68u7xauLmewoWPSf0znVSKQsLJrfLFGlbYfrA7-z4n7W5gTFPe8O_tYc/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="349" data-original-width="542" height="206" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUO8ZQnPP23b_knEOM-M7Ta3i4Tz_BHH6wpz6SIJqlkxaLhvqIkGHGZdw8NdG5yq_0wFyEy8qU-F9IoIne8zO68u7xauLmewoWPSf0znVSKQsLJrfLFGlbYfrA7-z4n7W5gTFPe8O_tYc/" width="320" /></a></div><div class="separator" style="clear: both; text-align: left;">Enterprise Technology Architecture is not Enterprise Architecture, it is only one of the part of Enterprise Architecture. Enterprise Architecture is not only all about Technology, technology is just the part of Enterprise Architecture. Actually, Enterprise Architecture is driven by four pieces on the left side</div><div class="separator" style="clear: both; text-align: left;"><div class="separator" style="clear: both; text-align: left;"><div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirm5Fq8x4YXbM_SJvWnDOHLdo9OR4gQ5288BLEzVZxiEoBC4LT22kC_viU0dbs1BOUsxm7Nuk3mDNFDWLtHW-FKafXgm80HhY0ZdaQnhO56i2mcvDAyylCt8yxNQXZ6IQ8J0W3vT7XAsg/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="583" data-original-width="1126" height="166" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEirm5Fq8x4YXbM_SJvWnDOHLdo9OR4gQ5288BLEzVZxiEoBC4LT22kC_viU0dbs1BOUsxm7Nuk3mDNFDWLtHW-FKafXgm80HhY0ZdaQnhO56i2mcvDAyylCt8yxNQXZ6IQ8J0W3vT7XAsg/" width="320" /></a></div><br /><div style="text-align: left;">Enterprise Architecture has to do less with Technology and more with methodology. Flow of Enterprise Architecture is in direction of Strategy -> Planning -> Execution and Enterprise Architecture is all about planning and design and there is Feedback loop in reverse direction - in all way up, the design implemented has to be communicated to the rest of the Organization and for that Feedback loop is used. By Feedback loop, Organization will understand, how the business will benefit from the new implemented Enterprise Architecture.</div><div style="text-align: left;"><br /></div><div style="text-align: left;"><b><u>Change is inevitable :</u></b> One of the primary goal of Enterprise Architecture is to facilitate change. Enterprise Architecture help organization to deal with change / transformation at organization level for example, merger and acquisitions, which makes new business to try to fit in existing technology or sometimes existing business tries to adapt to new technology capabilities. So, enterprise architecture helps you to deal with the change in business and IT Space.</div><div style="text-align: left;"><br /></div><div style="text-align: left;">TOGAF has now become the mainstream Architecture Framework. The open group is a technology neutral industry association is having over 450 member organizations. TOGAF is the most popular and widely implemented framework across the world and is utilized by business operating in a broad range of sector including healthcare, academia, aerospace, media and so on. </div><div style="text-align: left;"><br /></div><div style="text-align: left;"><b><u>How does TOGAF Work ? </u></b></div></div><div class="separator" style="clear: both; text-align: right;"> </div><div class="separator" style="clear: both; text-align: left;">TOGAF is collection of Building Blocks, Methods and Deliverables. ADM consumes building blocks from Continuum and creates Architecture models to be used by organization for satisfying business needs. <div class="separator" style="clear: both; text-align: center;"><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHcBCdf0DAt0CuRT55eut9he3puvu5WlQA_l_06WLP7Vti08wrAIiSMrmR-YGS8C0OnqB26mbP9WWCA_JUAZKOjhbkn4XzUP7fHif-3NLfR04287R62ctKm7tDlci4PXh4hnSQMSO824E/" style="margin-left: 1em; margin-right: 1em;"><img alt="" data-original-height="626" data-original-width="736" height="240" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhHcBCdf0DAt0CuRT55eut9he3puvu5WlQA_l_06WLP7Vti08wrAIiSMrmR-YGS8C0OnqB26mbP9WWCA_JUAZKOjhbkn4XzUP7fHif-3NLfR04287R62ctKm7tDlci4PXh4hnSQMSO824E/" width="282" /></a></div><br /></div><br /></div><div class="separator" style="clear: both; text-align: right;"> </div><br /><br /><br /></div><br /><br /></div><br /></div>Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com1tag:blogger.com,1999:blog-8462405262618085864.post-68027879660745700062017-12-06T06:22:00.000-08:002017-12-06T06:22:14.356-08:00Weblogic - Server Creation - Issues<u>Datasource creation using python script. </u><br />
<br />
Python Script was failing after creating Datasource.<br />
From UI Admin Console, if I try to activate changes done by Python Script, datasource was not getting connected with DB.<br />
<br />
I was getting -<br />
<h1 class="entry-title" style="background: 0px 0px rgb(255, 255, 255); border: 0px; box-sizing: border-box; color: #333333; font-family: Lato, Helvetica, Arial, Lucida, sans-serif; font-size: 28px; font-weight: 500; line-height: 1em; margin: 0px; outline: 0px; padding: 0px 0px 10px; text-size-adjust: 100%; vertical-align: baseline;">
ORA-01017: Invalid Username/Password; Logon Denied</h1>
<div>
Trust me- user name and password was correct. </div>
<div>
<br /></div>
<div>
But both were entered in UPPER case in script. Although Username/Password as given in upper case in Schema as well. </div>
<div>
<br /></div>
<div>
So what is the problem.</div>
<div>
<br /></div>
<div>
I guess, Weblogic encrypts password while creating Datasources. But while connecting to Db its decrypting in lower case and due to that it was not connecting with DB.</div>
<div>
<br /></div>
<div>
But how come oracle is not connecting with different case password, because its case in-sensitive. This is not correct since last version of Oracle.</div>
<div>
<br /></div>
<div>
We need to make below parameter false and restart DB.</div>
<div>
SEC_CASE_SENSITIVE_LOGON</div>
<div>
<br /></div>
<div>
After making - SEC_CASE_SENSITIVE_LOGON to false, datasource started connecting to DB. </div>
<div>
<br /></div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-2898458400970974012017-05-15T03:29:00.000-07:002017-05-15T03:29:04.750-07:00Java - Heap Size - Configuration Options<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b>Java Heap Size - </b>Place to
store objects created by your Java application, this is where Garbage
Collection takes place, the memory used by your Java application.<b><o:p></o:p></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-Xms<size> - Set initial Java heap size</size></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-Xmx<size> - Set maximum Java heap size</size></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
$ java -Xms512m -Xmx1024m JavaApp</div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b>Young Generation - </b>Consist of Eden, S0
and S1 Space</div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman";">-Xmn<size> </size></span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">- Set the size of young generation.</span><span style="color: #333333; font-family: "Helvetica","sans-serif"; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-bidi-font-weight: bold; mso-fareast-font-family: "Times New Roman";">$</span><span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">java -Xmn512m MyJavaProgram</span><span style="color: #333333; font-family: "Helvetica","sans-serif"; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;">
<span style="color: #333333; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">$java -Xmn1g MyJavaProgram </span><span style="color: #333333; font-family: "Helvetica","sans-serif"; font-size: 10.5pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><br /></b></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b>Some more switches for Young generation
memory configuration are:</b></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
</div>
<ol>
<li><span style="font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;"> </span><span style="background: white; color: #333333; font-size: 10pt; text-indent: -0.25in;">-XX:NewSize<span class="apple-converted-space"> </span></span><span style="background: white; color: #333333; font-size: 10pt; text-indent: -0.25in;">-<span class="apple-converted-space"> </span>Set the minimum
size of young generation which is allocated at initialization of JVM.</span></li>
<li><span style="font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;"> </span><span style="background: white; color: #333333; font-size: 10pt; text-indent: -0.25in;">-XX:MaxNewSize</span><span class="apple-converted-space" style="text-indent: -0.25in;"><span style="background: white; color: #333333; font-size: 10.0pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;"> </span><span style="background: white; color: #333333; font-size: 10.0pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin;">- Set the maximum size of young generation that
JVM can use.</span></span></li>
<li><span style="font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;"> </span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #333333; font-size: 10pt; line-height: 115%; text-align: justify; text-indent: -0.25in;">-XX:SurvivorRatio<b> - </b></span><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; color: #333333; font-size: 10pt; line-height: 115%; text-align: justify; text-indent: -0.25in;">used to tune the size of the survivor spaces</span><span style="background-color: white; text-align: justify; text-indent: -0.25in;">.
For example </span><b style="text-align: justify; text-indent: -0.25in;"><span style="color: #333333; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman";">-XX:SurvivorRatio=6</span></b><span style="color: #333333; font-size: 10pt; line-height: 115%; text-align: justify; text-indent: -0.25in;"> </span><span style="color: #333333; font-size: 10pt; line-height: 115%; text-align: justify; text-indent: -0.25in;">sets the ratio between each
survivor space and eden to be 1:6.In other words, each survivor space will be</span><span style="color: #333333; font-size: 10pt; line-height: 115%; text-align: justify; text-indent: -0.25in;"> </span><b style="text-align: justify; text-indent: -0.25in;"><span style="color: #333333; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman";">one eighth of the young
generation</span></b><b style="text-align: justify; text-indent: -0.25in;"><span style="color: #333333; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Calibri; mso-bidi-font-size: 11.0pt; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman";"> </span></b><span style="color: #333333; font-size: 10pt; line-height: 115%; text-align: justify; text-indent: -0.25in;">(not
one seventh, because there are two survivor spaces).</span></li>
<li><span style="font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;"> </span><span style="color: #333333; font-size: 10pt; text-align: justify; text-indent: -0.25in;">-XX:NewRatio : NewRatio controls the size of young and old generation. For
example<b> </b>-XX:NewRatio=3 means that the ratio between the young and
old/tenured generation is 1:3. In other words, the combined size of the eden
and survivor spaces will be one fourth of the total heap size.</span></li>
</ol>
<!--[if !supportLists]--><o:p></o:p><br />
<div class="MsoListParagraphCxSpLast" style="background: white; line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-align: justify; text-indent: -.25in;">
<span style="color: #333333; font-size: 10.0pt; mso-bidi-font-family: Calibri; mso-bidi-theme-font: minor-latin; mso-fareast-font-family: "Times New Roman";"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b>Perm Gen Size - </b>Place to
store your loaded class definition and metadata.</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
XX:PermSize<size> - Set initial PermGen Size.</size></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-XX:MaxPermSize<size> - Set the maximum PermGen Size.</size></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
$ java -XX:PermSize=64m -XX:MaxPermSize=128m JavaApp</div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0in;">
<b><span style="font-family: "Calibri","sans-serif"; font-size: 11.0pt; mso-ascii-theme-font: minor-latin; mso-bidi-font-family: "Times New Roman"; mso-bidi-theme-font: minor-bidi; mso-fareast-font-family: Calibri; mso-fareast-theme-font: minor-latin; mso-hansi-theme-font: minor-latin;">Note</span></b>: <span style="color: #242729; font-family: "Arial","sans-serif"; font-size: 11.5pt;"><br />
</span><span style="color: #242729; font-family: "Arial","sans-serif"; font-size: 8.0pt;">PermGen space is replaced by MetaSpace in Java 8. The PermSize
and MaxPermSize JVM arguments are ignored and a warning is issued if present at
start-up.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: #242729; font-family: "Arial","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">Most allocations for
the class metadata are now allocated out of native memory. * The classes that
were used to describe class metadata have been removed.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: #242729; font-family: "Arial","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">Main difference
between old PermGen and new MetaSpace is, you don't have to mandatory define
upper limit of memory usage. You can keep MetaSpace space limit unbounded. Thus
when memory usage increases you will not get OutOfMemoryError error. Instead
the reserved native memory is increased to full-fill the increase memory usage.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: #242729; font-family: "Arial","sans-serif"; font-size: 8.0pt; mso-fareast-font-family: "Times New Roman";">You can define the max
limit of space for MetaSpace, and then it will throw OutOfMemoryError :
Metadata space. Thus it is important to define this limit cautiously, so that
we can avoid memory waste.</span><span style="font-size: 8.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b>Java Stack Size -</b>Size of a
Java thread. If a project has a lot of threads processing, try reduce this
stack size to avoid running out of memory.</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
-Xss = set java thread stack size</div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
$ java -Xss512k JavaApp</div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-25389593162492858822017-05-11T00:13:00.000-07:002017-05-11T00:13:14.436-07:00Garbage Collection in Java in easy language<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;">What is <b>Throughput </b>in
gc(garbage collection) in java ?</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .75in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l19 level1 lfo10; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">In short, Throughput is
the <b>time not spent </b>in garbage collection (GC) ( in percent).</span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .75in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l19 level1 lfo10; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Throughput focuses on
maximizing the amount of work by an application in a specific period of time.
Examples of how throughput might be measured include ></span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: 3.0pt; margin-left: 1.25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l19 level2 lfo10; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10pt;">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">The number of
transactions completed in a given time.<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: 3.0pt; margin-left: 1.25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l19 level2 lfo10; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10pt;">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">The number of jobs that
a batch program can complete in an hour.<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l19 level2 lfo10; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;"> </span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">The number of database queries that can be
completed in an hour.</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;">What are <b>pauses </b>in
gc(garbage collection) in java ?</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraph" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l4 level1 lfo9; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Pauses is applications
pauses i.e. when <b>application doesn’t gives any response</b> because of
garbage collection (GC).</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: blue; font-family: "Arial","sans-serif"; mso-fareast-font-family: "Times New Roman";">JVM Heap memory (Hotspot heap structure) with
diagram in java:</span></b><span style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOsnHlM5ZOAKHHOUfSSWKHuvR21PnP6nX8pm6yPYRRfFpl8WNi_KqRG6kAxI7aw9XFitMO22fNcd5LaU_NhNJ7yH3CjuXhzQ9hng0GQshgj8l33SNHpZe4Va5G8nv0Iz6aBM4_MUNia2U/s1600/hotspot.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="243" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOsnHlM5ZOAKHHOUfSSWKHuvR21PnP6nX8pm6yPYRRfFpl8WNi_KqRG6kAxI7aw9XFitMO22fNcd5LaU_NhNJ7yH3CjuXhzQ9hng0GQshgj8l33SNHpZe4Va5G8nv0Iz6aBM4_MUNia2U/s640/hotspot.jpg" width="640" /></a></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: blue; font-family: "Arial","sans-serif"; mso-fareast-font-family: "Times New Roman";">JVM Heap memory (Hotspot heap structure) in
java consists of following elements></span></b><span style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: yellow; line-height: normal; margin-bottom: 3.0pt; margin-left: .25in; margin-right: 0in; margin-top: 0in; mso-list: l5 level1 lfo1; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">1)<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: Arial, sans-serif; font-size: 10pt;">Young </span></b><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: Arial, sans-serif; font-size: 10pt;">Generation</span><span style="font-family: Arial, sans-serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: yellow; line-height: normal; margin-bottom: 3.0pt; margin-left: .75in; margin-right: 0in; margin-top: 0in; mso-list: l5 level3 lfo1; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">i)<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: Arial, sans-serif; font-size: 10pt;">Eden</span></b><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: Arial, sans-serif; font-size: 10pt;">,</span><span style="font-family: Arial, sans-serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: yellow; line-height: normal; margin-bottom: 3.0pt; margin-left: .75in; margin-right: 0in; margin-top: 0in; mso-list: l5 level3 lfo1; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">ii)<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: Arial, sans-serif; font-size: 10pt;">S0 (Survivor </span></b><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: Arial, sans-serif; font-size: 10pt;">space 0<b>)</b></span><span style="font-family: Arial, sans-serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: yellow; line-height: normal; margin-bottom: 3.0pt; margin-left: .75in; margin-right: 0in; margin-top: 0in; mso-list: l5 level3 lfo1; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">iii)<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: Arial, sans-serif; font-size: 10pt;">S1 (Survivor </span></b><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: Arial, sans-serif; font-size: 10pt;">space 1<b>)</b></span><span style="font-family: Arial, sans-serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: lime; line-height: normal; margin-bottom: 3.0pt; margin-left: .25in; margin-right: 0in; margin-top: 0in; mso-list: l5 level1 lfo1; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">2)<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: Arial, sans-serif; font-size: 10pt;">Old </span></b><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: Arial, sans-serif; font-size: 10pt;">Generation
(Tenured)</span><span style="font-family: Arial, sans-serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #3C78D8; line-height: normal; margin-bottom: 3.0pt; margin-left: .25in; margin-right: 0in; margin-top: 0in; mso-list: l5 level1 lfo1; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">3)<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: Arial, sans-serif; font-size: 10pt;">Permanent </span></b><span style="background-attachment: initial; background-clip: initial; background-image: initial; background-origin: initial; background-position: initial; background-repeat: initial; background-size: initial; font-family: Arial, sans-serif; font-size: 10pt;">Generation.</span><span style="font-family: Arial, sans-serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;">So, JVM Heap memory
(Hotspot heap structure) is divided into three parts <b>Young </b>Generation, <b>Old
</b>Generation (tenured) and <b>Permanent </b>Generation.</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Young </span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Generation is further divided into <b>Eden</b>, <b>S0
(Survivor </b>space 0<b>) </b>and <b>S1 (Survivor </b>space 1<b>).</b></span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Times New Roman", serif; font-size: 10pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="color: blue; font-family: "Arial","sans-serif";">GARBAGE
COLLECTION </span></b><span style="color: blue; font-family: "Arial","sans-serif";">(<b>Minor
and major</b> garbage collection) in JVM Heap memory (i.e. in young, old and
permanent generation) <o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="background: yellow; font-family: Arial, sans-serif;">3.1) Young </span></b><span style="background: yellow; font-family: Arial, sans-serif;">Generation</span><span style="background: rgb(204, 204, 204); font-family: Arial, sans-serif;"> (<b><i>Minor
garbage collection </i></b><i>occurs in </i><b>Young Generation)</b></span><span style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l6 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">New objects are
allocated in Young generation.</span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l6 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><i><span style="font-family: Arial, sans-serif; font-size: 10pt;">Minor
garbage collection </span></i></b><i><span style="font-family: Arial, sans-serif; font-size: 10pt;">occurs
in </span></i><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Young Generation.</span></b><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;">When <b><i>minor garbage
collection?</i></b></span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l17 level1 lfo3; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">When the young
generation fills up, this causes a <b><i>minor garbage collection</i></b>.</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l17 level1 lfo3; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">All the unreferenced
(dead) objects are cleaned up from young generation.</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;">When objects are <b>moved
from young to old generation</b> in JVM<i> heap<b>?</b></i></span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraph" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l22 level1 lfo4; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Some of the objects
which aren't cleaned up <b>survive in young generation and gets aged</b>.
Eventually such objects are <b>moved from young to old generation</b>.</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;">What is <b>Stop the
World Event?</b></span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l22 level1 lfo4; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Minor garbage
collections are called <b>Stop the World</b> events. </span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l22 level1 lfo4; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">All
the non-daemon threads running in application are stopped during minor garbage
collections</span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;"> (i.e. the application
stops for while)<b>. </b></span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l22 level1 lfo4; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><a href="http://www.javamadesoeasy.com/2015/03/daemon-threads-12-salient-features-of.html"><b><span style="color: #1155cc; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">Daemon threads</span></b></a><b><span style="font-family: Arial, sans-serif; font-size: 10pt;"> performs minor garbage collection</span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;">. (Daemon threads are low </span><a href="http://www.javamadesoeasy.com/2015/03/thread-priorities-setpriority-and.html"><span style="color: #1155cc; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">priority threads</span></a><span style="font-family: Arial, sans-serif; font-size: 10pt;"> which runs intermittently in background for
doing garbage collection). </span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;">Division of Young
Generation<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-align: justify;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;">a) <b>Eden</b> b) <b>S0 (Survivor </b>space 0<b>) </b>c) <b>S1 (Survivor </b>space 1<b>)</b><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Times New Roman", serif;"><br />
</span><b><span style="background: lime; font-family: Arial, sans-serif;">3.2) Old </span></b><span style="background: lime; font-family: Arial, sans-serif;">Generation or (<b>tenured</b> generation) -</span><span style="background: rgb(204, 204, 204); font-family: Arial, sans-serif;"> (<b><i>Major
garbage collection </i></b><i>occurs in </i><b>Old Generation</b>)</span><span style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 38.1pt; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l1 level1 lfo5; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">The <b>Old Generation</b>
is used for storing the long surviving aged objects (Some of the objects which
aren't cleaned up <b>survive in young generation and gets aged</b>.
Eventually such objects are <b>moved from young to old generation</b>).</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 38.1pt; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l1 level1 lfo5; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><i><span style="font-family: Arial, sans-serif; font-size: 10pt;">Major
garbage collection </span></i></b><i><span style="font-family: Arial, sans-serif; font-size: 10pt;">occurs
in </span></i><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Old Generation.</span></b><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;">At what time (or what
age) objects are <b>moved from young to old generation</b> in JVM<i> heap<b>?</b></i></span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraph" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l15 level1 lfo6; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">There is some threshold
set for young generation object and when that age is met, the object gets moved
to the old generation during gc(garbage collection) in java. </span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;">What is <b>major garbage
collection</b> in java?</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l15 level1 lfo6; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">When
the old generation fills up</span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;">,
this causes a <b><i>major garbage collection</i></b>. Objects are cleaned up
from old generation.</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l15 level1 lfo6; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Major collection is much
slower than minor garbage collection in jvm heap <b>because it involves all
live objects</b>. </span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;">Major garbage collection
are <b>Stop the World Event</b> in java<b>?</b></span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l20 level1 lfo7; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Major garbage
collections are also called Stop the World events. </span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l20 level1 lfo7; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">All the non-daemon
threads running in application are stopped during major garbage collections. </span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l20 level1 lfo7; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><a href="http://www.javamadesoeasy.com/2015/03/daemon-threads-12-salient-features-of.html"><span style="color: #1155cc; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">Daemon threads</span></a><span style="font-family: Arial, sans-serif; font-size: 10pt;"> performs major garbage collection.</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Times New Roman", serif; font-size: 10pt;"><br />
</span><span style="font-family: Arial, sans-serif; font-size: 10pt;">Major gc(garbage
collections) <b>in responsive applications</b> in java?</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraph" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l24 level1 lfo8; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Major garbage
collections should be minimized for responsive applications because
applications must not be stopped for long.</span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Optimizing </span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Major gc(garbage collections) in responsive
applications in java?</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Selection of appropriate
garbage collector for the old generation</span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;"> space affects the length of the “Stop the World” event for a
major garbage collection. </span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Times New Roman", serif; font-size: 10pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="background: fuchsia; font-family: Arial, sans-serif; font-size: 10pt;">3.3)
P</span></b><b><span style="background: fuchsia; font-family: Arial, sans-serif;">ermanent </span></b><span style="background: fuchsia; font-family: Arial, sans-serif;">Generation or (Permgen) - </span><span style="font-family: Arial, sans-serif;">(<b><span style="background: #D9D9D9;">full garbage collection</span></b><span style="background: #D9D9D9;"> occurs in permanent generation in java</span>).</span><span style="font-family: "Times New Roman","serif"; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l24 level1 lfo8; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Permanent generation
Space contains metadata required by JVM to describe the classes and methods
used in the application.</span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l24 level1 lfo8; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">The permanent generation
is included in a <b>full garbage collection</b> in java.</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l24 level1 lfo8; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">The permanent generation
space is populated at runtime by JVM based on classes in use in the
application. </span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l24 level1 lfo8; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">The permanent generation
space also contains <b>Java SE library classes and methods</b> in java.</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l24 level1 lfo8; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">JVM garbage collects
those classes when classes are no longer required and space may be needed for
other classes in java.</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="color: blue; font-family: "Arial","sans-serif";">Configuring
VM</span></b><span style="color: blue; font-family: "Arial","sans-serif";"> (JVM)<b>
PARAMETERS in</b> JVM Heap memory<o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: blue; font-family: "Arial","sans-serif";">Total
Heap Size Configuration<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;">Providing minimum heap size -Xms</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;"> is minimum heap size
which is allocated at initialization of JVM.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;">Example1</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;"> Set the minimum heap size of JVM to
512 megabytes.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;">java
-Xms512m MyJavaProgram<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;">Example2</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;"> Set the minimum heap size of JVM to 1
gigabyte.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;">java
-Xms1g MyJavaProgram<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;">Providing maximum heap size -Xmx </span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;">is the maximum heap
size that JVM can use. <o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;">Example1</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;"> Set the maximum heap size of JVM to
512 megabytes.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;">java
-Xmx512m MyJavaProgram <o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;">Example2</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;"> Set the maximum heap size of JVM to 1
gigabyte.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt;">java
-Xmx1g MyJavaProgram <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #4f81bd; font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%; mso-themecolor: accent1;">Young
Generation(VM PARAMETERS for Young Generation) <o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">a)
Eden,<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">b)
S0 (Survivor space 0)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">c)
S1 (Survivor space 1)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-Xmn :</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> -Xmn sets the size
of young generation. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example1</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> - java
-Xmn512m MyJavaProgram <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example2</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> - java
-Xmn1g MyJavaProgram <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:NewRatio :</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">
NewRatio controls the size of young generation. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> - <b>-XX:NewRatio=3</b>
means that the ratio between the young and old/tenured generation is 1:3. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">In
other words, the combined size of the eden and survivor spaces will be <b>one fourth </b>of the <b>total heap size</b>.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:NewSize </span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-
NewSize is minimum size of young generation which is allocated at
initialization of JVM. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Note
: If you have specified <b>-XX:NewRatio</b>
than minimum size of the young generation is allocated automatically at
initialization of JVM. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:MaxNewSize</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> -
MaxNewSize is the maximum size of young generation that JVM can use. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:SurvivorRatio :</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> (for survivor space) <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">SurvivorRatio
can be used to tune the size of the survivor spaces, but this is often not as
important for performance. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example:
<b> -XX:SurvivorRatio=6</b> sets the ratio between
each survivor space and eden to be 1:6. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">In
other words, each survivor space will be <b>one
eighth of the young generation </b>(not one seventh, because there are two
survivor spaces).<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #4f81bd; font-family: "Arial","sans-serif"; mso-themecolor: accent1;">Old Generation (tenured) - (VM PARAMETERS
for Old Generation) <o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:NewRatio
: NewRatio controls the size of young and old generation. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> of
using -XX:NewRatio: -XX:NewRatio=3 means that the ratio between the young and
old/tenured generation is 1:3. In other words, the combined size of the eden
and survivor spaces will be one fourth of the total heap size.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #4f81bd; font-family: "Arial","sans-serif"; mso-themecolor: accent1;">Permanent Generation (VM PARAMETERS for
Permanent Generation) <o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:PermSize</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">:
It’s is initial value of Permanent Space which is allocated at startup of JVM.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example1</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> :
Set initial value of Permanent Space as 512 megabytes to JVM<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">java
-XX:PermSize=512m MyJavaProgram<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example2</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> :
Set initial value of Permanent Space as 512 gigabyte to JVM<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">java
-XX:PermSize=1g MyJavaProgram<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:MaxPermSize</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">:
It’s maximum value of Permanent Space that JVM can allot up to.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example1</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> :
set maximum value of Permanent Space as 512 megabytes to JVM<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">java
-XX:MaxPermSize=512m MyJavaProgram<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example2</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> :
set maximum value of Permanent Space as 1 gigabyte to JVM<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">java
-XX:MaxPermSize=1g MyJavaProgram<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #1f497d; font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%; mso-themecolor: text2;">Other
important VM (JVM) parameters for java heap in java<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:MinHeapFreeRatio and
-XX:MaxHeapFreeRatio<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">JVM
can grows or shrinks the heap to keep the proportion of free space to live
objects within a specific range.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:+AggressiveHeap</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> is
used for Garbage Collection Tuning setting. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">This
VM option inspects the server resources and attempts to set various parameters
in optimal manner for long running and memory consuming applications. There
must be minimum of 256MB of physical memory on the servers before the
AggressiveHeap can be used. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-Xss -</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> Use this VM option
to adjust the maximum thread stack size. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Also
you must know that -Xss option is same as -XX:ThreadStackSize.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example1</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> :
set the default stack size of JVM to 512
megabytes.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">java
-Xss512m MyJavaProgram<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example2</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> :
set the default stack size of JVM to 1
gigabyte.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">java
-Xss1g MyJavaProgram<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #1f497d; font-family: "Arial","sans-serif"; font-size: 12.0pt; line-height: 115%; mso-themecolor: text2;">Different
types Garbage collectors<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #1f497d; font-family: "Arial","sans-serif"; mso-themecolor: text2;">Serial collector / Serial GC (Garbage
collector) in java <o:p></o:p></span></b></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l21 level1 lfo11; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Serial collector is also called Serial GC
(Garbage collector) or Serial Collector in java. <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l21 level1 lfo11; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Serial GC (Garbage collector) is rarely used
in java.<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l21 level1 lfo11; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Serial GC (Garbage collector) is designed for
the single threaded environments in java.<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l21 level1 lfo11; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">In Serial GC (Garbage collector) , both minor
and major garbage collections are done serially by one thread (using a single
virtual CPU) in java. <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l21 level1 lfo11; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Serial GC (Garbage collector) uses a
mark-compact collection method. This method moves older memory to the beginning
of the heap so that new memory allocations are made into a single continuous
chunk of memory at the end of the heap. This compacting of memory makes it
faster to allocate new chunks of memory to the heap in java.<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l21 level1 lfo11; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">The serial garbage collector is the default
for client style machines in Java SE 5 and 6. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">When to Use the Serial GC (garbage
Collector) in java?<o:p></o:p></span></b></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l2 level1 lfo12; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">The Serial GC is the garbage collector of
choice for most applications that do not have low pause time requirements and run
on client-style machines. It takes advantage of only a single virtual processor
for garbage collection work in java.<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l2 level1 lfo12; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Serial GC (garbage collector) is also popular
in environments where a high number of JVMs are run on the same machine. In
such environments when a JVM does a garbage collection it is better to use only
one processor to minimize the interference on the remaining JVMs in java.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Vm (JVM) option for enabling serial GC
(garbage Collector) in java <o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:+UseSerialGC<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example
of Passing Serial GC in Command Line for starting jar<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">java
-Xms256m -Xms512m -XX:+UseSerialGC -jar
d:\MyJar.jar<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #1f497d; font-family: "Arial","sans-serif"; mso-themecolor: text2;">Throughput GC (Garbage collector) or
Parallel collector in java<o:p></o:p></span></b></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l26 level1 lfo13; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Throughput collector is also called <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l26 level2 lfo13; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Throughput GC (garbage collector)<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l26 level2 lfo13; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">ParallelGC (garbage collector)<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l26 level2 lfo13; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Throughput collector<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l26 level2 lfo13; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">ParallelGC collector<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l26 level1 lfo13; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Throughput garbage collector is the default
garbage collector for JVM in java.<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l26 level1 lfo13; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Throughput garbage collector uses multiple
threads to execute a minor collection and so reduces the serial execution time
of the application in java. <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l26 level1 lfo13; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">The throughput garbage collector is similar
to the serial garbage collector but uses multiple threads to do the minor
collection in java. <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l26 level1 lfo13; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">This garbage collector uses a parallel
version of the young generation garbage collector in java. <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l26 level1 lfo13; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">The tenured generation collector is the same
as the serial garbage collector in java.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">When
to Use the Throughput GC (Garbage collector) in java?<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l18 level1 lfo14; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">The Throughput garbage collector should be
used when application can afford low pauses in java.<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l18 level1 lfo14; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">And application is running on host with
multiple CPU’s (to derive advantage of using multiple threads for garbage
collection) in java.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Vm
(JVM) option for enabling throughput GC (Garbage collector) in java<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> -XX:+UseParallelGC<o:p></o:p></span></b></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example
of using throughput collector in Command Line for starting jar<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">java
-Xms256m -Xms512m -XX:<b>+UseParallelGC </b>-jar d:\MyJar.jar<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">With
this Vm (JVM) option you get a <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l7 level1 lfo15; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Multi-threaded
young generation</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> garbage collector in java, <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l7 level1 lfo15; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">single-threaded
old generation</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> garbage collector in java and<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l7 level1 lfo15; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">single-threaded
compaction</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> of old generation in java.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Vm
(JVM) option for enabling throughput collector with n number of threads in java<o:p></o:p></span></div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l10 level1 lfo16; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:ParallelGCThreads=<numberofthreads><o:p></o:p></numberofthreads></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Another
Vm (JVM) option for enabling throughput collector in java <o:p></o:p></span></div>
<div class="MsoListParagraph" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l10 level1 lfo16; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:+UseParallelOldGC<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Goals for Throughput GC (Garbage
collector) in java<o:p></o:p></span></b></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l10 level1 lfo16; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Maximum pause time goal (Highest priority)<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l10 level1 lfo16; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Throughput goal<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l10 level1 lfo16; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Minimum footprint goal (Lowest priority)<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto;">
<br /></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin: 0in; mso-add-space: auto;">
<b><span style="font-family: Arial, sans-serif;">Controlling maximum pause time and throughput</span></b><span style="font-family: "Arial","sans-serif";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin: 0in; mso-add-space: auto;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Maximum
pause time goal (Highest priority)<o:p></o:p></span></b></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo18; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Vm (JVM) option for maximum pause time in
java.<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l0 level2 lfo18; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">We gives hint to throughput collector that
pause time should be <milisec> milliseconds or less.<o:p></o:p></milisec></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l0 level2 lfo18; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:MaxGCPauseMillis=<milisec><o:p></o:p></milisec></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l0 level2 lfo18; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example. We gives hint to throughput
collector that pause time should be 100 milliseconds or less. -XX:MaxGCPauseMillis=100<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo18; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">The throughput collector will adjust the Java
heap size and other garbage collection related parameters in an attempt to keep
garbage collection pauses shorter than <milisec> milliseconds.<o:p></o:p></milisec></span></div>
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l0 level1 lfo18; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">By default there is no maximum pause time
goal. <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Throughput goal<o:p></o:p></span></b></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l27 level1 lfo19; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Vm (JVM) option for throughput in java. <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l27 level1 lfo19; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">The throughput is measured time spent doing
garbage collection and time spent outside of garbage collection.
-XX:GCTimeRatio=<milisec><o:p></o:p></milisec></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l27 level1 lfo19; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Example : XX:GCTimeRatio=19 sets a goal of 5%
of the total time for garbage collection. By default the goal for total time
for garbage collection is 1%.<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l27 level1 lfo19; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">The ratio of garbage collection time to
application time is 1 / (1 + <milisec>)<o:p></o:p></milisec></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Performance
of Throughput GC (garbage Collector) host <b>with
different number of CPU’s</b> in java<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l30 level1 lfo17; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">By default on a host with N CPUs, the
throughput collector uses N garbage collector threads in the minor collection.
Note : We can control number of garbage
collector threads with a command line option in java.<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l30 level1 lfo17; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">On a host with 1 CPU the throughput collector
will not perform as well as the serial collector because of the additional
overhead for the parallel execution (Example - Synchronization costs) in java. <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l30 level1 lfo17; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">On a host with 2 CPUs the throughput
collector generally performs as well as the serial garbage collector and a
reduction in the minor garbage collector pause times can be expected on hosts
with more than 2 CPUs in java.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Adjusting Generation Sizes in throughput
GC (Garbage collector) </span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l11 level1 lfo21; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">By default a generation <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l13 level2 lfo20; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">grows in increments of 20% and <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l13 level2 lfo20; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">shrinks in increments of 5%. <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l13 level1 lfo20; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">Controlling growth of generation (in percent)
><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l13 level2 lfo20; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:YoungGenerationSizeIncrement=<growthpercent></growthpercent></span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">
for the young generation and <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l13 level2 lfo20; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:TenuredGenerationSizeIncrement=<growthpercent></growthpercent></span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;"> for
the tenured generation. <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l13 level1 lfo20; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; line-height: 115%; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">shrink of generation (in percent) ><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l13 level2 lfo20; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">-XX:
AdaptiveSizeDecrementScaleFactor=<shrinkpercent><o:p></o:p></shrinkpercent></span></b></div>
<div class="MsoListParagraphCxSpLast" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l13 level2 lfo20; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; line-height: 115%;">If the size of an increment for growing is
growthPercent, the size of the decrement for shrinking will be growthPercent/
shrinkPercent.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: blue; font-family: "Arial","sans-serif"; mso-fareast-font-family: "Times New Roman";">5.4) Concurrent Mark Sweep (CMS) Collector /
concurrent low pause collector in java</span></b><span style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .75in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l31 level1 lfo23; tab-stops: list .75in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><a href="http://www.javamadesoeasy.com/2016/10/concurrent-mark-sweep-cms-collector.html"><span style="color: #1155cc; font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">Concurrent Mark Sweep Collector</span></a><span style="font-family: Arial, sans-serif; font-size: 10pt;"> is also called<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: 3.0pt; margin-left: 1.25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l31 level2 lfo23; tab-stops: list 1.25in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10pt;">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;"> </span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">concurrent low pause collector<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l31 level2 lfo23; tab-stops: list 1.25in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">concurrent low pause GC
(garbage collector)</span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: 3.0pt; margin-left: 1.25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l31 level2 lfo23; tab-stops: list 1.25in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10pt;">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;"> </span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">CMS GC (garbage Collector)<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l31 level2 lfo23; tab-stops: list 1.25in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">CMS Collector</span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: 3.0pt; margin-left: 1.25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l31 level2 lfo23; tab-stops: list 1.25in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10pt;">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;"> </span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">concurrent low pause collector <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l31 level2 lfo23; tab-stops: list 1.25in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">concurrent low pause GC
(garbage collector)</span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 3.0pt; margin-left: .75in; margin-right: 0in; margin-top: 0in; mso-list: l31 level1 lfo23; tab-stops: list .75in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Concurrent Mark Sweep
(CMS) collector <b>collects the old/tenured generation</b> in java<b>. </b><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 3.0pt; margin-left: .75in; margin-right: 0in; margin-top: 0in; mso-list: l31 level1 lfo23; tab-stops: list .75in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Concurrent Mark Sweep
(CMS) Collector <b>minimize the pauses </b>by doing most of the <b>garbage
collection work concurrently with the application threads</b> in java. <o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: 3.0pt; margin-left: .75in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l31 level1 lfo23; tab-stops: list .75in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Concurrent Mark Sweep
(CMS) Collector action <b>on live objects ></b><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l31 level2 lfo23; tab-stops: list 1.25in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10pt;">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Concurrent Mark Sweep
(CMS) Collector <b>does not copy or compact the live objects</b>. A garbage
collection is done <b>without moving the live objects</b>. If fragmentation
becomes a problem, allocate a larger heap in java.</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Times New Roman", serif; font-size: 13.5pt;"><br />
</span><b><span style="background: white; font-family: Arial, sans-serif; font-size: 10pt;">When to
Use the Concurrent Low Pause Collector in java</span></b><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l12 level2 lfo24; tab-stops: list .5in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Concurrent Low Pause
Collector should be used if your <b>applications that require low garbage
collection pause times</b> in java<b>.</b> </span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l12 level2 lfo24; tab-stops: list .5in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Concurrent Low Pause
Collector should be used when your <b>application can </b>afford to <b>share
processor resources with the garbage collector while </b>the <b>application is
running</b> in java. </span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l12 level2 lfo24; tab-stops: list .5in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Concurrent Low Pause
Collector is beneficial to applications which have a relatively <b>large set of
long-lived data</b> (a large tenured generation) and run on machines with <b>two
or more processors</b> in java.</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l12 level2 lfo24; tab-stops: list .5in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Examples
</span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;">when to use
Concurrent Mark Sweep (CMS) collector / concurrent low pause collector </span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Example 1 - Desktop UI
application</span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;"> that <b>respond to
events</b>, </span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Example 2 - Web server
responding to a request</span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;">
and</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; text-indent: .5in;">
<b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Example 3 - Database
responding to queries.</span></b><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Times New Roman", serif; font-size: 10pt;"><br />
</span><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Vm </span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;">(JVM) option for enabling <b>Concurrent Mark
Sweep </b>(CMS) Collector </span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraph" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l9 level2 lfo25; tab-stops: list .5in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">-XX:+UseConcMarkSweepGC</span></b><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Example </span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;">of using Concurrent Mark Sweep (CMS) collector <b>/
concurrent low pause collector</b> <o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;">java -Xms256m -Xms512m
<b>-XX:+UseConcMarkSweepGC</b> -jar d:\MyJar.jar</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: Arial, sans-serif;">Concurrent Mark Sweep (CMS) Collector /
concurrent low pause collector working in detail </span></b><span style="font-family: "Times New Roman", serif;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: Arial, sans-serif; font-size: 10pt;">As mentioned above
Concurrent Mark Sweep (CMS) collector <b>collects the old/tenured generation
(i.e. </b>performs <b><i><span style="background: #EFEFEF;">Major garbage
collection </span></i></b>process<b>). </b></span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Times New Roman", serif; font-size: 10pt;"><br />
</span><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Major gc(garbage
collection)</span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;"> in Concurrent Mark
Sweep (CMS) Collector / concurrent low pause </span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l9 level2 lfo25; tab-stops: list .5in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">For
each major collection</span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;"> the CMS collector will <b>pause
all </b>the <b>application threads for a brief period</b> at the <b>beginning </b>of
the collection and toward the <b>middle </b>of the collection. </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l9 level2 lfo25; tab-stops: list .5in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">The <b>second pause </b>tends
to be the <b>longer </b>than first pause and <b>uses multiple threads to do the
collection</b> work during that pause in java. The remainder of the collection
is done with a garbage collector thread that runs concurrently with the
application. </span><span style="font-family: "Times New Roman", serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Minor gc (garbage
collection)</span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;"> in Concurrent Mark
Sweep (CMS) Collector / concurrent low pause collector</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraph" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l8 level2 lfo26; tab-stops: list .5in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">The minor collections is
done in a manner <b>similar to the serial collector</b> although <b>multiple
threads are used</b> to do the collection in java.</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Heap Structure for CMS
garbage Collector</span></b><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l8 level2 lfo26; tab-stops: list .5in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">CMS garbage collectors
didies heap into three sections: <b>young </b>generation, <b>old </b>generation,
and <b>permanent </b>generation of a fixed memory size.</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l8 level2 lfo26; tab-stops: list .5in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Young
</span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Generation is further
divided into <b>Eden</b>, <b>S0 (Survivor </b>space 0<b>) </b>and <b>S1
(Survivor </b>space 1<b>).</b></span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: Arial, sans-serif;">Detailed Steps</span></b><span style="font-family: Arial, sans-serif;"> in
GC (garbage collection) cycle in Concurrent Mark Sweep (CMS) Collector /
concurrent low pause garbage collector:</span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l28 level2 lfo27; tab-stops: list .5in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10.0pt; mso-bidi-font-family: Symbol; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Young
Generation GC </span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;">(garbage Collection) </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l3 level3 lfo28; tab-stops: list 1.0in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10.0pt; mso-bidi-font-size: 12.0pt; mso-fareast-font-family: "Courier New";">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: Arial, sans-serif; font-size: 10.5pt;">Live
objects</span></b><span style="font-family: Arial, sans-serif; font-size: 10.5pt;"> are <b>copied </b>from
the <b>Eden space and survivor space</b> to the <b>other survivor space</b>. </span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l3 level3 lfo28; tab-stops: list .75in 1.0in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10pt;">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;"> </span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10.5pt;">Any <b>older objects</b> that have reached their
aging threshold are <b>promoted to old generation</b>.</span><span style="font-family: "Times New Roman", serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-add-space: auto; mso-list: l3 level2 lfo28; tab-stops: list .5in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">After
Young generation GC </span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;">(garbage Collection) in
java</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 3.0pt; margin-left: .75in; margin-right: 0in; margin-top: 0in; mso-list: l25 level1 lfo29; tab-stops: list .75in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10pt;">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">After a young GC, the <b>Eden
space and one of the survivor spaces is cleared</b>. Eden, S0 and S1 are part
of Young Generation<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .75in; margin-right: 0in; margin-top: 0in; mso-list: l25 level1 lfo29; tab-stops: list .75in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "Courier New"; font-size: 10pt;">o<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;"> </span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">promoted objects (<b>older objects</b> that have
reached their aging threshold in young GC) are are <b>available in old
generation</b>.</span><span style="font-family: "Times New Roman", serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<ul style="margin-top: 0in;" type="disc">
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; vertical-align: baseline;"><b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">Old Generation</span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">
<b>GC </b>(garbage Collection)<b> with CMS</b> in java</span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></li>
<ol start="1" style="margin-top: 0in;" type="1">
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; vertical-align: baseline;"><b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">Initial mark </span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">phase <b>- </b>(<b>First pause </b>happens/ stop the
world event ) - <b>mark live/reachable objects </b>(Example - objects on
thread stack, static objects etc.) and elsewhere in the <b>heap </b>(Example
- the young generation). </span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></li>
<li class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; vertical-align: baseline;"><b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">Concurrent marking </span></b><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";">phase
<b>- (</b>No pause phase ) <b>- </b> finds <b>live objects</b> while
the application continues to execute.</span><span style="font-family: "Arial","sans-serif"; font-size: 10.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"> </span><span style="font-family: "Times New Roman","serif"; font-size: 10.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></li>
</ol>
</ul>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.5in; margin-right: 0in; margin-top: 0in; mso-list: l14 level1 lfo22; text-indent: 0in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "Times New Roman", serif; font-size: 13.5pt;">0.<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Remark
- </span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;">(<b>Second pause</b>
happens/ stop the world events) - It <b>finds objects</b> that were <b>missed
during the concurrent marking phase due to the concurrent execution of the
application threads</b>. </span><span style="font-family: "Times New Roman", serif; font-size: 13.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .75in; margin-right: 0in; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: Arial, sans-serif; font-size: 10.5pt;">Old Generation GC (garbage Collection)<b> -
Sweep phase </b>(Concurrent Sweep phase) in java<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l14 level2 lfo22; tab-stops: list 1.0in; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Arial, sans-serif; font-size: 10.5pt;">1.<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Sweep
</span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;">phase - do the
concurrent <b>sweep</b>, memory is freed up.</span><span style="font-family: Arial, sans-serif; font-size: 10.5pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: 3.0pt; margin-left: 1.25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l29 level4 lfo30; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Objects that were not
marked in the previous phase are deallocated in place.<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l29 level4 lfo30; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">There is no compaction</span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l29 level4 lfo30; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Unmarked
objects</span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;"> are equal to <b>Dead Objects.</b></span><span style="font-family: "Times New Roman", serif; font-size: 10pt;"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: 3.0pt; margin-left: 1.25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l23 level1 lfo32; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Symbol; font-size: 10pt;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">Old Generation GC
(garbage Collection)<b> - After Sweeping</b><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: 3.0pt; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l16 level1 lfo31; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: Arial, sans-serif; font-size: 10pt;">5.<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><b><span style="font-family: Arial, sans-serif; font-size: 10pt;">Reset
</span></b><span style="font-family: Arial, sans-serif; font-size: 10pt;">phase - do the
concurrent <b>reset</b>.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "Times New Roman", serif; font-size: 13.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span><span style="font-family: Arial, sans-serif; font-size: 10pt;"><o:p></o:p></span></div>
<br />
<div class="MsoNormal" style="margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-85767109228369564532017-04-04T00:08:00.003-07:002017-04-04T00:08:55.893-07:00Oracle : Release space occupied by Blob/Clob objects<b>Objective: </b>Release the space occupied by table having columns capable to store BLOB/CLOB data. The space is not released even after deleting the whole row from the table.<br />
<br />
There are defined steps to execute after doing delete of Table rows. Steps are below :<br />
<br />
Assumptions:<br />
Table Name : BLOB_OBJECT_TAB<br />
Column Name : BLOB_OBJECT_TAB_COL<br />
<br />
set serverout on<br />
spool shrink_table.log<br />
<br />
ALTER TABLE BLOB_OBJECT_TAB enable row movement;<br />
<br />
ALTER TABLE BLOB_OBJECT_TAB SHRINK SPACE compact;<br />
<br />
ALTER TABLE BLOB_OBJECT_TAB SHRINK SPACE;<br />
<br />
ALTER TABLE BLOB_OBJECT_TAB MODIFY LOB(BLOB_OBJECT_TAB_COL) (SHRINK SPACE CASCADE);<br />
<br />
alter table BLOB_OBJECT_TAB disable row movement;<br />
<br />
ALTER INDEX PK_ID REBUILD;<br />
<br />
<br />
ALTER TABLE BLOB_OBJECT_TAB disable row movement;<br />
<br />
<br />
<br />
spool off;Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-44236877325133001882016-09-27T07:59:00.001-07:002016-09-27T08:00:26.227-07:00Websphere 8: JMS : File Store and Data Store<b><span style="font-size: large;">File stores</span></b><br />
File stores use a file system to preserve operating information and to persist the objects that messaging engines need for recovery in the event of a failure.<br />
<br />
A file store is a type of message store that directly uses files in a file system through the operating system. The data storage in a file store is split into three levels: the log file, permanent store file, and temporary store file.<br />
<br />
<span style="font-size: x-small;">The relationship between a messaging engine and its file store </span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjihDHiXTkpyEtYX0jS5g6C4W0-EbpWlejrVh3qX2OaxNtSkFXeotqcHYA1sNuVwDlNyivwePU00z9rBCDohoqHTrTu1BpbahNblPI45FOijMbyJu0cqSnR63yfVNAiCoRW48KxYG9m0m4/s1600/filestroe.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="131" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjihDHiXTkpyEtYX0jS5g6C4W0-EbpWlejrVh3qX2OaxNtSkFXeotqcHYA1sNuVwDlNyivwePU00z9rBCDohoqHTrTu1BpbahNblPI45FOijMbyJu0cqSnR63yfVNAiCoRW48KxYG9m0m4/s320/filestroe.jpg" width="320" /></a></div>
<b>Log file</b><br />
This file contains information about currently active transactions and data that is not yet written to a store file. It is a circular log and its file size is static while a messaging engine is running, but can be changed if required. A restart of the messaging engine is required for the changes to take effect. The size of the log file limits the maximum size of a message that can be sent.<br />
<br />
<b>Permanent store file</b><br />
This file contains permanent data that is retained after the restart of the messaging engine, such as persistent messages, queue data, and information about the storage and transmission of persistent messages.<br />
The permanent store file can be configured to have a maximum and minimum size, or to be unlimited in size. The file can grow from the minimum size (or as required in the unlimited case) but will never shrink (even if the maximum size is set lower than its current size). The file sizes can be changed in the administration console, but a restart of the messaging engine is required for the changes to take effect.<br />
Similar to a file system, when data is deleted from the store, the data in the file is not deleted, only the directory information is updated. This means that if a message is consumed, the message data may still be present in the store file, but the directory information that includes this data in the store is updated to reflect the fact that it is deleted.<br />
<br />
<b>Temporary store file</b><br />
This file contains temporary data that is not retained after the restart of the messaging engine, such as non-persistent messages that were spilled to the file store to release memory from the JVM heap. The temporary store file contents are truncated when the messaging engine starts.<br />
The temporary store file can be configured to have a maximum and minimum size, or to be unlimited in size. The file can grow from the minimum size (or as required in the unlimited case) but will never shrink (even if the maximum size is set lower than its current size). The file sizes can be changed in the administration console, but a restart of the messaging engine is required for the changes to take effect.<br />
<br />
Similar to a file system, when data is deleted from the store, the data in the file is not deleted, only the directory information is updated. This means that if a message is consumed, the message data may still be present in the store file, but the directory information that includes this data in the store is updated to reflect the fact that it is deleted.<br />
<br />
<br />
You can configure where the file store files must be placed. By default, the file store uses a subdirectory in the following path: ${USER_INSTALL_ROOT}/filestores/com.ibm.ws.sib/${ME_NAME}. The file store directory contains two other directories; the log directory that contains the log file and the store directory that contains both the PermanentStore and TemporaryStore files.<br />
<br />
<span style="font-size: large;"><b>Data stores</b></span><br />
A data store is a message store that uses a relational database. A messaging engine uses a data store to store operating information in the database, as well as to preserve essential objects that the messaging engine needs for recovery in the event of a failure.<br />
<br />
A data store consists of the set of tables that a messaging engine uses to store persistent data in a database. See Data store tables for a list of the tables that comprise a data store. All the tables in a data store are held in the same database schema. You can create multiple data stores in the same database, provided that you use a different schema name for each data store.<br />
<br />
<br />
The one-to-one relationship between a messaging engine and a data store means that every messaging engine must have its own data store. A messaging engine uses an instance of a JDBC data source to interact with the database that contains the data store for that messaging engine. The relationship between a messaging engine and its data store. illustrates these relationships.<br />
<br />
<span style="font-size: x-small;">The relationship between a messaging engine and its data store</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLXjBXzSIG48sQDHc_1cpGZAdha4St2jxbVz3iJZZ865k_SDVyQFjoF8_tH-bh5MxF2zSG2x_kvDUeb3i-tmrPtUHOy3Civ5Vvqy6cEOXwnC7CPJclNyapDsJs8f16ukJs8R-oEZxIIBc/s1600/datastore.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="140" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgLXjBXzSIG48sQDHc_1cpGZAdha4St2jxbVz3iJZZ865k_SDVyQFjoF8_tH-bh5MxF2zSG2x_kvDUeb3i-tmrPtUHOy3Civ5Vvqy6cEOXwnC7CPJclNyapDsJs8f16ukJs8R-oEZxIIBc/s320/datastore.jpg" width="320" /></a></div>
<span style="font-size: x-small;"><br /></span>
All the tables in the data store must be stored in the same schema. You can create more than one data store in a database, provided that you use a different schema name for each data store. Although every messaging engine uses the same table names, its relationship with the schema gives each messaging engine exclusive use of its own tables.<br />
<br />
<b>Data store topologies</b><br />
You have several options for the relative location of a data store and its messaging engine. The topology also defines the relationship of a data store with other data stores.<br />
The following options affect your choice of data store topology:<br />
•<span class="Apple-tab-span" style="white-space: pre;"> </span>The data store can either run on the same node as its messaging engine or on a remote node.<br />
•<span class="Apple-tab-span" style="white-space: pre;"> </span>The data store can either have a dedicated database or it can share a database with other data stores.<br />
<br />
<b>Tip</b>: If you are using the Informix® RDBMS, configure a separate database instance for each messaging engine.<br />
A data store uses a relational database management system (RDBMS), working through JDBC, to store data as rows in a set of tables. This data is important when you are backing up or restoring a data store.<br />
The following table summarizes the purpose of each data store table.<br />
<div>
<br /></div>
<div>
<table border="0" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-collapse: collapse; margin-left: -1.35pt; mso-padding-alt: 0in 5.4pt 0in 5.4pt; mso-yfti-tbllook: 1184; width: 453px;">
<tbody>
<tr style="height: 15.0pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td style="background: #DADADA; border: solid black 1.0pt; height: 15.0pt; mso-border-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 125.0pt;" valign="bottom" width="167"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "verdana" , sans-serif; font-size: 10pt;">Table name<o:p></o:p></span></b></div>
</td>
<td style="background: #DADADA; border-left: none; border: solid black 1.0pt; height: 15.0pt; mso-border-bottom-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; mso-border-top-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 215.0pt;" valign="bottom" width="287"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="font-family: "verdana" , sans-serif; font-size: 10pt;">Purpose<o:p></o:p></span></b></div>
</td>
</tr>
<tr style="height: 25.5pt; mso-yfti-irow: 1;">
<td style="background: white; border-top: none; border: solid black 1.0pt; height: 25.5pt; mso-border-bottom-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 125.0pt;" valign="top" width="167"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "verdana" , sans-serif; font-size: 10pt;">SIBOWNER<o:p></o:p></span></div>
</td>
<td style="background: white; border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; height: 25.5pt; mso-border-bottom-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 215.0pt;" valign="top" width="287"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "verdana" , sans-serif; font-size: 10pt;">Ensures exclusive access to the data store by an active
messaging engine.<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 38.25pt; mso-yfti-irow: 2;">
<td style="background: white; border-top: none; border: solid black 1.0pt; height: 38.25pt; mso-border-bottom-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 125.0pt;" valign="top" width="167"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "verdana" , sans-serif; font-size: 10pt;">SIBOWNERO<o:p></o:p></span></div>
</td>
<td style="background: white; border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; height: 38.25pt; mso-border-bottom-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 215.0pt;" valign="top" width="287"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "verdana" , sans-serif; font-size: 10pt;">Used for locking the data store. This table stores no data in
its one EMPTY_COLUMN column.<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 25.5pt; mso-yfti-irow: 3;">
<td style="background: white; border-top: none; border: solid black 1.0pt; height: 25.5pt; mso-border-bottom-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 125.0pt;" valign="top" width="167"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "verdana" , sans-serif; font-size: 10pt;">SIBCLASSMAP<o:p></o:p></span></div>
</td>
<td style="background: white; border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; height: 25.5pt; mso-border-bottom-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 215.0pt;" valign="top" width="287"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "verdana" , sans-serif; font-size: 10pt;">Catalogs the different object types in the data store.<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 15.0pt; mso-yfti-irow: 4;">
<td style="background: white; border-top: none; border: solid black 1.0pt; height: 15.0pt; mso-border-bottom-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 125.0pt;" valign="top" width="167"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "verdana" , sans-serif; font-size: 10pt;">SIBLISTING<o:p></o:p></span></div>
</td>
<td style="background: white; border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; height: 15.0pt; mso-border-bottom-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 215.0pt;" valign="top" width="287"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "verdana" , sans-serif; font-size: 10pt;">Catalogs the SIB<i>nnn</i> tables.<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 25.5pt; mso-yfti-irow: 5;">
<td style="background: white; border-top: none; border: solid black 1.0pt; height: 25.5pt; mso-border-bottom-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 125.0pt;" valign="top" width="167"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "verdana" , sans-serif; font-size: 10pt;">SIBXACTS<o:p></o:p></span></div>
</td>
<td style="background: white; border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; height: 25.5pt; mso-border-bottom-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 215.0pt;" valign="top" width="287"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "verdana" , sans-serif; font-size: 10pt;">Maintains the status of active two-phase commit transactions.<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 25.5pt; mso-yfti-irow: 6;">
<td style="background: white; border-top: none; border: solid black 1.0pt; height: 25.5pt; mso-border-bottom-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 125.0pt;" valign="top" width="167"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "verdana" , sans-serif; font-size: 10pt;">SIBKEYS<o:p></o:p></span></div>
</td>
<td style="background: white; border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; height: 25.5pt; mso-border-bottom-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 215.0pt;" valign="top" width="287"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "verdana" , sans-serif; font-size: 10pt;">Assigns unique identifiers to objects in the messaging engine.<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 63.75pt; mso-yfti-irow: 7; mso-yfti-lastrow: yes;">
<td style="background: white; border-top: none; border: solid black 1.0pt; height: 63.75pt; mso-border-bottom-alt: solid black .5pt; mso-border-left-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 125.0pt;" valign="top" width="167"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "verdana" , sans-serif; font-size: 10pt;">SIB<i>nnn</i>, where <i>nnn</i> is a number<o:p></o:p></span></div>
</td>
<td style="background: white; border-bottom: solid black 1.0pt; border-left: none; border-right: solid black 1.0pt; border-top: none; height: 63.75pt; mso-border-bottom-alt: solid black .5pt; mso-border-right-alt: solid black .5pt; padding: 0in 5.4pt 0in 5.4pt; width: 215.0pt;" valign="top" width="287"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="font-family: "verdana" , sans-serif; font-size: 10pt;">Contains persistent objects such as messages and subscription
information. These tables hold both persistent and nonpersistent objects,
using separate tables for the different types of data.<o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
</div>
<div>
<b><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;">Note:</span></b><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;"> </span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;">The SIBOWNERO table was
introduced for</span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;"> </span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;">WebSphere<sup>®</sup></span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;"> </span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;">Application Server</span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;"> </span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;">Version 7.0</span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;"> </span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;">and must be created when
you are migrating to</span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;"> </span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;">WebSphere Application Server</span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;"> </span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;">Version 7.0 or later</span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;"> </span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;">from an earlier version of</span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;"> </span><span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;">WebSphere Application
Server.</span></div>
<div>
<span style="font-family: "arial" , sans-serif; font-size: 9.5pt; line-height: 115%;"><br /></span></div>
<div>
<span style="font-family: "arial" , sans-serif; font-size: large;"><b>Message store high availability</b></span></div>
<div>
<span style="font-family: "arial" , sans-serif;">High availability is achieved by failing over messaging engines between servers. Both file stores and data stores can be deployed in a highly available environment.<br />
<br />In this figure, two servers access a message store that is either a file store accessed through a network file system or a data store that is accessed through a remote database server. This means a messaging engine running on one of the servers can be failed over to the other server, and will retain access to the message store.<br />
</span><br />
<div>
<span style="font-family: "arial" , sans-serif;"><br /></span></div>
<span style="font-family: "arial" , sans-serif;">
<div>
<span style="font-size: x-small;">Figure 1. Failover of a messaging engine between servers </span></div>
</span></div>
<div>
<br />
<div class="separator" style="clear: both; font-family: Arial, sans-serif; font-size: 9.5pt; text-align: center;">
<span style="line-height: 115%;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Fw7p9TL6lMgpe_YHbXr2xz3fBfUpq4Ph6E7UXy9lzsQX7NZvp2DgqVtlU3GldtrJrcdqQ-0RQ-1UOFVW03Nv4QnwWlbNSoIG9cesPPltQ67vGrwXKC_WEOncIQ0TyPUe07LOSUIeD1U/s1600/ha.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="299" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6Fw7p9TL6lMgpe_YHbXr2xz3fBfUpq4Ph6E7UXy9lzsQX7NZvp2DgqVtlU3GldtrJrcdqQ-0RQ-1UOFVW03Nv4QnwWlbNSoIG9cesPPltQ67vGrwXKC_WEOncIQ0TyPUe07LOSUIeD1U/s320/ha.jpg" width="320" /></a></span></div>
<span style="line-height: 115%;">
<div class="separator" style="clear: both; font-family: Arial, sans-serif; font-size: 9.5pt; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; font-family: Arial, sans-serif; font-size: 9.5pt; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "arial" , sans-serif; font-size: large;"><b>Relative advantages of a file store and a data store</b></span></div>
<div class="separator" style="clear: both; text-align: left;">
<span style="font-family: "arial" , sans-serif; font-size: large;"><b><br /></b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"><b>When you will use file store over data store?</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"><u>Better performance</u></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;">To achieve best performance using a data store, you often have to use a separate remote database server. With file store you can achieve even better performance without having to use a separate remote database server.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"><u>Low administration requirements</u></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;">The file store combines high throughput with little or no administration. This makes it suitable for those who do not want to worry about where the messaging engine is storing its recoverable data. File store improves on the throughput, and scalability of Apache Derby.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"><u>Lower deployment costs</u></span></div>
<div class="separator" style="clear: both;">
<u><span style="font-family: "arial" , sans-serif;"></span></u></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;">Use of data store might require database administration to configure and manage your messaging engines. File store can be used in environments without a database server.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"><b>When you will use data store over file store?</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;">Some organizations prefer to use data store because it uses their existing resources more effectively. For example, this might be the case for a company with a strong team of database specialists, or a stable database infrastructure.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;">If there is a transient connectivity loss to the file system, the application server must be restarted once the connectivity to the file system is restored. Whereas, in the case of the data store, the messaging engine can recover from the database itself. In such situations, the data store will be a preferred high availability option than the file store system.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;">With data store, some Java EE applications can share JDBC connections and benefit from one-phase commit optimization. File store does not support this optimization.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif; font-size: large;"><b>Security in Message Store : File or Data</b></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;">Data stored in both data store and file store benefit from security features provided by WebSphere® Application Server when accessed using the WebSphere Application Server APIs, that is when using JMS messaging. Further security features are available depending on the type of message store you use. </span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"><b>Data store: </b>you access your chosen database by using a userid and password that is administered using the supplied tools for your specified DBMS. Logical and physical separation of your database server can also be used to improve the overall security of your data.</span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"><br /></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"></span></div>
<div class="separator" style="clear: both;">
<span style="font-family: "arial" , sans-serif;"><b>File store:</b> additional security can be provided when using a file store by careful consideration of your file store files. For example, using a secure network-attached drive to store your file store files improves the physical security of your data. Another example is storing your files on an operating system encrypted file system.</span></div>
</span></div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-84948837356499277242016-09-23T00:07:00.000-07:002016-09-23T00:07:22.263-07:00SEPA Payments - Some informationBelow info is consolidated from Quora.com<br />
<br />
<b><span style="color: #333333; font-family: Helvetica, sans-serif; font-size: 18pt; letter-spacing: -0.75pt;">What is SEPA?</span></b><br />
<br />
<div class="qtextpara" style="margin-bottom: 12.0pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;">
<span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt;">SEPA, or the<span class="apple-converted-space"> </span><b>Single
Euro Payments Area</b>, is a payment system that simplifies bank transfers
denominated in EUR. SEPA is an initiative by the European Union. As of January
2016 SEPA consists of the 28 member states of the EU, Switzerland, Iceland,
Norway, Liechtenstein, Monaco and San Marino. In 2016 Andorra will also join.<o:p></o:p></span></div>
<div class="qtextpara" style="margin: 0in 0in 12pt;">
<span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt;">SEPA payments are either free or very cheap, which is great for
intra-European business. In countries where the euro is not the national
currency many banks still allow people to hold bank accounts denominated in
euro.<o:p></o:p></span></div>
<div class="qtextpara" style="margin: 0in 0in 0.0001pt;">
<span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt;">SEPA introduced a lot of harmonization on 3 domains:</span><o:p></o:p></div>
<div class="qtextpara" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-list: l1 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: #333333; font-family: Symbol; font-size: 11.5pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt;">Credit transfers</span><o:p></o:p></div>
<div class="qtextpara" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-list: l1 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: #333333; font-family: Symbol; font-size: 11.5pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt;">Direct Debits</span><o:p></o:p></div>
<div class="qtextpara" style="margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 0in; margin-top: 0in; mso-list: l1 level1 lfo2; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: #333333; font-family: Symbol; font-size: 11.5pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt;">Card payments</span><o:p></o:p></div>
<div class="qtextpara" style="margin-bottom: .0001pt; margin: 0in;">
<br /></div>
<div class="qtextpara" style="margin-bottom: .0001pt; margin: 0in;">
<span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt;">The
harmonization was done on the standards themselves (everyone now talks XML
ISO20022), pricing aspect, and speed of processing and the rules of behind each
of 3 domains. You can find a lot of information on the EPC websites.</span><o:p></o:p></div>
<div class="qtextpara" style="margin-bottom: .0001pt; margin: 0in;">
<br /></div>
<div class="qtextpara" style="margin-bottom: .0001pt; margin: 0in;">
<span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt;">SEPA,
together with PSD (<span class="qlinkcontainer"><a data-tooltip="attached" href="https://en.wikipedia.org/wiki/Payment_Services_Directive" target="_blank"><span style="color: #2b6dad;">Payment Services Directive</span></a></span>)
and other innovations from the past decade, has allowed fintech startups
to come up with innovative solutions. <o:p></o:p></span></div>
<div class="qtextpara" style="margin-bottom: .0001pt; margin: 0in;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">Most of
the principles of SEPA could be carried over to a successor system:<br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--></span><span style="font-family: "Times New Roman","serif"; font-size: 12.0pt; mso-fareast-font-family: "Times New Roman";"><o:p></o:p></span></div>
<div class="MsoListParagraphCxSpFirst" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 24.0pt; margin-top: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: #333333; font-family: Symbol; font-size: 11.5pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">use of IBAN (with or without BIC)<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 24.0pt; margin-top: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: #333333; font-family: Symbol; font-size: 11.5pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">use of XML data formats<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpMiddle" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 24.0pt; margin-top: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: #333333; font-family: Symbol; font-size: 11.5pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">fees for cross-border payments equal to national payments (in
the same currency)<o:p></o:p></span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 24.0pt; margin-top: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<!--[if !supportLists]--><span style="color: #333333; font-family: Symbol; font-size: 11.5pt; mso-bidi-font-family: Symbol; mso-fareast-font-family: Symbol;">·<span style="font-family: "Times New Roman"; font-size: 7pt; font-stretch: normal; font-variant-numeric: normal; line-height: normal;">
</span></span><!--[endif]--><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";">schemes for credit transfer and direct debit</span></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 24.0pt; margin-top: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<b style="text-indent: 0px;"><span style="color: #333333; font-family: Helvetica, sans-serif; font-size: 18pt; letter-spacing: -0.75pt;"><br /></span></b></div>
<div class="MsoListParagraphCxSpLast" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .5in; margin-right: 24.0pt; margin-top: 0in; mso-add-space: auto; mso-list: l0 level1 lfo1; text-indent: -.25in;">
<b style="text-indent: 0px;"><span style="color: #333333; font-family: Helvetica, sans-serif; font-size: 18pt; letter-spacing: -0.75pt;">What is SEPA Direct Debit (SDD)?</span></b></div>
<div class="MsoNormal">
<span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; line-height: 115%;">The Single Euro Payments Area (SEPA) Direct
Debit is a payment arrangement where the debtor/payer authorizes a
creditor to collect payments from his or her bank account through a signed
mandate. The SEPA Direct Debit allows users to pay for goods and services
through bank transfers as long as they come from the 34 SEPA member countries
in the European Union.<span class="apple-converted-space"> </span></span><br />
<br />
SEPA is a payment method supported by<span class="apple-converted-space"> </span><span class="qlinkcontainer"><a href="https://www.quora.com/topic/Paymentwall-company" target="_blank"><span style="color: #2b6dad;">Paymentwall (company)</span></a></span><o:p></o:p></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; mso-bidi-font-family: "Times New Roman"; mso-fareast-font-family: "Times New Roman";"><br /></span></div>
<h1 style="margin-bottom: .0001pt; margin: 0in;">
<span class="renderedqtext"><span style="color: #333333; font-family: "Helvetica","sans-serif"; font-size: 18.0pt; letter-spacing: -.75pt;">Can I open a bank account for corporation at SEPA bank
from Japan?</span></span><span class="qlinkcontainer"><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt;"><o:p></o:p></span></span></h1>
<div class="MsoNormal">
<span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; line-height: 115%;">You need a bank with an activity in the SEPA
zone. You can ask your Japanese bank to open it via the local branch in one of
the Sepa countries. All Japanse banks I know with an activity in Brussels are
already doing this.</span><span class="qlinkcontainer"><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-outline-level: 1;">
<b><span style="color: #333333; font-family: "Helvetica","sans-serif"; font-size: 18.0pt; letter-spacing: -.75pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman"; mso-font-kerning: 18.0pt;">What are the
differences between ACH, SEPA and RTGS?</span></b><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt;"><br />
<!--[if !supportLineBreakNewLine]--><br />
<!--[endif]--><o:p></o:p></span></div>
<div class="MsoNormal">
<b><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; line-height: 115%;">ACH</span></b><span class="apple-converted-space"><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; line-height: 115%;"> </span><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; line-height: 115%;">stands for<span class="apple-converted-space"> </span></span><b>Automated Clearing House. </b>It is an electronic network for
bank transactions. The term was originally used for the US clearing network(e-check).
All ACH payments in the US are done by one of the two ACH: either the EPN or
FedACH. ACH rules are governed by NACHA. Its now being used for other country's
clearing house as well. To put in the context of India, NEFT is our ACH.</span><o:p></o:p></div>
<div class="MsoNormal">
<span class="apple-converted-space"><br /></span></div>
<div class="MsoNormal">
<b><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; line-height: 115%;">RTGS</span></b><span class="apple-converted-space"><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; line-height: 115%;"> </span><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; line-height: 115%;">is a settlement technique;
it is used by various central banks around the world to do large payment
settlement of their member banks. Best way to describe RTGS is as a <u>real-time
settlement system </u>for banks for large value payments. Banks hold Nostro
accounts with the central banks and all large payments are settled on a gross
basis by the central bank. It is also the mechanism via which deferred net
settlement is done on a periodic basis.<span class="apple-converted-space"> </span><o:p></o:p></span></span></div>
<div class="MsoNormal">
<span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; line-height: 115%;">The primary difference between ACH/NEFT and
RTGS is that payment instructions in ACH are settled in batches whereas payment
instructions in RTGS are settled individually. RTGS is gross settlement whereas
NEFT/ACH is net settlement.<span class="apple-converted-space"> </span><o:p></o:p></span></div>
<div class="MsoNormal">
<span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; line-height: 115%;"><span class="apple-converted-space"><br /></span></span></div>
<br />
<div class="MsoNormal">
<b><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; line-height: 115%;">SEPA</span></b><span class="apple-converted-space"><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; line-height: 115%;"><span style="-webkit-text-stroke-width: 0px; float: none; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; widows: 2; word-spacing: 0px;"> </span></span><span style="color: #333333; font-family: "Georgia","serif"; font-size: 11.5pt; line-height: 115%;">is the European
equivalent of bank transfer for all countries Euro. It is implemented in all
the countries where Euro is and a couple of other participating countries. So
the payment is a single payment instruction/set regardless if the payment is
being made within the Euro country or to another (cross-border) Euro country.
It is not real-time yet, but eventually would be heading there.</span><br />
<b style="-webkit-text-stroke-width: 0px; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; widows: 2; word-spacing: 0px;">SEPA<span class="apple-converted-space"> </span></b><span style="-webkit-text-stroke-width: 0px; float: none; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; widows: 2; word-spacing: 0px;">stands for<span class="apple-converted-space"> </span></span><b style="-webkit-text-stroke-width: 0px; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; widows: 2; word-spacing: 0px;">Single
Euro Payments Area.<span class="apple-converted-space"> </span></b><span style="-webkit-text-stroke-width: 0px; float: none; font-variant-caps: normal; font-variant-ligatures: normal; orphans: 2; text-align: start; widows: 2; word-spacing: 0px;">It really is ACH for European countries under EURO zone. All
EURO countries participate in clearing network like domestic market. Under
SEPA, there's no difference between transactions within or between EURO
countries.</span></span></div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com2tag:blogger.com,1999:blog-8462405262618085864.post-65247878283026851472016-09-21T09:00:00.002-07:002016-09-21T09:19:15.366-07:00Enumerations<br />
<ul>
<li>Enumerations are of class type, and have all the capabilities that a Java class has.</li>
<li>Enumerations can have Constructors, instance Variables, methods and can even implement Interfaces. Constructors cannot be public</li>
<li>Enumerations are not instantiated using new keyword.</li>
<li>All Enumerations by default inherit java.lang.Enum class.</li>
<li>Enumeration with Constructor, instance variable and Method</li>
<li></li>
<li>Because they are constants, the names of an enum fields are created in uppercase (like other Java constants).</li>
<li>You can use an enum any time you need to represent a fixed set of constants.</li>
</ul>
<br />
<div>
How to Define and Use an Enumeration</div>
<div>
<div>
<br /></div>
<div>
An enumeration can be defined simply by creating a list of enum variable. Let us take an example for list of Subject variable, with different subjects in the list.</div>
</div>
<div>
<br /></div>
<div>
<div>
<span style="color: purple;">enum Subject{</span></div>
<div>
<span style="color: purple;"> Java, Cpp, C, Dbms</span></div>
<div>
<span style="color: purple;">}</span></div>
</div>
<div>
<br /></div>
<div>
<div>
Identifiers Java, Cpp, C and Dbms are called enumeration constants. These are public, static final by default.</div>
<div>
<br /></div>
<div>
Variables of Enumeration can be defined directly without any new keyword.</div>
</div>
<div>
<br /></div>
<div>
<div>
<span style="color: purple;">Subject sub</span></div>
</div>
<div>
<span style="color: purple;"><br /></span></div>
<div>
<div>
Variables of Enumeration type can have only enumeration constants as value.</div>
<div>
<div>
<span style="color: purple;">sub = Subject.Java;</span></div>
</div>
<div>
<span style="color: purple;"><br /></span></div>
<div>
<div>
Example of Enumeration</div>
<div>
<br /></div>
<div>
<div>
<span style="color: purple;">enum WeekDays { </span></div>
<div>
<span style="color: purple;"><span class="Apple-tab-span" style="white-space: pre;"> </span>sun, mon, tues, wed, thurs, fri, sat </span></div>
<div>
<span style="color: purple;">}</span></div>
<div>
<span style="color: purple;"><br /></span></div>
<div>
<span style="color: purple;">class Test{</span></div>
<div>
<span style="color: purple;"> public static void main(String args[]) {</span></div>
<div>
<span style="color: purple;"> WeekDays wk;</span></div>
<div>
<span style="color: purple;"> wk = WeekDays.sun;</span></div>
<div>
<span style="color: purple;"> System.out.println("Today is "+wk);</span></div>
<div>
<span style="color: purple;"> }</span></div>
<div>
<span style="color: purple;">}</span></div>
<div>
Output :<span class="Apple-tab-span" style="white-space: pre;"> </span> </div>
<div>
Today is sun</div>
</div>
<div style="color: purple;">
<br /></div>
</div>
<div>
<div>
Values( ) and ValueOf( ) method</div>
<div>
<span style="color: purple;"><br /></span></div>
<div>
All the enumerations have values() and valueOf() methods in them. values() method returns an array of enum-type containing all the enumeration constants in it. Its general form is,</div>
<div>
<span style="color: purple;"><br /></span></div>
<div>
<span style="color: purple;">public static enum-type[ ] values() </span></div>
<div>
<span style="color: purple;"><br /></span></div>
<div>
valueOf() method is used to return the enumeration constant whose value is equal to the string passed in as argument while calling this method. It's general form is,</div>
<div>
<span style="color: purple;"><br /></span></div>
<div>
<span style="color: purple;">public static enum-type valueOf (String str)</span></div>
<div>
<span style="color: purple;"><br /></span></div>
<div>
<span style="color: purple;">enum Student {</span></div>
<div>
<span style="color: purple;"><span class="Apple-tab-span" style="white-space: pre;"> </span>John(11), Bella(10), Sam(13), Viraaj(9);</span></div>
<div>
<span style="color: purple;"><span class="Apple-tab-span" style="white-space: pre;"> </span>private int age; //age of students</span></div>
<div>
<span style="color: purple;"><span class="Apple-tab-span" style="white-space: pre;"> </span>int getage() { return age; }</span></div>
<div>
<span style="color: purple;"><br /></span></div>
<div>
<span style="color: purple;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Student(int age) {<span class="Apple-tab-span" style="white-space: pre;"> </span> //Constructor cannot be public</span></div>
<div>
<span style="color: purple;"><span class="Apple-tab-span" style="white-space: pre;"> </span>this.age= age;</span></div>
<div>
<span style="color: purple;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div>
<div>
<span style="color: purple;">}</span></div>
<div>
<span style="color: purple;"><br /></span></div>
<div>
<span style="color: purple;">public class EnumDemo</span><span style="color: purple;">{</span></div>
<div>
<span style="color: purple;"> public static void main( String args[] )<span class="Apple-tab-span" style="white-space: pre;"> </span> {</span></div>
<div>
<span style="color: purple;"><span class="Apple-tab-span" style="white-space: pre;"> </span>Student S=Student.Bella;</span></div>
<div>
<span style="color: purple;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("Age of Viraaj is " +Student.Viraaj.getage()+ "years");</span></div>
<div>
<span style="color: purple;"><br /></span></div>
<div>
<span style="color: purple;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("Age of "+Student.valueOf("Bella")+" is " +(Student.valueOf("Bella")).getage()+ " years");</span></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"><span style="color: purple;"> </span></span></div>
<div>
<span style="color: purple;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(S.values());</span></div>
<div>
<span style="color: purple;"><br /></span></div>
<div>
<span style="color: purple;"><span class="Apple-tab-span" style="white-space: pre;"> </span>for(Student s : S.values()){</span></div>
<div>
<span style="color: purple;"><span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println(s);</span></div>
<div>
<span style="color: purple;"><span class="Apple-tab-span" style="white-space: pre;"> </span>}</span></div>
<div>
<span style="color: purple;"><br /></span></div>
<div>
<span style="color: purple;"> }</span></div>
<div>
</div>
<div>
<span style="color: purple;">}</span></div>
<div>
<span style="color: purple;"><br /></span></div>
<div>
Output</div>
<div>
Age of Viraaj is 9years</div>
<div>
Age of Bella is 10 years</div>
<div>
[LStudent;@7e199049</div>
<div>
John</div>
<div>
Bella</div>
<div>
Sam</div>
<div>
Viraaj</div>
<div style="color: purple;">
<br /></div>
</div>
<div>
A Java enum switch statement example<br />
You can also use a Java enum in a switch statement. Here’s the source code for a complete Java enum switch statement example:<br />
<br />
<span style="color: purple;">public class JavaEnumSwitchCaseExample {</span><br />
<span style="color: purple;"><br /></span>
<span style="color: purple;"> enum Margin {</span><br />
<span style="color: purple;"> TOP, RIGHT, BOTTOM, LEFT</span><br />
<span style="color: purple;"> }</span><br />
<span style="color: purple;"><br /></span>
<span style="color: purple;"> public static void main(String[] args)<span class="Apple-tab-span" style="white-space: pre;"> </span> {</span><br />
<span style="color: purple;"> System.out.println(getMarginValue(Margin.TOP));</span><br />
<span style="color: purple;"> }</span><br />
<span style="color: purple;"><br /></span>
<span style="color: purple;"> /**</span><br />
<span style="color: purple;"> * @param A valid Margin value.</span><br />
<span style="color: purple;"> * @return A String representing the value for the given Margin,</span><br />
<span style="color: purple;"> * or null if the Margin is not valid.</span><br />
<span style="color: purple;"> */</span><br />
<span style="color: purple;"> public static String getMarginValue(Margin margin) {</span><br />
<span style="color: purple;"> // use the enum values in our switch statement here</span><br />
<span style="color: purple;"> switch (margin) {</span><br />
<span style="color: purple;"> case TOP: return "1em";</span><br />
<span style="color: purple;"> case RIGHT: return "12px";</span><br />
<span style="color: purple;"> case BOTTOM: return "1.5em";</span><br />
<span style="color: purple;"> case LEFT: return "6px";</span><br />
<span style="color: purple;"> default: return null;</span><br />
<span style="color: purple;"> }</span><br />
<span style="color: purple;"> }</span><br />
<span style="color: purple;"> </span><br />
<span style="color: purple;">}</span></div>
<div>
<br /></div>
<div style="color: purple;">
enums and implementation of serialization and singleton:<br />
<br />
1) Singleton using Enum in Java<br />
This is the way we generally declare Enum Singleton , it may contain instace variable and instance method but for sake of simplicity I haven’t used any, just beware that if you are using any instance method than you need to ensure thread-safety of that method if at all it affect the state of object. By default creation of Enum instance is thread safe but any other method on Enum is programmers responsibility.<br />
<div style="color: purple;">
<span style="color: purple;"><br /></span>
<span style="color: purple;">/**</span></div>
<div style="color: purple;">
<span style="color: purple;">* Singleton pattern example using Java Enumj</span></div>
<div style="color: purple;">
<span style="color: purple;">*/</span></div>
<div style="color: purple;">
<span style="color: purple;">public enum EasySingleton{</span></div>
<div style="color: purple;">
<span style="color: purple;"> INSTANCE;</span></div>
<div style="color: purple;">
<span style="color: purple;">}</span></div>
<span style="color: purple;"><br /></span>
You can acess it by EasySingleton.INSTANCE, much easier than calling getInstance() method on Singleton.<br />
<span style="color: purple;"><br /></span>
<span style="color: purple;"><br /></span>
2) Enum Singletons handled Serialization by themselves<br />
Another problem with conventional Singletons are that once you implement serializable interface they are no longer remain Singleton because readObject() method always return a new instance just like constructor in Java. you can avoid that by using readResolve() method and discarding newly created instance by replacing with Singleton as shown in below example :<br />
<div style="color: purple;">
<span style="color: purple;"><br /></span>
<span style="color: purple;"> //readResolve to prevent another instance of Singleton</span></div>
<div style="color: purple;">
<span style="color: purple;"> private Object readResolve(){</span></div>
<div style="color: purple;">
<span style="color: purple;"> return INSTANCE;</span></div>
<div style="color: purple;">
<span style="color: purple;"> }</span></div>
<span style="color: purple;"><br /></span>
This can become even more complex if your Singleton Class maintain state, as you need to make them transient, but within Enum Singleton, Serialization is guaranteed by JVM.<br />
<span style="color: purple;"><br /></span>
3) Creation of Enum instance is thread-safe<br />
As stated in point 1 since creatino of Enum instance is thread-safe by default you don't need to worry about double checked locking. </div>
</div>
<div>
<br /></div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-90099742006283353382016-09-20T04:41:00.002-07:002016-09-20T04:49:20.258-07:00JMS Message Structure<span style="background-color: white; color: #444444; font-family: "open sans" , sans-serif; font-size: 18px;">The basic structure of a JMS message consists out of three parts: </span><b style="background-color: white; color: #444444; font-family: "Open Sans", sans-serif; font-size: 18px;">headers</b><span style="background-color: white; color: #444444; font-family: "open sans" , sans-serif; font-size: 18px;">,</span><b style="background-color: white; color: #444444; font-family: "Open Sans", sans-serif; font-size: 18px;">properties</b><span style="background-color: white; color: #444444; font-family: "open sans" , sans-serif; font-size: 18px;"> and </span><b style="background-color: white; color: #444444; font-family: "Open Sans", sans-serif; font-size: 18px;">body</b><span style="background-color: white; color: #444444; font-family: "open sans" , sans-serif; font-size: 18px;">. </span><br />
<br />
<table border="0" cellspacing="0" cols="3" frame="VOID" rules="NONE">
<colgroup><col width="125"></col><col width="136"></col><col width="557"></col></colgroup>
<tbody>
<tr>
<td align="CENTER" bgcolor="#CCCCFF" colspan="3" height="20" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" width="818"><b>JMS Message Headers</b></td>
</tr>
<tr>
<td align="CENTER" bgcolor="#FFFF00" height="19" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="MIDDLE"><b><span style="color: #333333; font-family: "arial";">Header Field</span></b></td>
<td align="CENTER" bgcolor="#FFFF00" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="MIDDLE"><b><span style="color: #333333; font-family: "arial";">Set By</span></b></td>
<td align="CENTER" bgcolor="#FFFF00" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="MIDDLE"><b><span style="color: #333333; font-family: "arial";">Description</span></b></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" height="47" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">JMSDestination</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">send or publish method</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">Returns a Destination object (a Topic or a Queue, or their temporary version) describing where the message was directed.</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" height="47" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">JMSDeliveryMode</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">send or publish method</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">Can be DeliveryMode.NON_PERSISTENT orDeliveryMode.PERSISTENT; only persistent messages guarantee delivery in case of a crash of the brokers that transport it.</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" height="47" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">JMSExpiration</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">send or publish method</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">Returns a timestamp indicating the expiration time of the message; it can be 0 on a message without a defined expiration.</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" height="47" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">JMSPriority</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">send or publish method</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">Returns a 0-9 integer value (higher is better) defining the priority for delivery. It is only a best-effort value.</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" height="47" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">JMSMessageID</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">send or publish method</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">Contains a generated ID for identifying a message, unique at least for the current broker. All generated IDs start with the prefix 'ID:', but you can override it with the corresponding setter.</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" height="47" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">JMSTimestamp</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">send or publish method</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">Returns a long indicating the time of sending.</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" height="47" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">JMSCorrelationID</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">Client</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">Can link a message with another, usually one that has been sent previously (typically used for a request/response scenario). For example, a reply can carry the ID of the original request message.</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" height="19" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">JMSReplyTo</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">Client</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">Is a Destination object where replies should be sent, it can be null.</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" height="19" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">JMSType</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">Client</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">Defines a field for provider-specific or application-specific message types.</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" height="32" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">JMSRedelivered</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">JMS provider</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">Returns a boolean indicating if the message is being delivered again after a delivery which was not acknowledge.</span></td>
</tr>
</tbody>
</table>
<br />
<div>
<br /></div>
<div>
<table border="0" cellspacing="0" cols="3" frame="VOID" rules="NONE">
<colgroup><col width="125"></col><col width="136"></col><col width="557"></col></colgroup>
<tbody>
<tr>
<td align="CENTER" bgcolor="#CCCCFF" colspan="3" height="20" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" width="818"><b>JMS Message Properties</b></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" colspan="2" height="32" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><b><span style="font-family: "arial";">Application-related properties</span></b></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">A Java application can assign application-related properties, which are set before the message is delivered.</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" colspan="2" height="47" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><b><span style="font-family: "arial";">Provider-related properties</span></b></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">Every JMS provider can define proprietary properties that can be set either by the client or automatically by the provider. Provider-related properties are prefixed with 'JMS_' followed by the vendor name and the specific property name; for example: JMS_I</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" colspan="2" height="47" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><b><span style="font-family: "arial";">Standard properties</span></b></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">These standardized properties are set by the JMS provider (if supported) when a message is sent. Standard property names start with 'JMSX'; for example: JMSXUserid or JMSXDeliveryCount.</span><br />
<span style="font-family: "arial";"><br /></span>
<span style="font-family: "arial";"><br /></span></td>
</tr>
</tbody>
</table>
</div>
<div>
<table border="0" cellspacing="0" cols="3" frame="VOID" rules="NONE">
<colgroup><col width="125"></col><col width="136"></col><col width="557"></col></colgroup>
<tbody>
<tr>
<td align="CENTER" bgcolor="#CCCCFF" colspan="3" height="20" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" width="818"><b>JMS Message Body</b></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#FFFF00" colspan="2" height="19" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="MIDDLE"><b><span style="font-family: "arial";">Message Type</span></b></td>
<td align="CENTER" bgcolor="#FFFF00" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="MIDDLE"><b><span style="font-family: "arial";">Body Contains</span></b></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" colspan="2" height="19" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">TextMessage</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">A java.lang.String object (for example, the contents of an XML file).</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" colspan="2" height="47" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">MapMessage</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">A set of name-value pairs, with names as String objects and values as primitive types in the Java programming language. The entries can be accessed sequentially by enumerator or randomly by name. The order of the entries is undefined.</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" colspan="2" height="32" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">BytesMessage</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">A stream of uninterpreted bytes. This message type is for literally encoding a body to match an existing message format.</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" colspan="2" height="19" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">StreamMessage</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">A stream of primitive values in the Java programming language, filled and read sequentially.</span></td>
</tr>
<tr>
<td align="LEFT" bgcolor="#CCCCFF" colspan="2" height="19" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">ObjectMessage</span></td>
<td align="LEFT" bgcolor="#CCCCFF" style="border-bottom: 1px solid #000000; border-left: 1px solid #000000; border-right: 1px solid #000000; border-top: 1px solid #000000;" valign="TOP"><span style="font-family: "arial";">A Serializable object in the Java programming language.</span></td>
</tr>
</tbody>
</table>
</div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-83932506490688932382016-09-19T04:58:00.001-07:002016-09-19T04:58:23.190-07:00WMQ Poison Message, Dead Letter Queue and Backout Queue<b>Dead-letter queues</b><br />
The dead-letter queue (or undelivered-message queue) is the queue to which messages are sent if they cannot be routed to their correct destination.<br />
<br />
Messages are put on this queue when they cannot be put on the destination queue. For example, because the queue does not exist, or because it is full. Dead-letter queues are also used at the sending end of a channel, for data-conversion errors.<br />
<br />
Consider defining a dead-letter queue for each queue manager. If you do not, and the MCA is unable to put a message, it is left on the transmission queue and the channel is stopped.<br />
<br />
Also, if fast, non-persistent messages (see Fast, nonpersistent messages) cannot be delivered, and no dead-letter queue exists on the target system, these messages are discarded.<br />
<br />
However, using dead-letter queues can affect the sequence in which messages are delivered, and so you might choose not to use them.<br />
<br />
You can use the <b>USEDLQ</b> channel attribute to determine whether the dead-letter queue is used when messages cannot be delivered. This attribute can be configured so that some functions of the queue manager use the dead-letter queue, while other functions do not. For more information about the use of the USEDLQ channel attribute on different MQSC commands, see DEFINE CHANNEL, DISPLAY CHANNEL, ALTER CHANNEL, and DISPLAY CLUSQMGR.<br />
<br />
<br />
<b>Use Dead-Letter Queue (USEDLQ)</b><br />
This attribute determines whether the dead-letter queue (or undelivered message queue) is used when messages cannot be delivered by channels.<br />
<br />
Possible values are:<br />
NO<br />
Messages that cannot be delivered by a channel are treated as a failure. The channel either discards these messages, or the channel ends, in accordance with the setting of NPMSPEED.<br />
YES (default)<br />
If the queue manager DEADQ attribute provides the name of a dead-letter queue, then it is used, otherwise the behaviour is as for NO.<br />
<br />
<br />
<b>Handling poison messages in WebSphere MQ classes for JMS</b><br />
A <b>poison</b> message is one which cannot be processed by a receiving MDB application. If a poison message is encountered, the JMS MessageConsumer and ConnectionConsumer objects can requeue it according to two queue properties, <b>BOQNAME</b>, and <b>BOTHRESH</b>.<br />
<br />
Sometimes, a badly formatted message arrives on a queue, the receiving application cannot process the message correctly. Such a message can cause the receiving application to fail and to back out this badly formatted message. The message can then be repeatedly delivered to the input queue and repeatedly backed out by the application. These messages are known as poison messages. The JMS <b>MessageConsumer</b> object detects poison messages and reroutes them to an alternative destination.<br />
<br />
The WebSphere® MQ queue manager keeps a record of the number of times that each message has been backed out. When this number reaches a configurable <b>threshold</b> value, the message consumer requeues the message to a named <b>backout</b> queue. If this requeuing fails for any reason, the message is removed from the input queue and either requeued to the<b> dead-letter queue,</b> or discarded.<br />
<br />
The threshold value and the name of the back out queue are attributes of a WebSphere MQ queue. The names of the attributes are <b>BackoutThreshold</b> and <b>BackoutRequeueQName</b>.<br />
<br />
To set the BackoutThreshold and BackoutRequeueQName attributes, issue the following MQSC command:<br />
<b>ALTER QLOCAL(your.queue.name) BOTHRESH(threshold value) BOQNAME(your.backout.queue.name)</b><br />
<br />
If the BackoutThreshold attribute is set to a value other than <b>zero</b>, to avoid unexpected behavior set the BackoutRequeueQName attribute to a valid queue name.<br />
<br />
For publish/subscribe messaging, if your system creates a dynamic queue for each subscription, these attribute values are obtained from the WebSphere MQ classes for JMS model queue, <b>SYSTEM.JMS.MODEL.QUEUE</b>. To alter these settings, use:<br />
<b>ALTER QMODEL(SYSTEM.JMS.MODEL.QUEUE) BOTHRESH(threshold value) BOQNAME(your.backout.queue.name)</b><br />
<br />
<u>If the backout threshold value is zero, poison message handling is disabled,</u> and poison messages remain on the input queue. Otherwise, when the backout count reaches the threshold value, the message is sent to the named backout queue. <b>If the backout count reaches the threshold value, but the message cannot go to the backout queue, the message is sent to the dead-letter queue or it is discarded.</b> This situation occurs if the backout queue is not defined, or if the MessageConsumer object cannot send the message to the backout queueSanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-59699149708659011312016-09-19T04:04:00.000-07:002016-09-19T04:13:23.804-07:00IBM WebSphere MQ Series Important Concepts<b>QueueManager:</b><br />
QueueManager is responsible for storing and routing messages to other Queue Manager within MQ and it also communicate with outside world e.g. Java program or any other MQ client.<br />
<br />
<b>Channel:</b><br />
Queue Manager use channel to transmit messages to other QueueManager. Channel carries one way traffic in MQ Series (i.e. channels are uni directional). You can have either sending channel or receiving channel in MQ<br />
<br />
<b>Dead Letter Queue:</b><br />
A queue which is used by QueueManager to archive messages for a non existent queue. Also, if a local queue is full, in that case also, messages are routed to Dead Letter Queue.<br />
<br />
<b>CCDT file (Client Channel Definition table):</b><br />
CCDT file is a binary file which contains connection details required by MQ clients e.g. Java application using JMS to connect to MQ Server. In order to connect to MQ Server, MQ clients needs MQ Server host name, MQ Server port name and server channel name. All these details are encapsulated in CCDT file named as AMQCLCHL.TAB. In order to create MQ Connection, MQ clients needs location of this file, which is provided as configuration. most of MQ errors comes either with incorrect CCDT files.<br />
<br />
<b>SSLPEER (SSL Peer):</b><br />
SSLPEER is a String usually DN (Distinguished name) of MQ Client which connect to QueueManager securely using QueueManager. This is a mechanism WMQ uses to identify client. In case of Java or JMS client, SSLPEER is DN of client certificate stored in its keyStore and sent to server during SSL handshake.<br />
<br />
<b>Backout Queue:</b><br />
Dead letter queue is used to store messages which is received for non existent queue. On the other hand backout queue are application specific queue.If MQ client is not able to process message and ask for redelivery, message is redelivered to client with incremented delivery count. Once this deliveryCount crossed a configured threshold, message is moved to back-out queue for later processing or error handling. In short if MQ Series not able to deliver message to client after a preconfigured attempt, WMQ moves message to backout queue.<br />
<br />
If the application is unable to move the message to the Back Out Queue (BOQ) for some reason, then an attempt is made to move the queue to the Dead Letter Queue (DLQ). For example, there are some permission issues on the Back Out Queue, so the message could not be written to the BOQ and it will be moved to Dead letter Queue.<br />
<br />
<b>Binding connection and Client Connection:</b><br />
If MQ clients sits on same physical server where QueueManager is located than it can create binding connection which is relatively faster than client connection, which is usually created by MQ clients residing on same network but not same host. Most of application uses MQ client connection to connect QueueMangaer, which is easy and flexible.<br />
<br />
<b>Local Queue and Remote Queue:</b><br />
local queues are queue on same QueueManager while remote queue refers to queue on different QueueManager.<br />
<br />Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-50088301598831708952016-09-16T11:00:00.002-07:002016-09-19T04:05:12.615-07:00Why Threads Hung in Java Application<br />
<ol>
<li>Is the query you are using is not having correct indexes? While querying large data from DB, the thread will get hung if its not having indexes in query.</li>
<li>Are you dumping very big object using logger of log4j? </li>
<li>Are you doing database hit and trying to fietch large amount of data simultaneously in multiple requests?</li>
</ol>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-67151840201633984642016-09-14T09:19:00.001-07:002016-09-19T04:07:15.293-07:00JMS - General and Important Concepts<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 115%;">Transacted Message in JMS<o:p></o:p></span></b></div>
<div class="MsoNormal" style="background: white; line-height: 14.7pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"><br /></span></div>
<div class="MsoNormal" style="background: white; line-height: 14.7pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">In a</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><b><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">Java SE environment</span></b><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">or in</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><b><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">the Java EE
application client container</span></b><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">:<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 14.7pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">If</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">transacted</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">is set to</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">true</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">then the session will
use a local transaction which may subsequently be committed or rolled back by
calling the session's</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">commit</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">or</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">rollback</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">methods. The argument
</span><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">acknowledgeMode</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">is ignored.<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 14.7pt; margin-left: .25in; mso-list: l0 level1 lfo1; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto; tab-stops: list .25in; text-indent: -.25in;">
<!--[if !supportLists]--><span style="font-family: "symbol"; font-size: 10.0pt;">·<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal; line-height: normal;">
</span></span><!--[endif]--><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">If</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">transacted</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">is set to</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">false</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">then the session will
be non-transacted. In this case the argument </span><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">acknowledgeMode</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">is used to specify
how messages received by this session will be acknowledged. The permitted
values are</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><b><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">Session.CLIENT_ACKNOWLEDGE</span></b><b><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">,</span></b><b><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span></b><b><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">Session.AUTO_ACKNOWLEDGE</span></b><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">and </span><b><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">Session.DUPS_OK_ACKNOWLEDGE</span></b><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">. For a definition of
the meaning of these acknowledgement modes see the links below.</span></div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-top: none; border: solid #EEEEEE 1.0pt; mso-border-bottom-alt: solid #EEEEEE .75pt; mso-border-left-alt: solid #EEEEEE .75pt; mso-border-right-alt: solid #EEEEEE .75pt; mso-cellspacing: 0in; mso-padding-alt: 0in 0in 0in 0in; mso-yfti-tbllook: 1184; width: 869px;">
<tbody>
<tr style="height: 15.25pt; mso-yfti-firstrow: yes; mso-yfti-irow: 0;">
<td nowrap="" style="background: #DEE3E9; border: none; height: 15.25pt; padding: 6.0pt 2.25pt 2.25pt 5.25pt; width: 87.0pt;" valign="top" width="116"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #353833; font-size: 10.0pt;">Modifier and Type<o:p></o:p></span></b></div>
</td>
<td style="background: #DEE3E9; border: none; height: 15.25pt; padding: 6.0pt 2.25pt 2.25pt 5.25pt; width: 564.4pt;" valign="top" width="753"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #353833; font-size: 10.0pt;">Field and Description<o:p></o:p></span></b></div>
</td>
</tr>
<tr style="height: 60.15pt; mso-yfti-irow: 1;">
<td nowrap="" style="background: white; border: none; height: 60.15pt; padding: 6.0pt 0in 2.25pt 7.5pt; width: 87.0pt;" valign="top" width="116"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: #353833; font-size: 10.5pt;">static
int</span><span style="color: #353833; font-size: 10.0pt;"><o:p></o:p></span></div>
</td>
<td style="background: white; border: none; height: 60.15pt; padding: 6.0pt 0in 2.25pt 7.5pt; width: 564.4pt;" valign="top" width="753"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #4a6782; font-size: 10.5pt;">Session</span></b><b><span style="color: #353833; font-size: 10.5pt;">.<a href="https://docs.oracle.com/javaee/7/api/javax/jms/Session.html#AUTO_ACKNOWLEDGE"><span style="color: #4a6782; text-decoration: none;">AUTO_ACKNOWLEDGE</span></a></span></b><span style="color: #353833; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: 1.5pt;">
<span style="color: #474747; font-size: 10.5pt;">With this acknowledgment mode, the session
automatically acknowledges a client's receipt of a message either when the
session has successfully returned from a call to</span><span style="color: #474747; font-size: 10.5pt;"> </span><span style="color: #474747; font-size: 10.5pt;">receive</span><span style="color: #474747; font-size: 10.5pt;"> </span><span style="color: #474747; font-size: 10.5pt;">or when the message listener the session has
called to process the message successfully returns.<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 31.35pt; mso-yfti-irow: 2;">
<td nowrap="" style="background: #EEEEEF; border: none; height: 31.35pt; padding: 6.0pt 0in 2.25pt 7.5pt; width: 87.0pt;" valign="top" width="116"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: #353833; font-size: 10.5pt;">static
int</span><span style="color: #353833; font-size: 10.0pt;"><o:p></o:p></span></div>
</td>
<td style="background: #EEEEEF; border: none; height: 31.35pt; padding: 6.0pt 0in 2.25pt 7.5pt; width: 564.4pt;" valign="top" width="753"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #4a6782; font-size: 10.5pt;">Session</span></b><b><span style="color: #353833; font-size: 10.5pt;"> .<a href="https://docs.oracle.com/javaee/7/api/javax/jms/Session.html#CLIENT_ACKNOWLEDGE"><span style="color: #4a6782; text-decoration: none;">CLIENT_ACKNOWLEDGE</span></a></span></b><span style="color: #353833; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: 1.5pt;">
<span style="color: #474747; font-size: 10.5pt;">With this acknowledgment mode, the client
acknowledges a consumed message by calling the message's</span><span style="color: #474747; font-size: 10.5pt;"> </span><span style="color: #474747; font-size: 10.5pt;">acknowledge</span><span style="color: #474747; font-size: 10.5pt;"> </span><span style="color: #474747; font-size: 10.5pt;">method.<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 31.35pt; mso-yfti-irow: 3;">
<td nowrap="" style="background: white; border: none; height: 31.35pt; padding: 6.0pt 0in 2.25pt 7.5pt; width: 87.0pt;" valign="top" width="116"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: #353833; font-size: 10.5pt;">static
int</span><span style="color: #353833; font-size: 10.0pt;"><o:p></o:p></span></div>
</td>
<td style="background: white; border: none; height: 31.35pt; padding: 6.0pt 0in 2.25pt 7.5pt; width: 564.4pt;" valign="top" width="753"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #4a6782; font-size: 10.5pt;">Session</span></b><b><span style="color: #353833; font-size: 10.5pt;"> .<a href="https://docs.oracle.com/javaee/7/api/javax/jms/Session.html#DUPS_OK_ACKNOWLEDGE"><span style="color: #4a6782; text-decoration: none;">DUPS_OK_ACKNOWLEDGE</span></a></span></b><span style="color: #353833; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: 1.5pt;">
<span style="color: #474747; font-size: 10.5pt;">This acknowledgment mode instructs the session
to lazily acknowledge the delivery of messages.<o:p></o:p></span></div>
</td>
</tr>
<tr style="height: 45.75pt; mso-yfti-irow: 4; mso-yfti-lastrow: yes;">
<td nowrap="" style="background: #EEEEEF; border: none; height: 45.75pt; padding: 6.0pt 0in 2.25pt 7.5pt; width: 87.0pt;" valign="top" width="116"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: #353833; font-size: 10.5pt;">static
int</span><span style="color: #353833; font-size: 10.0pt;"><o:p></o:p></span></div>
</td>
<td style="background: #EEEEEF; border: none; height: 45.75pt; padding: 6.0pt 0in 2.25pt 7.5pt; width: 564.4pt;" valign="top" width="753"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #4a6782; font-size: 10.5pt;">Session</span></b><b><span style="color: #353833; font-size: 10.5pt;"> .<a href="https://docs.oracle.com/javaee/7/api/javax/jms/Session.html#SESSION_TRANSACTED"><span style="color: #4a6782; text-decoration: none;">SESSION_TRANSACTED</span></a></span></b><span style="color: #353833; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: 1.5pt;">
<span style="color: #474747; font-size: 10.5pt;">This value may be passed as the argument to the
method</span><span style="color: #474747; font-size: 10.5pt;"> </span><span style="color: #474747; font-size: 10.5pt;">createSession(int sessionMode)</span><span style="color: #474747; font-size: 10.5pt;"> </span><span style="color: #474747; font-size: 10.5pt;">on the</span><span style="color: #474747; font-size: 10.5pt;"> </span><span style="color: #474747; font-size: 10.5pt;">Connection</span><span style="color: #474747; font-size: 10.5pt;"> </span><span style="color: #474747; font-size: 10.5pt;">object to specify that the session should use a
local transaction.<o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal" style="background: white; line-height: 14.7pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"><br /></span></div>
<div class="MsoNormal" style="background: white; line-height: 14.7pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">In a</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><b><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">Java EE web or EJB container, when
there is an active JTA transaction in progress</span></b><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">:<o:p></o:p></span></div>
<div class="MsoNormal" style="background: white; line-height: 14.7pt; mso-margin-bottom-alt: auto; mso-margin-top-alt: auto;">
<span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">Both arguments</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">transacted</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">and</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">acknowledgeMode</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">are ignored. The
session will participate in the JTA transaction and will be committed or rolled
back when that transaction is committed or rolled back, not by calling the
session's</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">commit</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">or</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">rollback</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">methods. Since both
arguments are ignored, developers are recommended to use</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"> </span><span style="font-family: "dejavu sans mono"; font-size: 10.5pt;">createSession()</span><span style="font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">, which has no
arguments, instead of this method.<o:p></o:p></span></div>
<h2 style="margin-bottom: 7.5pt; margin-left: 0in; margin-right: 0in; margin-top: 7.5pt;">
<span style="color: #2c4557; font-family: "dejavu sans" , "sans-serif"; font-size: 13.5pt; line-height: 115%;">Interface TopicConnectionFactory</span><span style="color: #474747; font-family: "dejavu serif" , "serif"; font-size: 10.5pt; line-height: 115%;"><o:p></o:p></span></h2>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-top: none; border: solid #EEEEEE 1.0pt; mso-border-bottom-alt: solid #EEEEEE .75pt; mso-border-left-alt: solid #EEEEEE .75pt; mso-border-right-alt: solid #EEEEEE .75pt; mso-cellspacing: 0in; mso-padding-alt: 0in 0in 0in 0in; mso-yfti-tbllook: 1184; width: 783px;">
<tbody>
<tr>
<td nowrap="" style="background: #DEE3E9; border: none; padding: 6.0pt 2.25pt 2.25pt 5.25pt; width: 143.1pt;" valign="top" width="191"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #353833; font-family: "dejavu sans" , "sans-serif"; font-size: 10.0pt;">Modifier and Type<o:p></o:p></span></b></div>
</td>
<td style="background: #DEE3E9; border: none; padding: 6.0pt 2.25pt 2.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #353833; font-family: "dejavu sans" , "sans-serif"; font-size: 10.0pt;">Method and
Description<o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td nowrap="" style="background: white; border: none; padding: 6.0pt 0in 2.25pt 7.5pt; width: 143.1pt;" valign="top" width="191"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: #353833; font-family: "dejavu sans mono"; font-size: 10.5pt;"><a href="https://docs.oracle.com/javaee/7/api/javax/jms/TopicConnection.html" title="interface in javax.jms"><b><span style="color: #4a6782; text-decoration: none;">TopicConnection</span></b></a></span><span style="color: #353833; font-family: "dejavu sans" , "sans-serif"; font-size: 10.0pt;"><o:p></o:p></span></div>
</td>
<td style="background: white; border: none; padding: 6.0pt 0in 2.25pt 7.5pt; width: 444.3pt;" valign="top" width="592"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #353833; font-family: "dejavu sans mono"; font-size: 10.5pt;"><a href="https://docs.oracle.com/javaee/7/api/javax/jms/TopicConnectionFactory.html#createTopicConnection--"><span style="color: #4a6782; text-decoration: none;">createTopicConnection</span></a></span></b><span style="color: #353833; font-family: "dejavu sans mono"; font-size: 10.5pt;">()</span><span style="color: #353833; font-family: "dejavu sans" , "sans-serif"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: 1.5pt;">
<span style="color: #474747; font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">Creates a
topic connection with the default user identity.<o:p></o:p></span></div>
</td>
</tr>
<tr>
<td nowrap="" style="background: #EEEEEF; border: none; padding: 6.0pt 0in 2.25pt 7.5pt; width: 143.1pt;" valign="top" width="191"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: #353833; font-family: "dejavu sans mono"; font-size: 10.5pt;"><a href="https://docs.oracle.com/javaee/7/api/javax/jms/TopicConnection.html" title="interface in javax.jms"><b><span style="color: #4a6782; text-decoration: none;">TopicConnection</span></b></a></span><span style="color: #353833; font-family: "dejavu sans" , "sans-serif"; font-size: 10.0pt;"><o:p></o:p></span></div>
</td>
<td style="background: #EEEEEF; border: none; padding: 6.0pt 0in 2.25pt 7.5pt; width: 444.3pt;" valign="top" width="592"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #353833; font-family: "dejavu sans mono"; font-size: 10.5pt;"><a href="https://docs.oracle.com/javaee/7/api/javax/jms/TopicConnectionFactory.html#createTopicConnection-java.lang.String-java.lang.String-"><span style="color: #4a6782; text-decoration: none;">createTopicConnection</span></a></span></b><span style="color: #353833; font-family: "dejavu sans mono"; font-size: 10.5pt;">(<a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang"><b><span style="color: #4a6782; text-decoration: none;">String</span></b></a> userName, <a href="http://docs.oracle.com/javase/7/docs/api/java/lang/String.html?is-external=true" title="class or interface in java.lang"><b><span style="color: #4a6782; text-decoration: none;">String</span></b></a> password)</span><span style="color: #353833; font-family: "dejavu sans" , "sans-serif"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: 1.5pt;">
<span style="color: #474747; font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">Creates a
topic connection with the specified user identity.<o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">public</span></b><span style="font-family: "courier new"; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">class</span></b><span style="font-family: "courier new"; font-size: 10pt;"> FirstClient {</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">private</span></b><span style="font-family: "courier new"; font-size: 10pt;"> Context </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">context</span><span style="font-family: "courier new"; font-size: 10pt;"> = </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">null</span></b><span style="font-family: "courier new"; font-size: 10pt;">;</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">private</span></b><span style="font-family: "courier new"; font-size: 10pt;"> <span style="background: silver; mso-highlight: silver;">TopicConnectionFactory</span> </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">factory</span><span style="font-family: "courier new"; font-size: 10pt;"> = </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">null</span></b><span style="font-family: "courier new"; font-size: 10pt;">;</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">private</span></b><span style="font-family: "courier new"; font-size: 10pt;"> TopicConnection
</span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">connection</span><span style="font-family: "courier new"; font-size: 10pt;"> = </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">null</span></b><span style="font-family: "courier new"; font-size: 10pt;">;</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">private</span></b><span style="font-family: "courier new"; font-size: 10pt;"> TopicSession </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">session</span><span style="font-family: "courier new"; font-size: 10pt;"> = </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">null</span></b><span style="font-family: "courier new"; font-size: 10pt;">;</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">private</span></b><span style="font-family: "courier new"; font-size: 10pt;"> Topic </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">topic</span><span style="font-family: "courier new"; font-size: 10pt;"> = </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">null</span></b><span style="font-family: "courier new"; font-size: 10pt;">;</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">private</span></b><span style="font-family: "courier new"; font-size: 10pt;"> TopicPublisher </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">publisher</span><span style="font-family: "courier new"; font-size: 10pt;"> = </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">null</span></b><span style="font-family: "courier new"; font-size: 10pt;">;</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">public</span></b><span style="font-family: "courier new"; font-size: 10pt;"> FirstClient() {</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> Properties
initialProperties = </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">new</span></b><span style="font-family: "courier new"; font-size: 10pt;"> Properties();</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> initialProperties.put(InitialContext.</span><i><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">INITIAL_CONTEXT_FACTORY</span></i><span style="font-family: "courier new"; font-size: 10pt;">,<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><span style="color: #2a00ff; font-family: "courier new"; font-size: 10.0pt;">"org.exolab.jms.jndi.InitialContextFactory"</span><span style="font-family: "courier new"; font-size: 10pt;">);</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> initialProperties.put(InitialContext.</span><i><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">PROVIDER_URL</span></i><span style="font-family: "courier new"; font-size: 10pt;">, </span><span style="color: #2a00ff; font-family: "courier new"; font-size: 10.0pt;">"tcp://localhost:3035"</span><span style="font-family: "courier new"; font-size: 10pt;">);</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">try</span></b><span style="font-family: "courier new"; font-size: 10pt;"> {</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">context</span><span style="font-family: "courier new"; font-size: 10pt;"> = </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">new</span></b><span style="font-family: "courier new"; font-size: 10pt;">
InitialContext(initialProperties);</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">factory</span><span style="font-family: "courier new"; font-size: 10pt;"> = (<span style="background: silver; mso-highlight: silver;">TopicConnectionFactory</span>) </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">context</span><span style="font-family: "courier new"; font-size: 10pt;">.lookup(</span><span style="color: #2a00ff; font-family: "courier new"; font-size: 10.0pt;">"ConnectionFactory"</span><span style="font-family: "courier new"; font-size: 10pt;">);</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">topic</span><span style="font-family: "courier new"; font-size: 10pt;"> = (Topic) </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">context</span><span style="font-family: "courier new"; font-size: 10pt;">.lookup(</span><span style="color: #2a00ff; font-family: "courier new"; font-size: 10.0pt;">"topic1"</span><span style="font-family: "courier new"; font-size: 10pt;">);</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">connection</span><span style="font-family: "courier new"; font-size: 10pt;"> = </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">factory</span><span style="font-family: "courier new"; font-size: 10pt;">.createTopicConnection();</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">session</span><span style="font-family: "courier new"; font-size: 10pt;"> = </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">connection</span><span style="font-family: "courier new"; font-size: 10pt;">.createTopicSession(</span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">false</span></b><span style="font-family: "courier new"; font-size: 10pt;">, </span><span style="color: #3f7f5f; font-family: "courier new"; font-size: 10.0pt;">//Transacted </span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> TopicSession.</span><i><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">AUTO_ACKNOWLEDGE</span></i><span style="font-family: "courier new"; font-size: 10pt;">);</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">publisher</span><span style="font-family: "courier new"; font-size: 10pt;"> = </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">session</span><span style="font-family: "courier new"; font-size: 10pt;">.createPublisher(</span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">topic</span><span style="font-family: "courier new"; font-size: 10pt;">);</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> EventMessage
eventMessage = </span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">new</span></b><span style="font-family: "courier new"; font-size: 10pt;"> EventMessage(1, </span><span style="color: #2a00ff; font-family: "courier new"; font-size: 10.0pt;">"Message
from FirstClient"</span><span style="font-family: "courier new"; font-size: 10pt;">);</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> ObjectMessage
objectMessage = </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">session</span><span style="font-family: "courier new"; font-size: 10pt;">.createObjectMessage();</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> objectMessage.setObject(eventMessage);</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">connection</span><span style="font-family: "courier new"; font-size: 10pt;">.start();</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">publisher</span><span style="font-family: "courier new"; font-size: 10pt;">.publish(objectMessage);</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> System.</span><i><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">out</span></i><span style="font-family: "courier new"; font-size: 10pt;">.println(</span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">this</span></b><span style="font-family: "courier new"; font-size: 10pt;">.getClass().getName()+
</span><span style="color: #2a00ff; font-family: "courier new"; font-size: 10.0pt;">"
has sent a message : "</span><span style="font-family: "courier new"; font-size: 10pt;"> + eventMessage);</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">session</span><span style="font-family: "courier new"; font-size: 10pt;">.close();</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">connection</span><span style="font-family: "courier new"; font-size: 10pt;">.close();</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> </span><span style="color: #0000c0; font-family: "courier new"; font-size: 10.0pt;">context</span><span style="font-family: "courier new"; font-size: 10pt;">.close();</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> }
</span><b><span style="color: #7f0055; font-family: "courier new"; font-size: 10.0pt;">catch</span></b><span style="font-family: "courier new"; font-size: 10pt;"> (Exception e) {</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> }
</span><span style="font-family: "courier new"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: "courier new"; font-size: 10pt;">}</span><span style="color: #474747; font-family: "dejavu serif" , "serif"; font-size: 10.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 115%;">Synchronous</span></b> <b><span style="font-size: 14.0pt; line-height: 115%;">Messaging</span></b> <b><span style="font-size: 14.0pt; line-height: 115%;">and Asynchronous Messaging<o:p></o:p></span></b></div>
<div class="MsoNormal">
<span style="background: white; font-family: "georgia" , "serif"; font-size: 11.5pt; line-height: 115%;"><br /></span></div>
<div class="MsoNormal">
<span style="background: white; font-family: "georgia" , "serif"; font-size: 11.5pt; line-height: 115%;">In case of asynchronous consumption, the
consumer is implementing the MessageListener interface .So the overridden
onMessage() method gets the message. But in case of synchronous consumption,
the client is waiting to get the message since we used the receive() method of
the consumer.</span><o:p></o:p></div>
<div class="MsoNormal">
public interface <b>MessageListener</b><o:p></o:p></div>
<div class="MsoNormal" style="background: white; line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
A MessageListener object
is used to receive asynchronously delivered messages.<o:p></o:p></div>
<div class="MsoNormal" style="background: white; line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<br /></div>
<div class="MsoNormal" style="background: white; line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
Each session must ensure that it passes
messages serially to the listener. This means that a listener assigned to one
or more consumers of the same session can assume that the onMessage method
is not called with the next message until the session has completed the last
call.</div>
<div class="MsoNormal">
Implement MessageListener Interface for implement
Asynchronous Consumer.</div>
<table border="1" cellpadding="0" cellspacing="0" class="MsoNormalTable" style="border-top: none; border: solid #EEEEEE 1.0pt; mso-border-bottom-alt: solid #EEEEEE .75pt; mso-border-left-alt: solid #EEEEEE .75pt; mso-border-right-alt: solid #EEEEEE .75pt; mso-cellspacing: 0in; mso-padding-alt: 0in 0in 0in 0in; mso-yfti-tbllook: 1184; width: 783px;">
<tbody>
<tr>
<td nowrap="" style="background: #DEE3E9; border: none; padding: 6.0pt 2.25pt 2.25pt 5.25pt; width: 138.9pt;" valign="top" width="185"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #353833; font-family: "dejavu sans" , "sans-serif"; font-size: 10.0pt;">Modifier and Type<o:p></o:p></span></b></div>
</td>
<td style="background: #DEE3E9; border: none; padding: 6.0pt 2.25pt 2.25pt 5.25pt;" valign="top"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #353833; font-family: "dejavu sans" , "sans-serif"; font-size: 10.0pt;">Method and
Description<o:p></o:p></span></b></div>
</td>
</tr>
<tr>
<td nowrap="" style="background: white; border: none; padding: 6.0pt 0in 2.25pt 7.5pt; width: 138.9pt;" valign="top" width="185"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<span style="color: #353833; font-family: "dejavu sans mono"; font-size: 10.5pt;">void</span><span style="color: #353833; font-family: "dejavu sans" , "sans-serif"; font-size: 10.0pt;"><o:p></o:p></span></div>
</td>
<td style="background: white; border: none; padding: 6.0pt 0in 2.25pt 7.5pt; width: 433.5pt;" valign="top" width="578"><div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: .0001pt; margin-bottom: 0in;">
<b><span style="color: #353833; font-family: "dejavu sans mono"; font-size: 10.5pt;"><a href="https://docs.oracle.com/javaee/7/api/javax/jms/MessageListener.html#onMessage-javax.jms.Message-"><span style="color: #4a6782; text-decoration: none;">onMessage</span></a></span></b><span style="color: #353833; font-family: "dejavu sans mono"; font-size: 10.5pt;">(<a href="https://docs.oracle.com/javaee/7/api/javax/jms/Message.html" title="interface in javax.jms"><b><span style="color: #4a6782; text-decoration: none;">Message</span></b></a> message)</span><span style="color: #353833; font-family: "dejavu sans" , "sans-serif"; font-size: 10.0pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 14.7pt; margin-bottom: 1.5pt;">
<span style="color: #474747; font-family: "dejavu serif" , "serif"; font-size: 10.5pt;">Passes a
message to the listener.<o:p></o:p></span></div>
</td>
</tr>
</tbody></table>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><span style="font-size: 14.0pt; line-height: 115%;">JMS Reliablity Mechanisms-Message
persistence in JMS<o:p></o:p></span></b></div>
<div style="background: white; line-height: 18.3pt; margin-bottom: .0001pt; margin: 0in; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;"><br /></span></div>
<div style="background: white; line-height: 18.3pt; margin-bottom: .0001pt; margin: 0in; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">1)<strong style="font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; outline: 0px;"><u><span style="border: 1pt none windowtext; padding: 0in;"><span style="font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; outline: 0px;">Persistent delivery mode</span></span></u></strong><span class="apple-converted-space"> </span>–<span class="apple-converted-space"><u><span style="border: none windowtext 1.0pt; mso-border-alt: none windowtext 0in; padding: 0in;"><span style="font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; outline: 0px;"> </span></span></u></span><u><span style="border: none windowtext 1.0pt; mso-border-alt: none windowtext 0in; padding: 0in;">This is the default delivery mode</span></u></span>. It
forces the JMS provider to take extra care to avoid the loss of message in case
of failure. Message is persisted in secondary storage. When the provider comes
alive again message will be delivered to consumer. This ensures reliable
message delivery.<o:p></o:p></div>
<div style="background: white; line-height: 18.3pt; margin-bottom: .0001pt; margin: 0in; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">2)<b><span style="font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; outline: 0px;">Non-Persistent
delivery mode</span></b>– If we specify the delivery mode as non-persistent then the
provider is not taking extra effort to persist the message if a provider
failure occurs.<o:p></o:p></span></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<br /></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<b><span style="font-family: "calibri" , "sans-serif"; mso-ascii-theme-font: minor-latin; mso-bidi-font-size: 11.5pt; mso-hansi-theme-font: minor-latin;">By using the setDeliveryMode(int
value) method of MessageProducer interface .<o:p></o:p></span></b></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">DeliveryMode.PERSISTENT
=2<o:p></o:p></span></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">DeliveryMode.NON_PERSISTENT=1
.<o:p></o:p></span></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<span style="background: #f3f3f7; color: #575757; font-family: "courier new"; font-size: 11.5pt;">producer.setDeliveryMode(DeliveryMode.PERSISTENT);</span><span style="font-family: "calibri" , "sans-serif"; mso-ascii-theme-font: minor-latin; mso-bidi-font-size: 11.5pt; mso-hansi-theme-font: minor-latin;"><o:p></o:p></span></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<br /></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">Or Use the
overloaded send() or publish() method of MessageProducer interface .The second
argument in the method call specifies the delivery mode.<o:p></o:p></span></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<span style="background: #f3f3f7; color: #575757; font-family: "courier new"; font-size: 11.5pt;">producer.send(message, DeliveryMode.PERSISTENT);</span><o:p></o:p></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<br /></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<b><span style="font-family: "calibri" , "sans-serif"; font-size: 14.0pt;">Setting Message Priority Levels in JMS<o:p></o:p></span></b></div>
<div style="background: white; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -.25in; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;"><br /></span></div>
<div style="background: white; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">1.<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal;">
</span></span><!--[endif]--><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">Priority
levels – 0 to 9<o:p></o:p></span></div>
<div style="background: white; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">2.<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal;">
</span></span><!--[endif]--><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">Default
Priority Level – 4<o:p></o:p></span></div>
<div style="background: white; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">3.<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal;">
</span></span><!--[endif]--><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">Messages
having highest priority are delivered first.<o:p></o:p></span></div>
<div style="background: white; margin-left: .25in; mso-add-space: auto; mso-list: l1 level1 lfo2; text-indent: -.25in; vertical-align: baseline;">
<!--[if !supportLists]--><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">4.<span style="font-family: "times new roman"; font-size: 7pt; font-stretch: normal;">
</span></span><!--[endif]--><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">Setting
Message Priority<o:p></o:p></span></div>
<div style="background: white; margin-left: .25in; mso-add-space: auto; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">-By using
setPriority(int value) method of MessageProducer interface.
<o:p></o:p></span></div>
<div style="background: white; margin-left: .25in; mso-add-space: auto; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">-By using
the overloaded publish() method.The third argument will be the priority. <o:p></o:p></span></div>
<div style="background: white; margin-left: .25in; mso-add-space: auto; vertical-align: baseline;">
<span style="color: #353833; font-family: "calibri" , "sans-serif"; font-size: 11.0pt;"> void send(<a href="https://docs.oracle.com/javaee/7/api/javax/jms/Message.html" title="interface in javax.jms"><span style="color: #4a6782;">Message</span></a> message,
int deliveryMode, int priority, long timeToLive) throws <a href="https://docs.oracle.com/javaee/7/api/javax/jms/JMSException.html" title="class in javax.jms"><span style="color: #4a6782;">JMSException</span></a></span><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;"><o:p></o:p></span></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;"> topicPublisher.publish(message,
DeliveryMode.NON_PERSISTENT, 3,20000)<o:p></o:p></span></div>
<div style="background: white; margin-left: 1.0in; mso-add-space: auto; vertical-align: baseline;">
<b><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">message</span></b><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;"> - the
message to send<o:p></o:p></span></div>
<div style="background: white; margin-left: 1.0in; mso-add-space: auto; vertical-align: baseline;">
<b><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">deliveryMode</span></b><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;"> - the delivery mode to use<o:p></o:p></span></div>
<div style="background: white; margin-left: 1.0in; mso-add-space: auto; vertical-align: baseline;">
<b><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">priority</span></b><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;"> - the
priority for this message<o:p></o:p></span></div>
<div style="background: white; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 1.0in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; vertical-align: baseline;">
<b><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">timeToLive</span></b><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;"> - the message's lifetime (in milliseconds)<o:p></o:p></span></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<br /></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<b><span style="font-family: "calibri" , "sans-serif"; font-size: 14.0pt;">Message Expiry in JMS<o:p></o:p></span></b></div>
<pre style="line-height: 14.7pt;"><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">By default a message never expires.In some cases message will become obsolete after a particular time period. In such situation it is desirable to set expiration time . After the message expires, it will not be delivered.<o:p></o:p></span></pre>
<pre style="line-height: 14.7pt;"><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">We can set the expiration time in program in two ways.<o:p></o:p></span></pre>
<pre style="line-height: 14.7pt;"><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;"> </span></pre>
<pre style="line-height: 14.7pt;"><u><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">Using setTimeToLive() method of MessageProducer interface to set the expiry time of messages from that producer.</span></u><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;"><o:p></o:p></span></pre>
<pre style="line-height: 14.7pt;"><b><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">Example</span></b><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">:<b> topPublisher .setTimeToLive</b>(10000)<o:p></o:p></span></pre>
<pre style="line-height: 14.7pt;"><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">The above statement sets the expiry time 10000 milliseconds(10 seconds)<o:p></o:p></span></pre>
<pre style="line-height: 14.7pt;"><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;"> </span></pre>
<pre style="line-height: 14.7pt;"><u><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">Using the overridden method publish() of MessageProducer</span></u><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;"><o:p></o:p></span></pre>
<pre style="line-height: 14.7pt;"><b><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">Example</span></b><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;"> :<b>topPublisher.publish</b>(message, DeliveryMode.PERSISTENT, 3,10000)<o:p></o:p></span></pre>
<pre style="line-height: 14.7pt;"><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">The fourth argument gives the expiry time as 10000 milliseconds<o:p></o:p></span></pre>
<div style="background: white; line-height: 18.3pt; margin-bottom: .0001pt; margin: 0in; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">The
reliability mechanisms we discussed so far are :<o:p></o:p></span></div>
<div style="background: white; line-height: 18.3pt; margin-bottom: .0001pt; margin: 0in; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">1)<strong style="font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; outline: 0px;"><span style="border: 1pt none windowtext; padding: 0in;"><a href="http://www.coderpanda.com/jms-reliability-in-jms-message-persistence-in-jms/" style="font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; outline: 0px;" title="JMS Reliablity Mechanisms-Message persistence in JMS"><span style="color: windowtext;">Setting
message persistence</span></a></span></strong><o:p></o:p></span></div>
<div style="background: white; font-stretch: inherit; font-variant-numeric: inherit; line-height: 18.3pt; margin: 0in 0in 0.0001pt; outline: 0px; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">2)<a href="http://www.coderpanda.com/jms-reliablity-mechanisms-message-persistence-in-jms-setting-message-priority-levels-in-jms/" style="font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; outline: 0px;" title="JMS Reliablity Mechanisms-Setting Message Priority Levels in JMS"><strong style="font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: windowtext; padding: 0in;">Setting
Message Priority</span></strong></a><o:p></o:p></span></div>
<div style="background: white; font-stretch: inherit; font-variant-numeric: inherit; line-height: 18.3pt; margin: 0in 0in 0.0001pt; outline: 0px; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">3)<a href="http://www.coderpanda.com/jms-reliablity-mechanisms-message-expiry-in-jms/" style="font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; line-height: inherit; outline: 0px;" title="JMS Reliablity Mechanisms-Message Expiry in JMS"><strong style="font-size: inherit; font-stretch: inherit; font-style: inherit; font-variant: inherit; line-height: inherit; outline: 0px;"><span style="border: 1pt none windowtext; color: windowtext; padding: 0in;">Configuring
message expiry time</span></strong></a><o:p></o:p></span></div>
<pre style="line-height: 14.7pt;"><span style="font-family: "calibri" , "sans-serif"; font-size: 12.0pt;"> </span></pre>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<b><span style="font-family: "calibri" , "sans-serif"; font-size: 14.0pt;">Creating Durable Subscriptions in JMS<o:p></o:p></span></b></div>
<pre style="line-height: 14.7pt;"><span style="font-family: "calibri" , "sans-serif"; font-size: 12.0pt;">
</span></pre>
<pre style="line-height: 14.7pt;"><span style="font-family: "calibri" , "sans-serif"; font-size: 12.0pt;">This ensures message delivery to Subscriber, when it comes alive.<o:p></o:p></span></pre>
<pre style="line-height: 14.7pt;"><span style="font-family: "calibri" , "sans-serif"; font-size: 12.0pt;"> </span></pre>
<div style="line-height: 18.3pt; margin-bottom: 19.5pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; vertical-align: baseline;">
<span style="background: aqua; color: #575757; font-family: "courier new"; font-size: 11.0pt;">topic
= (Topic) context.lookup("topic1");<br />
connection = factory.createTopicConnection();<br />
session = connection.createTopicSession(false,TopicSession.AUTO_ACKNOWLEDGE);<br />
subscriber = session.createDurableSubscriber(topic,"sampleSubscription");<br />
// subscriber = session.createSubscriber(topic);<br />
connection.start();<br />
Message message = subscriber.receive();</span><span style="color: #575757; font-family: "courier new"; font-size: 11.0pt;"><o:p></o:p></span></div>
<div style="line-height: 18.3pt; margin-bottom: .0001pt; margin: 0in; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">A durable subscriber can have only one active subscriber at a
time.<o:p></o:p></span></div>
<div style="line-height: 18.3pt; margin-bottom: .0001pt; margin: 0in; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">A durable subscriber
registers a durable subscription with a unique identity (“</span><span style="background: aqua; color: #575757; font-family: "courier new"; font-size: 11.0pt;">sampleSubscription</span><span style="color: #575757; font-family: "courier new"; font-size: 11.0pt;">” </span><span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">in above example). Subsequent
subscribers with the same identity will resume the subscription in the state
where the previous subscriber was left.<o:p></o:p></span></div>
<div style="line-height: 18.3pt; margin-bottom: .0001pt; margin: 0in; vertical-align: baseline;">
<span style="font-family: "calibri" , "sans-serif"; font-size: 11.0pt;">If there is no active subscriber, then the JMS provider keeps
the messages till they are received by any subscriber or till the message
expires.<o:p></o:p></span></div>
<pre style="line-height: 14.7pt;"><span style="font-family: "calibri" , "sans-serif"; font-size: 12.0pt;"> </span></pre>
<pre style="line-height: 14.7pt;"><span style="font-family: "calibri" , "sans-serif"; font-size: 12.0pt;"> </span></pre>
<div style="background: white; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 0in; margin-top: 0in; mso-add-space: auto; text-indent: .5in; vertical-align: baseline;">
<br /></div>
<div style="background: white; margin-bottom: .0001pt; margin: 0in; mso-add-space: auto; vertical-align: baseline;">
<br /></div>
<br />
<div class="MsoNormal">
<br /></div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-68685665665829170762016-05-02T19:07:00.000-07:002016-06-18T23:54:12.805-07:00Hadoop - Practicing HDFS Basic Commands<b>notroot@ubuntu:~$ hadoop</b><br />
<span style="font-size: x-small;">Usage: hadoop [--config confdir] COMMAND</span><br />
<span style="font-size: x-small;">where COMMAND is one of:</span><br />
<span style="font-size: x-small;"> namenode -format format the DFS filesystem</span><br />
<span style="font-size: x-small;"> secondarynamenode run the DFS secondary namenode</span><br />
<span style="font-size: x-small;"> namenode run the DFS namenode</span><br />
<span style="font-size: x-small;"> datanode run a DFS datanode</span><br />
<span style="font-size: x-small;"> dfsadmin run a DFS admin client</span><br />
<span style="font-size: x-small;"> mradmin run a Map-Reduce admin client</span><br />
<span style="font-size: x-small;"> fsck run a DFS filesystem checking utility</span><br />
<span style="font-size: x-small;"> fs run a generic filesystem user client</span><br />
<span style="font-size: x-small;"> balancer run a cluster balancing utility</span><br />
<span style="font-size: x-small;"> fetchdt fetch a delegation token from the NameNode</span><br />
<span style="font-size: x-small;"> jobtracker run the MapReduce job Tracker node</span><br />
<span style="font-size: x-small;"> pipes run a Pipes job</span><br />
<span style="font-size: x-small;"> tasktracker run a MapReduce task Tracker node</span><br />
<span style="font-size: x-small;"> historyserver run job history servers as a standalone daemon</span><br />
<span style="font-size: x-small;"> job manipulate MapReduce jobs</span><br />
<span style="font-size: x-small;"> queue get information regarding JobQueues</span><br />
<span style="font-size: x-small;"> version print the version</span><br />
<span style="font-size: x-small;"> jar <jar> run a jar file</jar></span><br />
<span style="font-size: x-small;"> distcp <srcurl> <desturl> copy file or directories recursively</desturl></srcurl></span><br />
<span style="font-size: x-small;"> archive -archiveName NAME -p <parent path=""> <src>* <dest> create a hadoop archi ve</dest></src></parent></span><br />
<span style="font-size: x-small;"> classpath prints the class path needed to get the</span><br />
<span style="font-size: x-small;"> Hadoop jar and the required libraries</span><br />
<span style="font-size: x-small;"> daemonlog get/set the log level for each daemon</span><br />
<span style="font-size: x-small;"> or</span><br />
<span style="font-size: x-small;"> CLASSNAME run the class named CLASSNAME</span><br />
<span style="font-size: x-small;">Most commands print help when invoked w/o parameters.</span><br />
<br />
<div style="background-color: white; font-family: Verdana, Helvetica, Arial, sans-serif; font-size: 12px; line-height: 1.3em;">
<b>balancer </b>- Runs a cluster balancing utility. An administrator can simply press Ctrl-C to stop the rebalancing process. See <a href="http://hadoop.apache.org/docs/current/hadoop-project-dist/hadoop-hdfs/HdfsUserGuide.html#Balancer" style="color: #6688aa; text-decoration: none;">Balancer</a> for more details.</div>
<div>
<br /></div>
<b>notroot@ubuntu:~$ hadoop balancer</b><br />
<span style="font-size: x-small;">16/05/03 01:07:11 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 0 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:07:12 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 1 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:07:13 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 2 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:07:14 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 3 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:07:15 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 4 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:07:16 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 5 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:07:17 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 6 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:07:18 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 7 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:07:19 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 8 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:07:20 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 9 time(s).</span><br />
<span style="font-size: x-small;">Received an IO exception: Call to localhost/127.0.0.1:8020 failed on connection exception: java.net.ConnectException: Connection refused . Exiting...</span><br />
<span style="font-size: x-small;">Balancing took 11.778 seconds</span><br />
<span style="font-size: x-small;"><br /></span>
<b>notroot@ubuntu:~$ hadoop version</b><br />
<span style="font-size: x-small;">Hadoop 1.0.3</span><br />
<span style="font-size: x-small;">Subversion https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.0 -r 1335192</span><br />
<span style="font-size: x-small;">Compiled by hortonfo on Tue May 8 20:31:25 UTC 2012</span><br />
<span style="font-size: x-small;">From source with checksum e6b0c1e23dcf76907c5fecb4b832f3be</span><br />
<span style="font-size: x-small;"><br /></span>
<b>notroot@ubuntu:~$ hadoop fs -ls hdfs:/</b><br />
<span style="font-size: x-small;">16/05/03 01:08:44 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 0 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:08:45 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 1 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:08:46 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 2 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:08:47 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 3 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:08:48 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 4 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:08:49 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 5 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:08:50 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 6 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:08:51 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 7 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:08:52 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 8 time(s).</span><br />
<span style="font-size: x-small;">16/05/03 01:08:53 INFO ipc.Client: Retrying connect to server: localhost/127.0.0 .1:8020. Already tried 9 time(s).</span><br />
<span style="font-size: x-small;">Bad connection to FS. command aborted. exception: Call to localhost/127.0.0.1:80 20 failed on connection exception: java.net.ConnectException: Connection refused</span><br />
<br />
<b>notroot@ubuntu:~$ start-all.sh</b><br />
<span style="font-size: x-small;">starting namenode, logging to /home/notroot/lab/software/hadoop-1.0.3/libexec/.. /logs/hadoop-notroot-namenode-ubuntu.out</span><br />
<span style="font-size: x-small;">localhost: starting datanode, logging to /home/notroot/lab/software/hadoop-1.0.3 /libexec/../logs/hadoop-notroot-datanode-ubuntu.out</span><br />
<span style="font-size: x-small;">localhost: starting secondarynamenode, logging to /home/notroot/lab/software/had oop-1.0.3/libexec/../logs/hadoop-notroot-secondarynamenode-ubuntu.out</span><br />
<span style="font-size: x-small;">starting jobtracker, logging to /home/notroot/lab/software/hadoop-1.0.3/libexec/ ../logs/hadoop-notroot-jobtracker-ubuntu.out</span><br />
<span style="font-size: x-small;">localhost: starting tasktracker, logging to /home/notroot/lab/software/hadoop-1. 0.3/libexec/../logs/hadoop-notroot-tasktracker-ubuntu.out</span><br />
<span style="font-size: x-small;"><br /></span>
<b>notroot@ubuntu:~$ jps</b><br />
<span style="font-size: x-small;">3248 DataNode</span><br />
<span style="font-size: x-small;">3016 NameNode</span><br />
<span style="font-size: x-small;">3479 SecondaryNameNode</span><br />
<span style="font-size: x-small;">3910 Jps</span><br />
<span style="font-size: x-small;">3804 TaskTracker</span><br />
<span style="font-size: x-small;">3560 JobTracker</span><br />
<br />
<b>notroot@ubuntu:~$ hadoop fs -ls hdfs:/</b><br />
<span style="font-size: x-small;">Found 1 items</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-01 07:24 /home</span><br />
<span style="font-size: x-small;"><br /></span>
<br />
<b>notroot@ubuntu:~$ hadoop fsck - /</b><br />
<span style="font-size: x-small;">FSCK started by notroot from /127.0.0.1 for path / at Tue May 03 01:22:23 UTC 20 16</span><br />
<span style="font-size: x-small;">.Status: HEALTHY</span><br />
<span style="font-size: x-small;"> Total size: 4 B</span><br />
<span style="font-size: x-small;"> Total dirs: 6</span><br />
<span style="font-size: x-small;"> Total files: 1</span><br />
<span style="font-size: x-small;"> Total blocks (validated): 1 (avg. block size 4 B)</span><br />
<span style="font-size: x-small;"> Minimally replicated blocks: 1 (100.0 %)</span><br />
<span style="font-size: x-small;"> Over-replicated blocks: 0 (0.0 %)</span><br />
<span style="font-size: x-small;"> Under-replicated blocks: 0 (0.0 %)</span><br />
<span style="font-size: x-small;"> Mis-replicated blocks: 0 (0.0 %)</span><br />
<span style="font-size: x-small;"> Default replication factor: 1</span><br />
<span style="font-size: x-small;"> Average block replication: 1.0</span><br />
<span style="font-size: x-small;"> Corrupt blocks: 0</span><br />
<span style="font-size: x-small;"> Missing replicas: 0 (0.0 %)</span><br />
<span style="font-size: x-small;"> Number of data-nodes: 1</span><br />
<span style="font-size: x-small;"> Number of racks: 1</span><br />
<span style="font-size: x-small;">FSCK ended at Tue May 03 01:22:23 UTC 2016 in 10 milliseconds</span><br />
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;">The filesystem under path '/' is HEALTHY</span><br />
<span style="font-size: x-small;"><br /></span>
<b>notroot@ubuntu:~$ hadoop version</b><br />
<span style="font-size: x-small;">Hadoop 1.0.3</span><br />
<span style="font-size: x-small;">Subversion https://svn.apache.org/repos/asf/hadoop/common/branches/branch-1.0 -r 1335192</span><br />
<span style="font-size: x-small;">Compiled by hortonfo on Tue May 8 20:31:25 UTC 2012</span><br />
<span style="font-size: x-small;">From source with checksum e6b0c1e23dcf76907c5fecb4b832f3be</span><br />
<br />
<b>notroot@ubuntu:~$ hadoop balancer</b><br />
<span style="font-size: x-small;">Time Stamp Iteration# Bytes Already Moved Bytes Left To Move Bytes Being Moved</span><br />
<span style="font-size: x-small;">16/05/03 01:23:35 INFO net.NetworkTopology: Adding a new node: /default-rack/127.0.0.1:50010</span><br />
<span style="font-size: x-small;">16/05/03 01:23:35 INFO balancer.Balancer: 0 over utilized nodes:</span><br />
<span style="font-size: x-small;">16/05/03 01:23:35 INFO balancer.Balancer: 1 under utilized nodes: 127.0.0.1:50010</span><br />
<span style="font-size: x-small;">The cluster is balanced. Exiting...</span><br />
<span style="font-size: x-small;">Balancing took 2.405 seconds</span><br />
<br />
<b>notroot@ubuntu:~$ hadoop balancer</b><br />
<span style="font-size: x-small;">Time Stamp Iteration# Bytes Already Moved Bytes Left To Move Bytes Being Moved</span><br />
<span style="font-size: x-small;">16/05/03 01:23:50 INFO net.NetworkTopology: Adding a new node: /default-rack/127.0.0.1:50010</span><br />
<span style="font-size: x-small;">16/05/03 01:23:50 INFO balancer.Balancer: 0 over utilized nodes:</span><br />
<span style="font-size: x-small;">16/05/03 01:23:50 INFO balancer.Balancer: 1 under utilized nodes: 127.0.0.1:50010</span><br />
<span style="font-size: x-small;">The cluster is balanced. Exiting...</span><br />
<span style="font-size: x-small;">Balancing took 2.32 seconds</span><br />
<br />
<b>notroot@ubuntu:~$ hadoop fs -ls /</b><br />
<span style="font-size: x-small;">Found 2 items</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-01 07:24 /home</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:23 /system</span><br />
<span style="font-size: x-small;"><br /></span>
<b>notroot@ubuntu:~$ hadoop fs -ls /default-rack</b><br />
<span style="font-size: x-small;">ls: Cannot access /default-rack: No such file or directory.</span><br />
<br />
<br />
<b>notroot@ubuntu:~$ hadoop fs -ls /default-rack/127.0.0.1:50010</b><br />
<span style="font-size: x-small;">ls: java.net.URISyntaxException: Relative path in absolute URI: 127.0.0.1:50010</span><br />
<span style="font-size: x-small;">Usage: java FsShell [-ls <path>]</path></span><br />
<br />
<b>notroot@ubuntu:~$ hadoop fs -ls hdfs:/</b><br />
<span style="font-size: x-small;">Found 2 items</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-01 07:24 /home</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:23 /system</span><br />
<br />
<b>notroot@ubuntu:~$ hadoop fs -count hdfs:/</b><br />
<span style="font-size: x-small;"> 7 1 4 hdfs://localhost:8020/</span><br />
<br />
<b>notroot@ubuntu:~$ hadoop fs -ls hdfs:/</b><br />
<span style="font-size: x-small;">Found 2 items</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-01 07:24 /home</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:23 /system</span><br />
<br />
<b>notroot@ubuntu:~$ hadoop fs -ls hdfs:/home</b><br />
<span style="font-size: x-small;">Found 1 items</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-01 07:24 /home/notroot</span><br />
<br />
<b>notroot@ubuntu:~$ hadoop fs -ls hdfs:/home/notroot</b><br />
<span style="font-size: x-small;">Found 1 items</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-01 07:24 /home/notroot/lab</span><br />
<br />
<b>notroot@ubuntu:~$ hadoop fs -ls hdfs:/home/notroot/lab</b><br />
<span style="font-size: x-small;">Found 1 items</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:22 /home/notroot/lab/mapred</span><br />
<br />
<b>notroot@ubuntu:~$ hadoop fs -ls hdfs:/home/notroot/lab/mapred</b><br />
<span style="font-size: x-small;">Found 1 items</span><br />
<span style="font-size: x-small;">drwx------ - notroot supergroup 0 2016-05-03 01:22 /home/notroot/lab/mapred/system</span><br />
<br />
<b>notroot@ubuntu:~$ hadoop fs -ls hdfs:/home/notroot/lab/mapred/system</b><br />
<span style="font-size: x-small;">Found 1 items</span><br />
<span style="font-size: x-small;">-rw------- 1 notroot supergroup 4 2016-05-03 01:22 /home/notroot/lab/mapred/system/jobtracker.info</span><br />
<br />
<b>notroot@ubuntu:~$ hadoop fs -ls hdfs:/home/notroot/lab/mapred</b><br />
<span style="font-size: x-small;">Found 1 items</span><br />
<span style="font-size: x-small;">drwx------ - notroot supergroup 0 2016-05-03 01:22 /home/notroot/lab/mapred/system</span><br />
<br />
<b>notroot@ubuntu:~$ hadoop fs -ls hdfs:/</b><br />
<span style="font-size: x-small;">Found 2 items</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-01 07:24 /home</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:23 /system</span><br />
<br />
<b>notroot@ubuntu:~$ hadoop fs -ls hdfs:/system</b><br />
<br />
<b>notroot@ubuntu:~$ ls -lt</b><br />
<span style="font-size: x-small;">total 7608</span><br />
<span style="font-size: x-small;">drwxrwxr-x 2 notroot notroot 4096 May 1 11:14 sanjeev</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 7772980 Apr 26 18:07 latest.tar.gz</span><br />
<span style="font-size: x-small;">drwxrwxr-x 3 notroot notroot 4096 Nov 12 2012 downloads</span><br />
<span style="font-size: x-small;">drwxrwxr-x 7 notroot notroot 4096 Sep 26 2012 lab</span><br />
<span style="font-size: x-small;">drwxrwxr-x 4 notroot notroot 4096 Sep 26 2012 backup</span><br />
<br />
<b>notroot@ubuntu:~$ cd sanjeev/</b><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ ls</b><br />
<span style="font-size: x-small;">sample sample1</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ cd ..</b><br />
<br />
<b>notroot@ubuntu:~$ ls -h -lrt</b><br />
<span style="font-size: x-small;">total 7.5M</span><br />
<span style="font-size: x-small;">drwxrwxr-x 4 notroot notroot 4.0K Sep 26 2012 backup</span><br />
<span style="font-size: x-small;">drwxrwxr-x 7 notroot notroot 4.0K Sep 26 2012 lab</span><br />
<span style="font-size: x-small;">drwxrwxr-x 3 notroot notroot 4.0K Nov 12 2012 downloads</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 7.5M Apr 26 18:07 latest.tar.gz</span><br />
<span style="font-size: x-small;">drwxrwxr-x 2 notroot notroot 4.0K May 1 11:14 sanjeev</span><br />
<br />
<b>notroot@ubuntu:~$ rm latest.tar.gz</b><br />
<br />
<b>notroot@ubuntu:~$ cd lab</b><br />
<br />
<b>notroot@ubuntu:~/lab$ ls</b><br />
<span style="font-size: x-small;">data hdfs mapred programs software</span><br />
<br />
<b>notroot@ubuntu:~/lab$ cd data/</b><br />
<br />
<b>notroot@ubuntu:~/lab/data$ ls -lrt</b><br />
<span style="font-size: x-small;">total 174832</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 81468050 Jan 10 2012 weblogs</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 88328787 May 25 2012 txns</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 391355 Jun 9 2012 custs</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 8828133 Jun 10 2012 txntab</span><br />
<span style="font-size: x-small;">drwxrwxr-x 2 notroot notroot 4096 Sep 5 2012 images</span><br />
<br />
<b>notroot@ubuntu:~/lab/data$ cd ..</b><br />
<br />
<b>notroot@ubuntu:~/lab$ ls</b><br />
<span style="font-size: x-small;">data hdfs mapred programs software</span><br />
<br />
<b>notroot@ubuntu:~/lab$ cd ..</b><br />
<br />
<b>notroot@ubuntu:~$ pwd</b><br />
<span style="font-size: x-small;">/home/notroot</span><br />
<br />
<b>notroot@ubuntu:~$ cd sanjeev</b><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ ls</b><br />
<span style="font-size: x-small;">googleroundtable.mp4 sample sample1</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ ls -lt</b><br />
<span style="font-size: x-small;">total 122812</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 175 May 1 11:15 sample1</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 136 May 1 11:09 sample</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 125744560 Apr 14 2014 googleroundtable.mp4</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ ls -lt -h</b><br />
<span style="font-size: x-small;">total 120M</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 175 May 1 11:15 sample1</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 136 May 1 11:09 sample</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 120M Apr 14 2014 googleroundtable.mp4</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -put googleroundtable.mp4 hdfs:/</b><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -ls hdfs:/</b><br />
<span style="font-size: x-small;">Found 3 items</span><br />
<span style="font-size: x-small;">-rw-r--r-- 1 notroot supergroup 125744560 2016-05-03 01:37 /googleroundtable.mp4</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-01 07:24 /home</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:23 /system</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -ls hdfs:/home</b><br />
<span style="font-size: x-small;">Found 1 items</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-01 07:24 /home/notroot</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -mkdir hdfs:/home/sanjeev</b><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -mv hdfs:/googleroundtable.mp4 hdfs:/sanjeev/</b><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -ls hdfs:/sanjeev</b><br />
<span style="font-size: x-small;">Found 1 items</span><br />
<span style="font-size: x-small;">-rw-r--r-- 1 notroot supergroup 125744560 2016-05-03 01:37 /sanjeev</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -ls hdfs:/</b><br />
<span style="font-size: x-small;">Found 3 items</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:39 /home</span><br />
<span style="font-size: x-small;">-rw-r--r-- 1 notroot supergroup 125744560 2016-05-03 01:37 /sanjeev</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:23 /system</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -rm hdfs:/sanjeev</b><br />
<span style="font-size: x-small;">Deleted hdfs://localhost:8020/sanjeev</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -put googleroundtable.mp4 hdfs:/</b><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -ls hdfs:/</b><br />
<span style="font-size: x-small;">Found 3 items</span><br />
<span style="font-size: x-small;">-rw-r--r-- 1 notroot supergroup 125744560 2016-05-03 01:42 /googleroundtable.mp4</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:39 /home</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:23 /system</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -mkdir hdfs:/sanjeev</b><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -ls hdfs:/</b><br />
<span style="font-size: x-small;">Found 4 items</span><br />
<span style="font-size: x-small;">-rw-r--r-- 1 notroot supergroup 125744560 2016-05-03 01:42 /googleroundtable.mp4</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:39 /home</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:42 /sanjeev</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:23 /system</span><br />
<span style="font-size: x-small;"><br /></span>
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -mv hdfs:/googleroundtable.mp4 hdfs:/sanjeev/googleroundtable.mp4</b><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -ls hdfs:/</b><br />
<span style="font-size: x-small;">Found 3 items</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:39 /home</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:43 /sanjeev</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:23 /system</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -ls hdfs:/sanjeev</b><br />
<span style="font-size: x-small;">Found 1 items</span><br />
<span style="font-size: x-small;">-rw-r--r-- 1 notroot supergroup 125744560 2016-05-03 01:42 /sanjeev/googleroundtable.mp4</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -cp hdfs:/sanjeev/googleroundtable.mp4 hdfs:/googlemapred.mp4</b><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -ls hdfs:/sanjeev</b><br />
<span style="font-size: x-small;">Found 1 items</span><br />
<span style="font-size: x-small;">-rw-r--r-- 1 notroot supergroup 125744560 2016-05-03 01:42 /sanjeev/googleroundtable.mp4</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -ls hdfs:/</b><br />
<span style="font-size: x-small;">Found 4 items</span><br />
<span style="font-size: x-small;">-rw-r--r-- 1 notroot supergroup 125744560 2016-05-03 01:44 /googlemapred.mp4</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:39 /home</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:43 /sanjeev</span><br />
<span style="font-size: x-small;">drwxr-xr-x - notroot supergroup 0 2016-05-03 01:23 /system</span><br />
<span style="font-size: x-small;"><br /></span>
<b>notroot@ubuntu:~/sanjeev$ hadoop dfs -copyToLocal hdfs:/googlemapred.mp4 .</b><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ ls -lt</b><br />
<span style="font-size: x-small;">total 245612</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 125744560 May 3 01:46 googlemapred.mp4</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 175 May 1 11:15 sample1</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 136 May 1 11:09 sample</span><br />
<span style="font-size: x-small;">-rw-rw-r-- 1 notroot notroot 125744560 Apr 14 2014 googleroundtable.mp4</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop fs -copyFromLocal sample hdfs:/sanjeev</b><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop fs -ls hdfs:/sanjeev</b><br />
<span style="font-size: x-small;">Found 2 items</span><br />
<span style="font-size: x-small;">-rw-r--r-- 1 notroot supergroup 125744560 2016-05-03 01:42 /sanjeev/googleroundtable.mp4</span><br />
<span style="font-size: x-small;">-rw-r--r-- 1 notroot supergroup 136 2016-05-03 01:53 /sanjeev/sample</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop fs -ls hdfs:/sanjeev/sample</b><br />
<span style="font-size: x-small;">Found 1 items</span><br />
<span style="font-size: x-small;">-rw-r--r-- 1 notroot supergroup 136 2016-05-03 01:53 /sanjeev/sample</span><br />
<br />
<b>notroot@ubuntu:~/sanjeev$ hadoop fs -cat hdfs:/sanjeev/sample</b><br />
<span style="font-size: x-small;">this is my test file</span><br />
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;">i m learing hadoop</span><br />
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;">its workong on vmware</span><br />
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;">ubantu is on top of vmaware</span><br />
<span style="font-size: x-small;"><br /></span>
<span style="font-size: x-small;">this is 2nd day class revision..</span><br />
<div>
<br /></div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-67469016493324028972015-08-16T12:16:00.002-07:002015-08-25T09:08:09.903-07:00Mongo DB - Introduction<b><u>mongo db</u></b><br />
<br />
<ol>
<li>no support for joins</li>
<li>no support for transactions </li>
<li>is schemaless</li>
<li>across multiple collections</li>
<li>data stored in documents </li>
</ol>
<br />
<br />
To Retain Scalability, MongoDB<br />
1. dont support joins,<br />
2. don't support transaction management - Docs are hierarchical, so docs can be accessed automically<br />
<div>
<br /></div>
<div>
scalability and Functionality<br />
High Performance</div>
<div>
<br /></div>
<div>
<br /></div>
supports documents in same context having different structure<br />
<br />
Mongo DB - non-relational json document store<br />
<br />
{'firstname':'Andrew',<br />
'lastname':'ericson',<br />
'hobbies':['cycling', 'golf', 'photography']}<br />
<br />
<u>mongo shell</u><br />
<br />
use test --- to database test<br />
db.things.save({a:1, b:2}) --save a row<br />
<br />
db.things.find() --find all document records of things documents<br />
<br />
db.things.save({a:2, b:3, d:4}) --save another row<br />
<br />
db.things.find({a:1}) --finds first record<br />
<br />
Easy to program because it stored in JSON<br />
<div>
<br /></div>
<u>JSON - </u>www.json.org<br />
<div>
array: list of things [...] [red,green]</div>
Dictonary : maps {key:val,} {a:b, c:d}<br />
<div>
<br /></div>
<div>
Top level in document has to be distionary</div>
{fruid:[apple, pear, manogoe]}<br />
<br />
<br />
db.user({'name':'andrew', 'city':'london'})<br />
<br />
Changing schema of a document:<br />
var j=db.user.findOne({'name':'andrew'})<br />
j.city='paris'<br />
db.user.save()<br />
<br />
allowed size of doc - 16mb<br />
<br />
restore command - mongodump mongorestore<br />
connect with shell - mongo<br />
<br />
<u>findOne Command</u><br />
<br />
{"name":"andrew"}<br />
{"a":4, "b":5, "c":7}<br />
{a:6, b:7, fruit:["apple", "pear", banana"]}<br />
<br />
<br />
<br />
<u>Connecting MongoDB</u><br />
MongoShell<->MongoDB<!-----><!-----><!-----><!-----></-><br />
<br />
Java Code<br />
->SparkJava<br />
->FreeMarker -MVC<br />
MongoJava Driver ->TCP Connection to MongoD<br />
Port - 80, 8082<br />
<br />
<u>MongoShell</u><br />
start mongo shell<br />
mongo<br />
>use test<br />
switch to db test<br />
>db.things.save({a:1, b:2, c:3})<br />
saved in collection things<br />
>db.things.find()<br />
will return 1 document<br />
>db.things.save({a:3, b:4, c:6, d:200})<br />
>db.things.find()<br />
will return two documents<br />
>db.things.find({a:1})<br />
>db.things.save({a:3, b:4, c:6, d:{k:200}})<br />
>db.things.find.preety()<br />
<br />
<u>Mongo DB Operations comparison</u><br />
<b>Ops - Mongo - SQL</b><br />
Create - Insert - Insert<br />
Read - Find - Select<br />
Update - Update - Update<br />
Delete - Remove - Delete<br />
<br />
$mongo - open mongo shell, connects with db and display version of mongodb<br />
->mongo shell is interactive javascript interpretor<br />
<br />
-mongoshell contains doskey, up arrow, down arrow key, left arrow and right arrow key for editing<br />
use tab to autocomplete the token in mongoshell<br />
<br />
z={a:1}<br />
z.a will return 1<br />
z["a"] will return 1<br />
difference in above is in z.a, a is not considered literal, i.e.<br />
if i say w="a"<br />
then z[w] will return 1 but not in the case of using dot (.) notation. reason is dot(.) notation look for reference or member variable in an object, but the square [] notation treats object more as a pirce of data or dictionary<br />
<br />
<u>BSON - binary JSON - Contains all datatypes of JSON</u><br />
NumberInt(1)<br />
NumberLong(1)<br />
new Date() -> ISODate("2012-10-21T17:41:51.398Z")<br />
<br />
use above constructor syntaxes to create objects of number, date etc.<br />
<br />
<u>Inserting documents in MongoDB</u><br />
doc={"name":"smith", "Age":30}<br />
db.people.insert(doc)<br />
db.people.find()<br />
above row will be returned.<br />
All documents insterted in mongodb will have an id, "_id" primary key is unique. This value is immutable, it cannot be changed.<br />
<br />
<u>findOne()</u><br />
db.people.findOne() - selects a random document from the collection people.<br />
<br />
db.people.findOne({"name":"Jones"})<br />
selects a document having value of name field as "Jones"<br />
<br />
second argument can be used to specify which field will be returned from database.<br />
db.people.findOne({"name":"Jones"}, {"name":<b>true</b>, "_id":<b>false</b>})<br />
->{"name":"Jones"}<br />
if we don't say "_id":false, it will be returned from DB as default behavior.<br />
<br />
<u>find()</u><br />
inserting records using a loop<br />
<br />
for(i=0; i<1000 db.scores.insert="" essay="" exam="" for="" i="" j="" names="" quiz="" score="Math.round(Math.random()*100});}}</p" student="" type=""><br />
3000 rows will be inserted.<br />
<br />
db.scores.find() - will return 3000 records, but page wise, 20 records per page. type "it" for iterating to next page.<br />
<br />
getting formatted output - use <u>pretty() </u>function<br />
<br />
db.scores.find().pretty()<br />
<br /><u>
Querying using selection</u><br />
<br />
using AND operation<br />
db.scores.find({student:19, type:"essay"})<br />
will select the rows having student id 19 and type essay<br />
<br />
<u>$gt and $lt opearator</u><br />
db.scores.find({score:{$gt:95}})<br />
will return all records having score value greater than 95<br />
<br />
db.scores.find({score:{$gt:95}, type:"essay"})<br />
will return all records having score value greater than 95 and type is equal to "essay"<br />
<br /><u>
putting more constraints on score</u><br /><!--1000--><!--1000--></1000><br />
db.scores.find({score:{$gt:95, $lte:98})<br />
$lte means less than or equal to<br />
$gt means greater than<br />
<!--1000--><br />
<br />
<u>inequality comparison</u><br />
db.people.find({name:{$lt:"D"}});<br />
will return all the names starting from A, B or C.<br />
<br />
db.people.find({name:{$lt:"D", $gt:"B"}});<br />
will return all the names starting from B, or C.<br />
<br />
db.people.insert({name:42});<br />
db.people.find({name:{$lt:"D", $gt:"B"}});<br />
will not select the record having name=42.<br />
<br />
Mogodb allows to query based on structure of document and type of values in document<br />
For exmaple<br />
{"name":"Smith", "age":30, "profession":"hacker"}<br />
{"name":"Jones", "age":35, "profession":"baker"}<br />
{"name":"Alice"}<br />
{"name":"Bob"}<br />
{"name":42}<br />
find all the records having field profession<br />
db.people.find({profession:{$exists:true}});<br />
<br />
below records will be selected<br />
{"name":"Smith", "age":30, "profession":"hacker"}<br />
{"name":"Jones", "age":35, "profession":"baker"}<br />
<br />
find all the records having field profession<br />
db.people.find({profession:{$exists:false}});<br />
will select all records not have profession field value<br />
<br />
<u>type based selection</u><br />
<br />
for selecting records having value of name field as string<br />
db.people.find({name:{$type:2}})<br />
type:2 is for String as per BSON Specs.<br />
<br />
<u>$regex</u><br />
Find all rows field name having value containing "a"<br />
db.people.find({name:{$regex:"a"}});<br />
<br />
Find all rows field name having value containing "e" as last letter<br />
db.people.find({name:{$regex:"e$"}});<br />
<br />
Find all rows field name field start with "A"<br />
db.people.find({name:{$regex:"^A"}});<br />
<br />
<u>$or</u><br />
$or operator is used as key and value is a array of conditions<br />
db..people.find({$or:[name:{$regex:"e$"}}, {age:{$exists:true}}]};<br />
find all rows having name ending with "e" or all rows containing age attribute.<br />
<br />
<u>$and</u><br />
db.people.find({$and:[name:{$regex:"e$"}}, {age:{$exists:true}}]};<br />
<br />
Querying inside arrays<br />
Arrays can be queried at the top level<br />
<br />
db.account.insert({name:"Howard", favouriutes:["pretzels", "beer"]});<br />
<br />
db.accounts.find({favourites:"pretzels"});<br />
<br />
Which of the following documents would be returned by this query?<br />
db.products.find( { tags : "shiny" } );<br />
{ _id : 42 , name : "Whizzy Wiz-o-matic", tags : [ "awesome", "shiny" , "green" ] }<br />
{ _id : 1040 , name : "Snappy Snap-o-lux", tags : "shiny" }<br />
<br />
<br />
db.accounts.find().pretty(); -display in a format<br />
<br />
{name:"Howard", favourites:["pretzels", "beer"]}<br />
{name:"Irving", favourites:["pretzels", "beer", "cheese"]}<br />
<br />
<u>$all </u>- Finding all rows which contain all elements of the given array in filtr, for ex<br />
db.accounts.find({favourites:{$all:[""pretzels", "beer"]}});<br />
will display both above records because both records contain "pretzels" and "beer"<br />
<br />
<u>$in </u>- Finding all rows which contain any of the elements of the given array in filter, for ex<br />
db.accounts.find({favourites:{$in:[""pretzels", "beer"]}});<br />
<br />
<br />
<u>Querying nested docs with dot notation</u><br />
<br />
{name:"richard", email:{work:"richard@10gen.com", personal:"kreuter@example.com"}}<br />
<br />
db.users.find({email:{work:"richard@10gen.com", personal:"kreuter@example.com"}})<br />
<br />
this will return above record, by byte by byte comparison. but if you change the order of elements, query will not find the document<br />
for example:<br />
<br />
db.users.find({email:{personal:"kreuter@example.com", work:"richard@10gen.com"}})<br />
<br />
or below will also not work<br />
<br />
db.users.find({email:{work:"richard@10gen.com"}})<br />
<br />
how to query embeded fields<br />
db.users.find({"email.work":"richard@10gen.com"})<br />
<br />
this will return by looking the contents of embeded field email<br />
<br />
<u>Cursors</u>--<br />
cur=db.people.find();null;<br />
cur.hasNext() -> Return true<br />
cur.next() -> Return next row<br />
<br />
while(cur.hasNext())printJson(cur.next());<br />
<br />
impose limit<br />
<br />
cur.limit(5);null;<br />
<br />
cur.sort({name:-1}); null;->sort in reverse order<br />
<br />
cur.sort({name:-1}).limit(3); null; -> will not print top 3<br />
<br />
<br />
<u>counting results:</u><br />
db.scores.count({type:"exam"})<br />
<br />
return count of rews requrned from aboive query.<br />
<br />
<u>replacing data in DB</u><br />
<br />
db.people.update({name:"Smith"}, {name:"Thompson", salary:50000});<br />
<br />
First argument {namne:"Smith"} is where clause<br />
Second argument {name:"Thompson", salary:50000} is the new values updating the existing values of fields. It will discard the previous vlaues of the fields . for example<br />
<br />
> db.foo.insert({ "_id" : "Texas", "population" : 2500000, "land_locked" : 1 });<br />
WriteResult({ "nInserted" : 1 })<br />
> db.foo.update({_id:"Texas"},{population:30000000})<br />
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })<br />
> db.foo.find();<br />
{ "_id" : "Texas", "population" : 30000000 }<br />
<br />
<u>updating specific field of a collection using $set</u><br />
<div>
<div>
> db.foo.find({"_id" : "Poland"});</div>
<div>
{ "_id" : "Poland", "population" : 2500000, "land_locked" : 2 }</div>
<div>
<br /></div>
<div>
> db.foo.update({"_id" : "Poland"}, {$set:{"population" : 200000}});</div>
<div>
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })</div>
<div>
<br /></div>
<div>
> db.foo.find({"_id" : "Poland"});</div>
<div>
{ "_id" : "Poland", <b>"population" : 200000</b>, "land_locked" : 2 }</div>
<div>
<br /></div>
</div>
<div>
<div>
If the field does not exist, new field with set value is created, e.g.</div>
</div>
<div>
<div>
> db.foo.update({"_id" : "Poland"}, {$set:{"language" : "Polish"}});</div>
<div>
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })</div>
<div>
> db.foo.find({"_id" : "Poland"});</div>
<div>
{ "_id" : "Poland", "population" : 200000, "land_locked" : 2, "language" : "Polish" }</div>
</div>
<div>
<br /></div>
<div>
<u>$inc</u> - increasing value of a field</div>
<div>
<div>
> db.foo.update({"_id" : "Poland"}, {<b>$inc:</b>{"population" : 1}});</div>
<div>
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })</div>
<div>
> db.foo.find({"_id" : "Poland"});</div>
<div>
{ "_id" : "Poland", <b>"population" : 200001</b>, "land_locked" : 2, "language" : "Polish" }</div>
</div>
<br />
<u>update </u>will not create any new row if it does not exist<br />
> db.foo.update({"_id" : "Englad"}, {$inc:{"population" : 1}});<br />
WriteResult({ "nMatched" : 0, "nUpserted" : 0, "nModified" : 0 })<br />
<br />
> db.food.find({"_id" : "Englad"});<br />
><br />
But update will add a new field if it does not exist<br />
> db.foo.insert({ "_id" : "England", "land_locked" : 2 });<br />
WriteResult({ "nInserted" : 1 })<br />
> db.foo.update({"_id" : "England"}, {$inc:{"population" : 1}});<br />
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })<br />
<br />
> db.foo.find({"_id" : "England"});<br />
{ "_id" : "England", "land_locked" : 2, "population" : 1 }<br />
<br />
$inc operator can only be applied to numeric value. $inc operator can add new field but $set operator cannot add new field.<br />
<br />
<u>$unset - </u>remove a field from document<br />
> db.users.find({ "_id" : "myrnarackham"});<br />
{ "_id" : "myrnarackham", "phone" : "301-512-7434", "country" : "RU" }<br />
> db.users.update({ "_id" : "myrnarackham"}, {$unset:{"country":"RU"}});<br />
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })<br />
> db.users.find({ "_id" : "myrnarackham"});<br />
{ "_id" : "myrnarackham", "phone" : "301-512-7434" }<br />
> db.users.update({ "_id" : "myrnarackham"}, {$unset:{"phone":"1"}});<br />
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })<br />
> db.users.find({ "_id" : "myrnarackham"});<br />
{ "_id" : "myrnarackham" }<br />
<br />
<br />
<a href="https://university.mongodb.com/courses/MongoDB/M101J/2015_August/courseware/Week_2_CRUD/52938211e2d423246e7c437c" style="background: rgb(221, 221, 221); box-sizing: border-box; color: #31302f; font-family: akzidenz-grotesk, Helvetica, Arial, sans-serif; font-size: 14px; letter-spacing: 0.400000005960465px; line-height: 17.5px;"><b><span class="section-unviewed" style="box-sizing: border-box;">Using $push, $pop, $pull, $pushAll, $pullAll, $addToSet</span> </b></a><br />
> db.friends.insert({_id : "Mike", interests : [ "chess", "botany" ] });<br />
WriteResult({ "nInserted" : 1 })<br />
> db.friends.update( { _id : "Mike" }, { $push : { interests : "skydiving" } } );<br />
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })<br />
> db.friends.find()<br />
{ "_id" : "Mike", "interests" : [ "chess", "botany", "skydiving" ] }<br />
> db.friends.update( { _id : "Mike" }, { $pop : { interests : -1 } } );<br />
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })<br />
> db.friends.find()<br />
{ "_id" : "Mike", "interests" : [ "botany", "skydiving" ] }<br />
> db.friends.update( { _id : "Mike" }, { $addToSet : { interests : "skydiving" } } );<br />
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 0 })<br />
> db.friends.find()<br />
{ "_id" : "Mike", "interests" : [ "botany", "skydiving" ] }<br />
> db.friends.update( { _id : "Mike" }, { $pushAll: { interests : [ "skydiving" , "skiing" ] } } );<br />
WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })<br />
> db.friends.find()<br />
{ "_id" : "Mike", "interests" : [ "botany", "skydiving", "skydiving", "skiing" ] }<br />
<br />
<u style="font-weight: bold;">$upsert</u>- insert a record if it does not exist, or update the existing one. example<br />
After performing the following update on an empty collection<br />
db.foo.update( { username : 'bar' }, { '$set' : { 'interests': [ 'cat' , 'dog' ] } } , { upsert : true } );<br />
<br />
<span style="background-color: white; color: #31302f; font-family: akzidenz-grotesk, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.400000005960465px; line-height: 24px;">{ "_id" : ObjectId("507b78232e8dfde94c149949"), "interests" : [ "cat", "dog" ], "username" : "bar" }</span><br />
<span style="background-color: white; color: #31302f; font-family: akzidenz-grotesk, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.400000005960465px; line-height: 24px;"><br /></span>
<span style="background-color: white; color: #31302f; font-family: akzidenz-grotesk, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.400000005960465px; line-height: 24px;"><u style="font-weight: bold;">Removing Documents - </u>Deleting documents from Database.</span><br />
<span style="background-color: white; color: #31302f; font-family: akzidenz-grotesk, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.400000005960465px; line-height: 24px;"><br /></span>
> db.people.insert({"name":"Alice", "age":20, sex:"f"})<br />
WriteResult({ "nInserted" : 1 })<br />
> db.people.insert({"name":"John", "age":20, sex:"m"})<br />
WriteResult({ "nInserted" : 1 })<br />
> db.people.insert({"name":"Ran", "age":20, sex:"f"})<br />
WriteResult({ "nInserted" : 1 })<br />
> db.people.insert({"name":"Mony", "age":25, sex:"f"})<br />
WriteResult({ "nInserted" : 1 })<br />
> db.people.insert({"name":"Ricky", "age":30, sex:"m"})<br />
WriteResult({ "nInserted" : 1 })<br />
> db.people.insert({"name":"Aster Krtor", "age":24, sex:"m"})<br />
WriteResult({ "nInserted" : 1 })<br />
<br />
Works like find() command. Receives argument to filter the rows to remove<br />
> db.people.remove({name:"Alice"})<br />
WriteResult({ "nRemoved" : 1 })<br />
<br />
If you want to remove all documents of the collection "people"<br />
> db.people.remove({})<br />
WriteResult({ "nRemoved" : 5 })<br />
> db.people.find()<br />
<span style="background-color: white; color: #31302f; font-family: akzidenz-grotesk, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.400000005960465px; line-height: 24px;"></span><br />
<br />
If you want to remove more efficiently, use drop<br />
db.people.drop()<br />
<br />
drop() function is different from remove(). Remove updates collection one by one, but drop removes whole collection datafile at ones.<br />
<br />
Document removal is an atomic operation and no document is half removed.<br />
<div>
<br /></div>
<span style="background-color: white; color: #31302f; font-family: akzidenz-grotesk, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.400000005960465px; line-height: 24px;"><br /></span>
<span style="background-color: white; color: #31302f; font-family: akzidenz-grotesk, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.400000005960465px; line-height: 24px;"><br /></span>
<span style="background-color: white; color: #31302f; font-family: akzidenz-grotesk, Helvetica, Arial, sans-serif; font-size: 16px; letter-spacing: 0.400000005960465px; line-height: 24px;"><br /></span>
<br />
<br />
<br />
<!--1000-->Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-15176519630185088672015-01-16T06:09:00.000-08:002015-01-16T06:10:40.167-08:00Oracle : Grants and checking Grants for a Schema<div style="margin-bottom: 0in;">
<span style="font-family: Times New Roman, serif;"><span style="font-size: 9pt;"><b>How would you enable one schema to do SELECT on another schema?</b></span></span></div>
<div style="margin-bottom: 0in;">
<br /></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Times New Roman, serif;"><span style="font-size: 12px;">Step 1: </span></span><span style="font-family: 'Times New Roman', serif; font-size: 9pt;">Login to Srouce Schema SOURCE_SCHEMA, to provide grant to client schema</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Times New Roman, serif;"><span style="font-size: 9pt;">GRANT
SELECT ON SRC_TAB TO CLIENT_SCHEMA;</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Times New Roman, serif;"><span style="font-size: 9pt;"><br /></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Times New Roman, serif;"><span style="font-size: 12px;">Step 2: Login to Client Schema to select data from table present in source schema</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Times New Roman, serif;"><span style="font-size: 12px;">SELECT * FROM </span></span><span style="font-family: 'Times New Roman', serif; font-size: 12px;">SOURCE_SCHEMA.</span><span style="font-family: 'Times New Roman', serif; font-size: 12px;">SRC_TAB;</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: 'Times New Roman', serif; font-size: 12px;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: 'Times New Roman', serif; font-size: 12px;">Same steps can be used for UPDATE, DELETE and other ddl and dml grants.</span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: 'Times New Roman', serif; font-size: 12px;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: 'Times New Roman', serif; font-size: 12px;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: 'Times New Roman', serif; font-size: 12px;"><b>How would you find from Client Schema that which tables of source schema are granted to Client Schema?</b></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: 'Times New Roman', serif; font-size: 12px;"><br /></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Times New Roman, serif;"><span style="font-size: 12px;">select * from USER_TAB_PRIVS where owner like '</span></span><span style="font-family: 'Times New Roman', serif; font-size: 12px;">SOURCE_SCHEMA</span><span style="font-family: Times New Roman, serif;"><span style="font-size: 12px;">';</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Times New Roman, serif;"><span style="font-size: 12px;"><br /></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Times New Roman, serif;"><span style="font-size: 12px;"><br /></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Times New Roman, serif;"><span style="font-size: 12px;"><b>How would you find the which objects (TABLE, FUNCTION, SEQUENCE etc) are present in a schema?</b></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Times New Roman, serif;"><span style="font-size: 12px;"><b><br /></b></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Times New Roman, serif;"><span style="font-size: 12px;">select * from ALL_OBJECTS where OWNER like '</span></span><span style="font-family: 'Times New Roman', serif; font-size: 12px;">SOURCE_SCHEMA</span><span style="font-family: Times New Roman, serif;"><span style="font-size: 12px;">' and OBJECT_TYPE like 'TABLE';</span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Times New Roman, serif;"><span style="font-size: 12px;"><br /></span></span></div>
<div style="margin-bottom: 0in;">
<span style="font-family: Times New Roman, serif;"><span style="font-size: 12px;">select * from ALL_OBJECTS where OWNER like '</span></span><span style="font-family: 'Times New Roman', serif; font-size: 12px;">SOURCE_SCHEMA</span><span style="font-family: Times New Roman, serif;"><span style="font-size: 12px;">' and OBJECT_TYPE like 'FUNCTION';</span></span></div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-74277955090827974042014-09-27T03:49:00.001-07:002014-09-27T03:49:19.944-07:00Updating EAR with Environment Specific deployment descriptor using ANT Script<u>Scenario:</u><br />
<br />
<ol>
<li>EAR contains a web application.</li>
<li>The EAR need to be deployed in three client environments e.g. Development, UAT and Production</li>
<li>The different environments required filters in web.xml. But the URL of filters are different for different environment. </li>
<li>So, before deployment, the web.xml of Development should be there in Web Application (WAR) and same applies before deployment in UAT and Production.</li>
</ol>
<div>
<u>Solution:</u></div>
<div>
<ol>
<li>Write an Ant Script to update the WAR file with respective web.xml and update the EAR with updated WAR File.</li>
</ol>
<div>
<u>Ant Script:</u></div>
</div>
<div>
<u><br /></u></div>
<br />
<div>
<!--</div>
<div>
<div>
ant -Dtar=apptar.tar -Dxml=PRO movwebx -f build.xml all</div>
<div>
<br /></div>
<div>
ant -f build.xml all</div>
<div>
<br /></div>
<div>
--></div>
<div>
<br /></div>
<div>
<project name="UPDATE_EAR" default="dist" basedir="."></div>
<div>
</div>
<div>
<property name="upd_ear.dir" value="upd_ear"/></div>
<div>
<br /></div>
<div>
<target name="mkchdir"></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><echo>CREATING TMP FOLDER</echo> </div>
<div>
<mkdir dir="upd_ear"/></div>
<div>
</target></div>
<div>
<br /></div>
<div>
<target name="mov" depends="mkchdir"></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><echo>MOVING TAR IN TMP FOLDER</echo> </div>
<div>
<move file="${tar}" todir="${upd_ear.dir}"/></div>
<div>
</target></div>
<div>
<br /></div>
<div>
<target name="tarxvf" depends="mov"></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><echo>UN TAR ${tar} IN TMP FOLDER</echo> </div>
<div>
<unjar src="${upd_ear.dir}/${tar}" dest="${upd_ear.dir}"/></div>
<div>
</target></div>
<div>
<br /></div>
<div>
<target name="earxvf" depends="tarxvf"></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><echo>UN JAR appear.ear IN TMP FOLDER</echo> </div>
<div>
<unjar src="${upd_ear.dir}/appear.ear" dest="${upd_ear.dir}"/></div>
<div>
</target></div>
<div>
<br /></div>
<div>
<target name="warxvf" depends="earxvf"></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><echo>UN JAR appwar.war IN TMP FOLDER</echo> </div>
<div>
<unwar src="${upd_ear.dir}/appwar.war" dest="${upd_ear.dir}"/></div>
<div>
</target></div>
<div>
<br /></div>
<div>
<target name="movwebx" depends="warxvf"></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><echo>MOVE web_${xml}.xml to web.xml</echo> </div>
<div>
<move file="${upd_ear.dir}/WEB-INF/web_${xml}.xml" tofile="${upd_ear.dir}/WEB-INF/web.xml" /></div>
<div>
</target></div>
<div>
</div>
<div>
<br /></div>
<div>
<target name="updwar" depends="movwebx"> </div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><echo>UPDATE web.xml of ${xml} IN appwar.war</echo> </div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><zip destfile="${upd_ear.dir}/appwar.war" update="true"></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><fileset dir="${upd_ear.dir}"> </div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><include name="WEB-INF/web.xml" /> </div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span></fileset></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span></zip></div>
<div>
</target></div>
<div>
<br /></div>
<div>
</div>
<div>
<target name="updear" depends="updwar"> </div>
<div>
<echo>UPDATING appear.ear WITH appwar.war</echo> </div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span> <zip destfile="${upd_ear.dir}/appear.ear" update="true"></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><fileset dir="${upd_ear.dir}"> </div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><include name="appwar.war" /> </div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span></fileset></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span> </zip></div>
<div>
</target></div>
<div>
<br /></div>
<div>
<target name="movear" depends="updear"></div>
<div>
<echo>MOVING EAR FILE</echo> </div>
<div>
<move file="${upd_ear.dir}/appear.ear" todir="." /></div>
<div>
</target></div>
<div>
<br /></div>
<div>
<target name="movtar" depends="movear"></div>
<div>
<echo>MOVING TAR FILE</echo> </div>
<div>
<move file="${upd_ear.dir}/${tar}" todir="." /></div>
<div>
</target></div>
<div>
<br /></div>
<div>
<target name="delchdir" depends="movtar"></div>
<div>
<echo>DELETING TMP FOLDER</echo> </div>
<div>
<delete dir="${upd_ear.dir}"/></div>
<div>
</target></div>
<div>
</div>
<div>
<target name="updateear" depends="delchdir"/></div>
<div>
<br /></div>
<div>
</project></div>
</div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-29142229955896206362014-07-25T20:39:00.000-07:002014-07-25T20:42:35.062-07:00AXIS 2 - Catching ErrorsAxis2 - This utility will never throw errors if your log4j is not enabled in the application. This will make you to struggle to find the issue. You will never understand the issue is in Client Code or Server Code. And it will consume your 2-3-4 days to one Week, So, then what is the solution: Enable the log4j of your WebService Server Application.<br />
<br />
Step 1 - Create a log4j.properties file.<br />
Step 2 - Create a ServletContextListener<br />
Step 3 - Load the log4j.properties file in PropertyConfigurator, its a log4j class.<br />
<br />
<u>Step 1 - log4j.properties</u><br />
<br />
#<br />
# Licensed to the Apache Software Foundation (ASF) under one<br />
# or more contributor license agreements. See the NOTICE file<br />
# distributed with this work for additional information<br />
# regarding copyright ownership. The ASF licenses this file<br />
# to you under the Apache License, Version 2.0 (the<br />
# "License"); you may not use this file except in compliance<br />
# with the License. You may obtain a copy of the License at<br />
#<br />
# http://www.apache.org/licenses/LICENSE-2.0<br />
#<br />
# Unless required by applicable law or agreed to in writing,<br />
# software distributed under the License is distributed on an<br />
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY<br />
# KIND, either express or implied. See the License for the<br />
# specific language governing permissions and limitations<br />
# under the License.<br />
#<br />
<br />
# Set root category priority to INFO and its only appender to CONSOLE.<br />
#log4j.rootCategory=INFO, CONSOLE<br />
log4j.rootCategory=DEBUG, LOGFILE<br />
<br />
# Set the enterprise logger priority to FATAL<br />
log4j.logger.org.apache.axis2.enterprise=DEBUG<br />
log4j.logger.de.hunsicker.jalopy.io=DEBUG<br />
log4j.logger.httpclient.wire.header=DEBUG<br />
log4j.logger.org.apache.commons.httpclient=DEBUG<br />
<br />
# CONSOLE is set to be a ConsoleAppender using a PatternLayout.<br />
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender<br />
log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout<br />
log4j.appender.CONSOLE.layout.ConversionPattern=[%p] %m%n<br />
<br />
# LOGFILE is set to be a File appender using a PatternLayout.<br />
log4j.appender.LOGFILE=org.apache.log4j.FileAppender<br />
log4j.appender.LOGFILE.File=D:\\AXIS2_DUMP\\axis2-1.6.2\\logs\\axis2.log<br />
log4j.appender.LOGFILE.Append=true<br />
log4j.appender.LOGFILE.layout=org.apache.log4j.PatternLayout<br />
log4j.appender.LOGFILE.layout.ConversionPattern=%d [%t] %-5p %c %x - %m%n<br />
<br />
<u>Step 2 - Create a ServletContextListener and Step 3</u><br />
MyClass.java<br />
<br />
package com.init;<br />
<br />
import java.util.Properties;<br />
<br />
import javax.servlet.ServletContextEvent;<br />
import javax.servlet.ServletContextListener;<br />
<br />
import org.apache.log4j.PropertyConfigurator;<br />
<br />
public class MyClass implements ServletContextListener {<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void contextInitialized(ServletContextEvent e) {<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>init();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("\n\ncontextInitialized(ServletContextEvent e)");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void contextDestroyed(ServletContextEvent e) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("\n\ncontextDestroyed(ServletContextEvent e)");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static void init() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Properties prop = new Properties();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// code added by sanjeev for NON_CLUSTER_CR -START<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>try {<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>String logpath = System.getProperty("log4j.configuration");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("logpath::"+logpath);<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>PropertyLoader.loadProperties(logpath);<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>prop = PropertyLoader.getProperties();<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("IPHLogger | init | prop="+prop );<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (prop != null) {<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
//loading log4j.properties in log4j memory<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>PropertyConfigurator.configure(prop);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} catch (Exception exception) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>exception.printStackTrace();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
}<br />
<div>
<br /></div>
<u>PropertyLoader.java </u><br />
package com.init;<br />
<br />
import java.io.InputStream;<br />
import java.util.Enumeration;<br />
import java.util.Properties;<br />
import java.util.ResourceBundle;<br />
<br />
<br />
public abstract class PropertyLoader {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private PropertyLoader() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static final boolean THROW_ON_LOAD_FAILURE = true;<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static final boolean LOAD_AS_RESOURCE_BUNDLE = true;<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static final String SUFFIX = ".properties";<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>private static volatile Properties result = null;<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// public: ................................................................<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>/**<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * Looks up a resource named 'name' in the classpath. The resource must map<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * to a file with .properties extention. The name is assumed to be absolute<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * and can use either "/" or "." for package segment separation with an<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * optional leading "/" and optional ".properties" suffix. Thus, the<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * following names refer to the same resource:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * <br />
<pre></pre>
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * some.pkg.Resource<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * some.pkg.Resource.properties<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * some/pkg/Resource<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * some/pkg/Resource.properties<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * /some/pkg/Resource<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * /some/pkg/Resource.properties<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * <br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> *<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * @param argStrname classpath resource name [may not be null]<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * @param argClassloader classloader through which to load the resource [null<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * is equivalent to the application loader]<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> *<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * @return resource converted to java.util.Properties [may be null if the<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * resource was not found and THROW_ON_LOAD_FAILURE is false]<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * @throws IllegalArgumentException if the resource was not found and<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * THROW_ON_LOAD_FAILURE is true<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> */<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static Properties loadProperties(String argStrname,<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ClassLoader argClassloader) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (argStrname == null)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>throw new IllegalArgumentException("null input: name");<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (argStrname.startsWith("/"))<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>argStrname = argStrname.substring(1);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (argStrname.endsWith(SUFFIX))<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>argStrname = argStrname.substring(0, argStrname.length()<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>- SUFFIX.length());<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>InputStream objInputStream = null;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>try {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (argClassloader == null)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>argClassloader = ClassLoader.getSystemClassLoader();<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (LOAD_AS_RESOURCE_BUNDLE) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>argStrname = argStrname.replace('/', '.');<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("0->"+argStrname);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// throws MissingResourceException on lookup failures:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>final ResourceBundle objResourceBundle = ResourceBundle<span class="Apple-tab-span" style="white-space: pre;"> </span>.getBundle(argStrname);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>result = new Properties();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (Enumeration keys = objResourceBundle.getKeys(); keys.hasMoreElements();) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>final String key = (String) keys.nextElement();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>final String value = objResourceBundle.getString(key);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>result.put(key, value);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>argStrname = argStrname.replace('.', '/');<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("1->"+argStrname);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (!argStrname.endsWith(SUFFIX))<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>argStrname = argStrname.concat(SUFFIX);<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>// returns null on lookup failures:<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objInputStream = argClassloader.getResourceAsStream(argStrname);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (objInputStream != null) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>result = new Properties();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>result.load(objInputStream); // can throw IOException<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} catch (Exception e) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>result = null;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} finally {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (objInputStream != null)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>try {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>objInputStream.close();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} catch (Throwable ignore) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if (THROW_ON_LOAD_FAILURE && (result == null)) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>throw new IllegalArgumentException("could not load ["<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ argStrname<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ "]"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ " as "<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>+ (LOAD_AS_RESOURCE_BUNDLE ? "a resource bundle"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>: "a classloader resource"));<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return result;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>/**<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * A convenience overload of loadProperties(String, ClassLoader)<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * that uses the current thread's context classloader.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> */<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static Properties loadProperties(final String argStrName) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return loadProperties(argStrName, Thread.currentThread().getContextClassLoader());<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>/**<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * A method to retrieve the properties value based on the key<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * passed as an argument<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> *<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> */<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static String getValue(String argStrKeyVal) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return (result == null) ? (null): ((result.containsKey(argStrKeyVal)) ? ((String) result<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>.get(argStrKeyVal)) : (null));<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>/**<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * A method to retrieve the properties object associated with<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> * the file.<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> */<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static synchronized Properties getProperties() {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return (result == null) ? (null) : result;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
} // end of class<br />
<div>
<br /></div>
<div>
<u>Adding listener in web.xml</u></div>
<div>
<div>
</div>
<div>
<web-app></web-app></div>
</div>
<div>
<div>
<listener></listener></div>
<div>
<?xml version="1.0" encoding="UTF-8"?><br />
<web-app ><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><listener><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><listener-class>com.init.MyClass</listener-class><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></listener> <br />
</web-app></div>
<div>
</div>
</div>
<div>
</div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-52348287997363728902014-05-18T06:14:00.003-07:002014-05-18T06:20:55.306-07:00AXIS 2 - Client and Password Call Back Handler - For a secured (using Rampart) webservice <br />
<u><b>Password Call Back Handler</b></u> - This class is invoked by container when the webservice receives a secured request.<br />
<br />
package crishantha.rampart;<br />
<br />
import java.io.IOException;<br />
<br />
import javax.security.auth.callback.Callback;<br />
import javax.security.auth.callback.CallbackHandler;<br />
import javax.security.auth.callback.UnsupportedCallbackException;<br />
<br />
import org.apache.ws.security.WSPasswordCallback;<br />
<br />
public class PWCBHandler implements CallbackHandler {<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("handle->(Callback[]:"+ callbacks);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>for (int i = 0; i < callbacks.length; i++) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("(Callback["+i+"]:"+ callbacks[i]);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>//When the server side need to authenticate the user<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("pwcb.getIdentifier()->"+pwcb.getIdentifier());<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("pwcb.getPassword()->"+pwcb.getPassword());<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>if(pwcb.getIdentifier().equals("apache") /*&& pwcb.getPassword().equals("password")*/) {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>//If authentication successful, simply return<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>pwcb.setPassword("password"); // this value should be same as password supplied in SOAP Envelop.<br />
//See the client program below for password<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("user authenticated->"+pwcb.getIdentifier());<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>} else {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>throw new UnsupportedCallbackException(callbacks[i], "check failed");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
}<br />
<br />
<span class="Apple-tab-span" style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, sans-serif; font-size: 13px; line-height: 18px; white-space: pre;"> </span><span style="background-color: white; font-family: 'Trebuchet MS', Trebuchet, sans-serif; font-size: 13px; line-height: 18px;"><b><u><wsp:policy> </wsp:policy></u></b>Tag in services.xml </span><span style="background-color: white; color: #666666; font-family: 'Trebuchet MS', Trebuchet, sans-serif; font-size: 13px; line-height: 18px;">(</span><a href="http://java-application-programming.blogspot.in/2014/05/axis2-servicesxml-engaging-rampart.html">http://java-application-programming.blogspot.in/2014/05/axis2-servicesxml-engaging-rampart.html</a>) need to be embed in services.xml for integrating Password Call Back Handler.<br />
<br />
<br />
<b><u>Client Program to call secured webservice</u></b><br />
<b><u><br /></u></b>
<br />
package ramp.client;<br />
<br />
import org.apache.axis2.client.Options;<br />
import org.apache.axis2.client.ServiceClient;<br />
import org.apache.axis2.context.ConfigurationContext;<br />
import org.apache.axis2.context.ConfigurationContextFactory;<br />
<br />
<br />
public class Client {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static void main(String[] args)throws Exception {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.setProperty("javax.net.ssl.trustStore", "D:\\apache-tomcat-7.0.53\\bin\\sslkey\\sslkey.jks");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.setProperty("javax.net.ssl.trustStorePassword", "password");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ConfigurationContext ctx = ConfigurationContextFactory.createConfigurationContextFromFileSystem("D:\\AXIS2_DUMP\\axis2-1.6.2\\repository", null);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("0->"+ctx.getContextRoot());<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>TemperatureConversionServiceStub stub = new TemperatureConversionServiceStub(ctx, "https://localhost:8443/ram/services/TemperatureConversionService");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("1->"+stub);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>ServiceClient sc = stub._getServiceClient();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("1.1->"+sc);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sc.engageModule("rampart");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("1.2->"+sc);<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Options options = sc.getOptions();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("1.3->"+options);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>options.setUserName("apache");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>options.setPassword("password");<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("1.4->"+options.getPassword());<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>TemperatureConversionServiceStub.Celcius2Farenhit celc = new TemperatureConversionServiceStub.Celcius2Farenhit();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("2->"+celc);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>celc.setCelcius(10f);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("3->"+celc);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>TemperatureConversionServiceStub.Celcius2FarenhitResponse cfr = stub.celcius2Farenhit(celc);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("4->"+cfr);<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>float f = cfr.get_return();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>System.out.println("5. result->"+f);<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
}<br />
<div>
<div style="text-decoration: underline;">
<br /></div>
<div style="text-decoration: underline;">
<br /></div>
<div style="text-decoration: underline;">
<b>SOAP Envelop sent by client program:</b></div>
<div style="text-decoration: underline;">
<br /></div>
<br />
<br />
<br />
<br />
<?xml version='1.0' encoding='utf-8'?><br />
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope"><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><soapenv:Header><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsse:Security<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>soapenv:mustUnderstand="true"><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsu:Timestamp wsu:Id="TS-1"><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsu:Created>2014-05-18T12:13:15.063Z</wsu:Created><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsu:Expires>2014-05-18T12:18:15.063Z</wsu:Expires><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></wsu:Timestamp><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsse:UsernameToken wsu:Id="UsernameToken-2"><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsse:Username>apache</wsse:Username><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsse:Password<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">password</wsse:Password><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></wsse:UsernameToken><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></wsse:Security><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></soapenv:Header><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><soapenv:Body><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><ns1:celcius2farenhit xmlns:ns1="http://www.polarisft.com/iph/ws/portalService/"><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><ns1:celcius>10.0</ns1:celcius><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></ns1:celcius2farenhit><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></soapenv:Body><br />
</soapenv:Envelope><br />
<br />
</div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-5191278034482646812014-05-17T06:51:00.003-07:002014-05-18T06:16:46.612-07:00AXIS 2 - SOAP Webservice - Adding Security layer to webservice using Rampart<u>Tools and Libraries used </u><br />
<br />
<ol>
<li>apache-tomcat-7.0.53</li>
<li>axis2-1.6.2</li>
<li>rampart-1.6.2</li>
<li>jdk 1.6</li>
</ol>
<div>
Exploring ram.war - The war file name is ram.war. The directory structure of the war file is below.</div>
<div>
<br /></div>
<div>
<div>
D:\APACHE-TOMCAT-7.0.53\WEBAPPS\RAM</div>
<div>
├───META-INF</div>
<div>
└───WEB-INF</div>
<div>
├───classes</div>
<div>
│ ├───com</div>
<div>
│ │ └───polaris</div>
<div>
│ │ └───iph</div>
<div>
│ │ └───ws</div>
<div>
│ └───crishantha</div>
<div>
│ └───rampart</div>
<div>
├───conf</div>
<div>
├───lib</div>
<div>
├───modules</div>
<div>
└───services</div>
<div>
└───TemperatureConversionService</div>
<div>
└───META-INF</div>
</div>
<div>
<br /></div>
<div>
Below folders contain classes for webservice.</div>
<div>
- classes/com.polaris.iph.ws </div>
<div>
- classes/crishantha.rampart</div>
<div>
<br /></div>
<div>
<b><u>Integrating rampart with Axis 2 webservice</u></b></div>
<div>
<div>
WEB-INF/conf - contains axis2.xml</div>
</div>
<div>
WEB-INF/lib - contains all jars from Axis2_HOME/lib/ and RAMPART_HOME/lib directory. </div>
<div>
<br /></div>
<div>
<b>Very important Note </b></div>
<div>
<b>- The version of Axis2 and Rampart should be same. I faced issues because previously I was using axis2-1.6.2 and rampart-1.3.2. Then I changed the version of rampart to rampart-1.6.2 and it worked. This is very important point.</b></div>
<div>
<b>- The axis2 libs should not be mixed with various versions of other libs of Rampart and other extensions. It creates compatibility issues.</b></div>
<div>
<br /></div>
<div>
WEB-INF/modules - copy rahas-1.6.2.mar and rampart-1.6.2.mar files from rampart-1.6.2\modules folder in WEB-INF/modules folder.</div>
<div>
<br />
<b><u>Declare webservice and engaging Rampart </u></b><br />
<br />
Adding Webservice in WAR file and engaging Rampart with Axis2. Follow this link to see the META-INF/services/TemperatureConversionService/META-INF/services.xml.<br />
<a href="http://java-application-programming.blogspot.in/2014/05/axis2-servicesxml-engaging-rampart.html">http://java-application-programming.blogspot.in/2014/05/axis2-servicesxml-engaging-rampart.html</a><br />
<br /></div>
<div>
<b><u>Making server ready for HTTPS</u></b></div>
<div>
Creating SSL Key to make tomcat server HTTPS /SSL Enabled. Execute below command from Tomcat_home\bin folder</div>
<div>
keytool -genkey -alias tomcat -keyalg RSA -keystore c:\sslkey\sslkey.jks</div>
<div>
<br /></div>
<div>
c:\sslkey\sslkey.jks will be created with the key. This key will be used to enable SSL.</div>
<div>
<br /></div>
<div>
Open the server.xml of tomcat from TOMCAT_HOME\conf\server.xml and enable /change/add below lines around <connector> tags.</connector></div>
<div>
<br /></div>
<div>
<div>
<Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"<br />
maxThreads="150" scheme="https" secure="true"<br />
clientAuth="false" sslProtocol="TLS"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> keystoreFile="C:\sslkey\sslkey.jks"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> keystorePass="password" /><br />
<connector div="" port="8443" protocol="HTTP/1.1" sslenabled="true"></connector><br />
<div>
Note: keystorePass="password", "password" value is entered while creating sslkey.jks using keytool (see few lines above)</div>
</div>
<div>
<br /></div>
<div>
Open WEB-INF/conf/axis2.xml and add below lines below <transportreceiver nbsp=""> tag </transportreceiver><span class="Apple-tab-span" style="white-space: pre;"> </span><transportReceiver></div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span><transportreceiver class="Apple-tab-span" name="https" span="" style="white-space: pre;"> </transportreceiver><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><transportReceiver name="https"<span class="Apple-tab-span" style="white-space: pre;"> </span>class="org.apache.axis2.transport.http.AxisServletListener"></div>
</div>
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><parameter name="port">8443</parameter><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></transportReceiver><br />
<div>
<b>Note :</b> The port in axis2.xml and server.xml should be same, here its kept 8443.</div>
<br />
<div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span></div>
</div>
<div>
Generating Client Code - Stub to call this service.<br />
<br />
Save the WSDL -TemperatureConversionService.xml<br />
Execute below command<br />
<br />
<br />
D:\AXIS2_DUMP\axis2-1.6.2\bin\clientcode>..\WSDL2Java.bat -uri D:\2010SANT\27_0_0\WS-POC\RAMPART\WebContent\WEB-INF\wsdl\TemperatureConversionService.xml -p ramp.client -d adb -s</div>
<div>
<br /></div>
<div>
<br />
NOTE: Get the jar from http://repo1.maven.org/maven2/org/apache/axis2/axis2-adb-codegen/1.6.2/axis2-adb-codegen-1.6.2.jar, before executing above command of WSDL2Java.bat. Issues will come without this jar.<br />
<br />
Follow below link to develop Webservice Client for secured Webservice<br />
<a href="http://java-application-programming.blogspot.in/2014/05/axis-2-client-and-password-call-back.html">http://java-application-programming.blogspot.in/2014/05/axis-2-client-and-password-call-back.html</a></div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-21810346963760890722014-05-17T06:41:00.001-07:002014-05-18T06:14:43.317-07:00AXIS 2 - services.xml - engaging rampart<br />
<serviceGroup><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><service name="TemperatureConversionService" targetNamespace="http://www.polarisft.com/iph/ws/"><br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><module ref="rampart" /> <!-- Engaging Rampart --><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><description><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>This service is to get the running Axis version<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></description><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><schema schemaNamespace="http://www.polarisft.com/iph/ws/portalService/" /><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><parameter name="ServiceClass">crishantha.rampart.TemperatureConversionService<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></parameter><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><operation name="celcius2farenhit"><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></operation><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><operation name="farenhit2celcius"><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><messageReceiver class="org.apache.axis2.rpc.receivers.RPCMessageReceiver" /><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></operation><br />
<br />
<!-- Rampart specific tags - start --><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsp:Policy wsu:Id="UsernameTokenOverHTTPS"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsp:ExactlyOne><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsp:All><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><sp:TransportBinding<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsp:Policy><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><sp:TransportToken><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsp:Policy><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><sp:HttpsToken RequireClientCertificate="false" /><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></wsp:Policy><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></sp:TransportToken><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><sp:AlgorithmSuite><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsp:Policy><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><sp:Basic256 /><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></wsp:Policy><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></sp:AlgorithmSuite><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><sp:Layout><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsp:Policy><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><sp:Lax /><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></wsp:Policy><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></sp:Layout><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><sp:IncludeTimestamp /><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></wsp:Policy><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></sp:TransportBinding><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><sp:SignedSupportingTokens<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy"><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><wsp:Policy><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><sp:UsernameToken<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient" /><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></wsp:Policy><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></sp:SignedSupportingTokens><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><ramp:RampartConfig xmlns:ramp="http://ws.apache.org/rampart/policy"><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><ramp:passwordCallbackClass>crishantha.rampart.PWCBHandler</ramp:passwordCallbackClass> <!-- crishantha.rampart.PWCBHandler is user defined class to handle user name password --><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></ramp:RampartConfig><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></wsp:All><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></wsp:ExactlyOne><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></wsp:Policy><br />
<!-- Rampart specific tags - End--><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></service><br />
</serviceGroup>Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-85826100623290982122014-05-01T11:32:00.003-07:002014-05-01T11:49:40.444-07:00SOAP Webservice - JAX-WS<u><b>Topics</b></u><br />
<br />
<ol>
<li><b>Create a sample SOAP Webservice using JAX-WS</b></li>
<li><b>Deploy in Tomcat 7.0</b></li>
<li><b>Invoke WSDL</b></li>
<li><b>Create Client</b></li>
<li><b>Use Client to invoke Webservice</b></li>
</ol>
<div>
</div>
<br />
<ol>
<li style="text-align: left;"><u><b>Create a sample SOAP Webservice using JAX-WS</b></u></li>
<ol>
<li style="text-align: left;">Create a dynamic Web Project in Eclipse</li>
<li style="text-align: left;">Create Service Endpoint Interface (SEI) HelloWorld </li>
<li style="text-align: left;">Create Service Inplementation Bean (SIB), HelloWorldImpl which implement SEI.</li>
<li style="text-align: left;">Change web.xml, add entries if Servlet giving service to Webservice HelloWorldImpl </li>
<li style="text-align: left;">Add sun-jaxws.xml in WEB-INF folder. This file will publish and start the webservice runtime in Tomcat.</li>
</ol>
<li><u><b>Deploy in Tomcat 7.0</b></u></li>
<ol>
<li>Add a new server in Eclipse, pointing to Tomcat 7 installation directory.</li>
<li>Add below jars in WEB-INF/lib folder</li>
<ol>
<li>gmbal-api-only.jar</li>
<li>ha-api.jar</li>
<li>jaxb-api.jar</li>
<li>jaxb-impl-2.2.6.jar</li>
<li>jaxb-impl.jar</li>
<li>jaxws-rt.jar</li>
<li>management-api.jar</li>
<li>policy.jar</li>
<li>stax-ex.jar</li>
<li>streambuffer.jar</li>
</ol>
<li>Add the webservice project (created in 1) in server.</li>
<li>Start the server.</li>
</ol>
<li><b><u>Invoke WSDL</u></b></li>
<ol>
<li>http://localhost:8080/SOAP_JAX/hello?wsdl</li>
</ol>
<li><b><u>Create Client</u></b></li>
<ol>
<li>Create a new java project in eclipse.</li>
<li>Go to src directory in doc command prompt.</li>
<li>Invoke command "wsimport -keep -verbose http://localhost:8080/SOAP_JAX/hello?wsdl"</li>
<li>Two classes will be created in src folder. These are stubs to invoke webservice. </li>
<li>Write the client file using the stubs created in 4 above.</li>
</ol>
<li><b><u>Invoke main method to access webservice.</u></b></li>
</ol>
<div>
<br /></div>
<div>
<b>HelloWorld.java (SEI)</b></div>
<div>
<b><br /></b></div>
<div>
<div>
package com.ws.soap.jaxws.sanjeev;</div>
<div>
<br /></div>
<div>
import javax.jws.WebMethod;</div>
<div>
import javax.jws.WebResult;</div>
<div>
import javax.jws.WebService;</div>
<div>
import javax.jws.soap.SOAPBinding;</div>
<div>
<br /></div>
<div>
/**</div>
<div>
* This class was generated by the JAX-WS RI.</div>
<div>
* JAX-WS RI 2.2.4-b01</div>
<div>
* Generated source version: 2.2</div>
<div>
* </div>
<div>
*/</div>
<div>
@WebService(name = "HelloWorld", targetNamespace = "http://com.soap.sanjeev/")</div>
<div>
@SOAPBinding(style = SOAPBinding.Style.RPC)</div>
<div>
public interface HelloWorld {</div>
<div>
<br /></div>
<div>
/**</div>
<div>
* </div>
<div>
* @return</div>
<div>
* returns java.lang.String</div>
<div>
*/</div>
<div>
@WebMethod</div>
<div>
@WebResult(partName = "return")</div>
<div>
public String getHelloWorldAsString();</div>
<div>
<br /></div>
<div>
}</div>
</div>
<div>
<br /></div>
<div>
<br /></div>
<b>HelloWorldImpl.java (SIB)</b><br />
<div>
<b><br /></b></div>
<div>
<div>
package com.ws.soap.jaxws.sanjeev;</div>
<div>
<br /></div>
<div>
import javax.jws.WebService;</div>
<div>
<br /></div>
<div>
@WebService(endpointInterface = "com.ws.soap.jaxws.sanjeev.HelloWorld")</div>
<div>
public class HelloWorldImpl implements HelloWorld {</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>@Override</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>public String getHelloWorldAsString() {</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>// TODO Auto-generated method stub</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>return "hello world";</div>
<div>
<span class="Apple-tab-span" style="white-space: pre;"> </span>}</div>
<div>
}</div>
<div style="font-weight: bold;">
<br /></div>
</div>
<div>
<b>WEB-INF/sun-jaxws.xml - will publish the webservice and start the webservice runtime</b><br />
<b><br /></b></div>
<div>
<?xml version="1.0" encoding="UTF-8"?><br />
<endpoints xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>version="2.0"><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><endpoint name="HelloWorld" implementation="com.ws.soap.jaxws.sanjeev.HelloWorldImpl"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>url-pattern="/hello" /><br />
<br />
</endpoints></div>
<div>
<div>
</div>
<div>
<br />
<endpoints div="" xmlns="http://java.sun.com/xml/ns/jax-ws/ri/runtime"></endpoints></div>
</div>
<div>
<b>WEB-INF/web.xml - setup servlet and url for webservice</b></div>
<div>
<?xml version="1.0" encoding="UTF-8"?><br />
<br />
<web-app<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>xmlns="http://java.sun.com/xml/ns/j2ee"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>version="2.4"><br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><display-name>Archetype Created Web Application</display-name><br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><listener><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><listener-class><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>com.sun.xml.ws.transport.http.servlet.WSServletContextListener<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></listener-class><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></listener><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><servlet><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><servlet-name>hello</servlet-name><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><servlet-class><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>com.sun.xml.ws.transport.http.servlet.WSServlet<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></servlet-class><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><load-on-startup>1</load-on-startup><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></servlet><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><servlet-mapping><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><servlet-name>hello</servlet-name><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><url-pattern>/hello</url-pattern> <!-- service the webservice --><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span></servlet-mapping><br />
<br />
</web-app><br />
<br />
<br />
<b>WSDL File</b><br />
<b><br /></b>
<br />
<?xml version="1.0" encoding="UTF-8"?><!-- Published by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.8 svn-revision#13980. --><!-- Generated by JAX-WS RI at http://jax-ws.dev.java.net. RI's version is JAX-WS RI 2.2.8 svn-revision#13980. --><definitions xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" xmlns:wsp="http://www.w3.org/ns/ws-policy" xmlns:wsp1_2="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://sanjeev.jaxws.soap.ws.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/" targetNamespace="http://sanjeev.jaxws.soap.ws.com/" name="HelloWorldImplService"><br />
<import namespace="http://com.soap.sanjeev/" location="http://localhost:8080/SOAP_JAX/hello?wsdl=1"></import><br />
<binding xmlns:ns1="http://com.soap.sanjeev/" name="HelloWorldImplPortBinding" type="ns1:HelloWorld"><br />
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="rpc"></soap:binding><br />
<operation name="getHelloWorldAsString"><br />
<soap:operation soapAction=""></soap:operation><br />
<input><br />
<soap:body use="literal" namespace="http://com.soap.sanjeev/"></soap:body><br />
</input><br />
<output><br />
<soap:body use="literal" namespace="http://com.soap.sanjeev/"></soap:body><br />
</output><br />
</operation><br />
</binding><br />
<service name="HelloWorldImplService"><br />
<port name="HelloWorldImplPort" binding="tns:HelloWorldImplPortBinding"><br />
<soap:address location="http://localhost:8080/SOAP_JAX/hello"></soap:address><br />
</port><br />
</service><br />
<br />
</definitions><br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjORoeSZ5OuGP7CS2ZpTl4XXaOSpxa5qyiiBT7kpE_fiIBg9qv-P2g86hzdXF9ueUm5GDDmXMmf77STLdOnxJG0UpnglATh58-40KDCVxuprQZ48OERzkwllHYDOdVq5BomkbmeuDtoVCQ/s1600/wsdl.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjORoeSZ5OuGP7CS2ZpTl4XXaOSpxa5qyiiBT7kpE_fiIBg9qv-P2g86hzdXF9ueUm5GDDmXMmf77STLdOnxJG0UpnglATh58-40KDCVxuprQZ48OERzkwllHYDOdVq5BomkbmeuDtoVCQ/s1600/wsdl.jpg" height="179" width="320" /></a></div>
<br />
<br />
<b>HelloClient.java - Webservice Client </b><br />
<b><br /></b>
package com.client.soap.jaxws.sanjeev;<br />
<br />
import javax.xml.ws.WebServiceRef;<br />
<br />
import com.ws.soap.jaxws.sanjeev.HelloWorld;<br />
import com.ws.soap.jaxws.sanjeev.HelloWorldImplService;<br />
<br />
public class HelloClient {<br />
@WebServiceRef(wsdlLocation="http://localhost:8080/SOAP_JAX/hello?wsdl")<br />
static HelloWorldImplService service;<br />
<br />
public static void main(String[] args) {<br />
try {<br />
HelloClient client = new HelloClient();<br />
client.doTest(args);<br />
} catch(Exception e) {<br />
e.printStackTrace();<br />
}<br />
}<br />
<br />
public void doTest(String[] args) {<br />
try {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> service = new HelloWorldImplService(); <span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
System.out.println("Retrieving the port from the following service: " + service);<br />
HelloWorld port = service.getHelloWorldImplPort();<br />
System.out.println("Invoking the sayHello operation on the port.");<br />
<br />
String name;<br />
if (args.length > 0) {<br />
name = args[0];<br />
} else {<br />
name = "No Name";<br />
}<br />
<br />
String response = port.getHelloWorldAsString();<br />
System.out.println(response);<br />
} catch(Exception e) {<br />
e.printStackTrace();<br />
}<br />
}<br />
<br />
}</div>
<div>
</div>
<div>
</div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-10828715885048282562013-11-15T11:08:00.000-08:002013-11-15T11:12:32.819-08:00Understanding SQL Joins using venn diagram<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVxLppDf7ueRtntFKPknrnh1HBjjTGxy1v1MpxCclfiN3P3qwgqDEx77YL77_xWh2y66BS4prSr3sjtBTWSybyhabuBjGszHh2g5YMiyur2jmNalcx_Jdnw-W8SGIcYSTNaIWZQttphUE/s1600/1424377_609817375768877_387332823_n.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVxLppDf7ueRtntFKPknrnh1HBjjTGxy1v1MpxCclfiN3P3qwgqDEx77YL77_xWh2y66BS4prSr3sjtBTWSybyhabuBjGszHh2g5YMiyur2jmNalcx_Jdnw-W8SGIcYSTNaIWZQttphUE/s1600/1424377_609817375768877_387332823_n.jpg" /></a></div>
<br />Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-8919406462184676782013-02-08T21:15:00.002-08:002013-02-08T21:32:48.973-08:00Java 6 Basics of Generics <br />
<br />
//Below program is self explanatory. Please go through line by line and you will know basics of Generics<br />
<br />
<br />
package com.sanjeev.generics;<br />
<br />
import java.util.ArrayList;<br />
import java.util.List;<br />
<br />
public class Dog {<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static List<dog> getDogList(){</dog><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List list = new ArrayList();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>list.add("hello dog"); //allowed as simple list can add any object<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>checkList(list); //allowed. For backward compatibility, normal list can be sent<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span> // as parameter to method with generic list<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return list; //same as above. Normal list can be returned in form of Generic List<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static List getDogList1(){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<dog> list = new ArrayList<dog>(); //Defining Generic List.</dog></dog><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>list.add(new Dog()); //Allowed only Dog object, for which the list is made generic<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>checkList(list); //Allowed method param, only Generic List for Dog Object<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return list;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static List getDogList2(){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List<dog> list = new ArrayList<dog>();</dog></dog><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>list.add("not allowed"); //Not allowed. Dog Object Generic List will not accept String to be added<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>checkList(list); //Allowed method param, only Generic List for Dog Object<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return list; //Allowed. Genric list can be returned in Normal List<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static List doMyList(){<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List < Object > myList = new ArrayList< Object >(); //Generic List for Object. Same as List myList = new ArrayList();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>myList.add(new Dog()); //Can be added Dog object in Generic List of Object<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>checkList(myList); //Not allowed. Generic List of < Object > cannot be sent as param in List<dog></dog><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>checkList1(myList); //Generic List< Object > can be sent in method param of List< Object ><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>checkList2(myList); //Generic List< Object > can be sent in method param of normal List<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List myList1 = new ArrayList();<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>myList1.add(new Dog()); //Allowed<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>checkList(myList1); //Normal list can be sent as param in any Genric List e.g. List<dog></dog><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>checkList1(myList1); //Normal list can be sent as param in any Genric List e.g. List< Object ><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>checkList2(myList1); //Normal List can be sent as param in any Normal List<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>List <dog> myList2 = new ArrayList<dog>();</dog></dog><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>myList.add(new Dog()); //Valid. Dog object can be added in Generic List <dog></dog><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>myList.add(new Object());//Valid. 'Object' can be added in Generic List <dog></dog><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>checkList(myList2); //Valid. As Generic List<dog> being sent in parameter List<dog></dog></dog><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>checkList1(myList2); //Not allowed. List<dog> cannot be sent as param in List< Object ></dog><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>checkList2(myList2); //Allowed. List<dog> can be sent as param in normal List</dog><br />
<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>return null;<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static void checkList(List<dog> mylist){<span class="Apple-tab-span" style="white-space: pre;"> </span></dog><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static void checkList1(List< Object > mylist){<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>public static void checkList2(List mylist){<span class="Apple-tab-span" style="white-space: pre;"> </span><br />
<span class="Apple-tab-span" style="white-space: pre;"> </span>}<br />
}<br />
<div>
<br /></div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0tag:blogger.com,1999:blog-8462405262618085864.post-67746661563678289232013-02-05T09:53:00.002-08:002013-02-05T10:21:37.117-08:00Freedom from darkness<span style="background-color: yellow;"></span><br />
Difference between Stack vs Heap in Java<br />
==============================================================<br />
Here are few differences between stack and heap memory in Java:<br />
1) Main difference between heap and stack is that stack memory is used to store local variables and function call, while heap memory is used to store objects in Java. No matter, where object is created in code e.g. as member variable, local variable or class variable, they are always created inside heap space in Java.<br />
2) Each Thread in Java has there own stack which can be specified using -Xss JVM parameter, similarly you can also specify heap size of Java program using JVM option -Xms and -Xmx where -Xms is starting size of heap and -Xmx is maximum size of java heap. to learn more about JVM options see my post 10 JVM option Java programmer should know.<br />
3) If there is no memory left in stack for storing function call or local variable, JVM will throw java.lang.StackOverFlowError, while if there is no more heap space for creating object, JVM will throw java.lang.OutOfMemoryError: Java Heap Space. Read more about how to deal with java.lang.OutOfMemoryError in my post 2 ways to solve OutOfMemoryError in Java.<br />
4) If you are using Recursion, on which method calls itself, You can quickly fill up stack memory. Another difference between stack and heap is that size of stack memory is lot lesser than size of heap memory in Java.<br />
5) Variables stored in stacks are only visible to the owner Thread, while objects created in heap are visible to all thread. In other words stack memory is kind of private memory of Java Threads, while heap memory is shared among all threads.<br />
<br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">Difference between IdentityHashMap and HashMap</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">===============================================</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">Though both HashMap and IdentityHashMap implements Map interface, have fail-fast Iterator and non synchronized collections, following are some key differences between HashMap and IdentityHashMap in Java.</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">1) Main difference between HashMap vs IdentityHashMap is that IdentityHashMap uses equality operator "==" for comparing keys and values inside Map while HashMap uses equals method for comparing keys and values.</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">2) Unlike HashMap, who uses hashcode to find bucket location, IdentityHashMap also doesn't use hashCode() instead it uses System.identityHashCode(object).</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">3) Another key difference between IdentityHashMap and HashMap in Java is Speed. Since IdentityHashMap doesn't use equals() its comparatively faster than HashMap for object with expensive equals() and hashCode().</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">4) One more difference between HashMap and IdentityHashMap is Immutability of key. One of the basic requirement to safely store Objects in HashMap is keys needs to be immutable, IdentityHashMap doesn't require keys to be immutable as it is not relied on equals and hashCode.</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">There is also a class called IdentityHashtable which is analogous to Hashtable in Java but it’s not part of standard JDK and available in com.sun... package.</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"><br /></span></span></span>
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">Example of IdentityHashMap in Java</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">Here is an example of IdentityHashMap in Java which shows key difference between HashMap and IdentityHashMap in comparing Objects. IdentityHashMap uses equality operator for comparison i instead of equals method in Java :</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"><br /></span></span></span>
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">import java.util.IdentityHashMap;</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"><br /></span></span></span>
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">/**</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> * Java program to show difference between HashMap and IdentityHashMap in Java</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> * @author Javin Paul</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> */</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">public abstract class Testing {</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"><br /></span></span></span>
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> public static void main(String args[]) {</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> IdentityHashMap<string string=""> identityMap = new IdentityHashMap<string string="">();</string></string></span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> </span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> identityMap.put("sony", "bravia");</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> identityMap.put(new String("sony"), "mobile");</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> </span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> //size of identityMap should be 2 here because two strings are different objects</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> System.out.println("Size of IdentityHashMap: " + identityMap.size());</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> System.out.println("IdentityHashMap: " + identityMap);</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> </span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> identityMap.put("sony", "videogame");</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> </span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> //size of identityMap still should be 2 because "sony" and "sony" is same object</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> System.out.println("Size of IdentityHashMap: " + identityMap.size());</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> System.out.println("IdentityHashMap: " + identityMap);</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> </span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"> }</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">}</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;"><br /></span></span></span>
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">Output</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">Size of IdentityHashMap: 2</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">IdentityHashMap: {sony=bravia, sony=mobile}</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">Size of IdentityHashMap: 2</span></span></span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><span style="font-size: x-small;"><span style="line-height: 18px;">IdentityHashMap: {sony=videogame, sony=mobile}</span></span></span><br />
<div style="font-size: 13px; line-height: 18px;">
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;"><br /></span></div>
<br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">When you assign an array to a previously declared array reference, the array you're assigning must be the same dimension as the reference you're assigning it to.</span><br />
<span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">When you assign one primitive(a) variable to another(b), the contents of the right-hand variable are copied and but if we change </span><span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">the contents of either a or b, the other variable won't be affected.</span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">static method cannot access an instance (non-static) variable or a non-static method.</span><br />
<span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">Instance variables and objects live on the heap. </span><span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">Local variables live on the stack.</span><br />
<span style="background-color: yellow;"><span style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">--> The default constructor has the same access modifier as the class.</span><br style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;" /><span style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">--> The default constructor has no arguments.</span><br style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;" /><span style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">--> The default constructor includes a no-arg call to the super constructor.</span></span><br />
<span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">Constructors are never inherited. They aren't methods. They can't be overridden.</span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">transient and volatile modifiers only applies to instance variables.</span><br />
<span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">In a class, Calling a constructor from a method is illegal. Constructor can only be called from another constructor.</span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">There are no final objects, only final references. A final reference still allows you to modify the state of the object it refers to, but you can't modify the reference variable to make it refer to a different object.</span><br />
<span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">Classes can have only public or default access. Class declared private will not compile.</span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">There are no final objects, only final references. A final reference still allows you to modify the state of the object it refers to, but you can't modify the reference variable to make it refer to a different object.</span><br />
<span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">declaring final a List variable as </span><br />
<span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">private final List l = new ArrayList(); </span><br />
<span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">Can I do l.add("a"); in constructor?</span><br />
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">Correlated and NonCorrelated Subquery- </span><br />
<span style="background-color: yellow;"><span style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">============================</span><br style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;" /><span style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">1.In case of correlated subquery inner query depends on outer query while in case of noncorrelated query inner query or subquery doesn't depends on outer query and run by its own.</span><br style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;" /><span style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">No-Correlated Query</span><br style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;" /><span style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">=============</span><br style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;" /><span style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">mysql> SELECT COMPANY FROM Stock WHERE LISTED_ON_EXCHANGE IN (SELECT RIC FROM Market WHERE COUNTRY='United States' OR</span><span class="text_exposed_show" style="color: #333333; display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;"> COUNTRY= 'INDIA');<br />Correlated Query<br />============<br />mysql> SELECT m.NAME FROM Market m WHERE m.RIC = (SELECT s.LISTED_ON_EXCHANGE FROM Stock s WHERE s.LISTED_ON_EXCHANGE=m.RIC);<br />2.In case of correlated subquery, outer query executed before inner query or subquery while in case of NonCorrelated subquery inner query executes before outer query.<br />3.Correlated Sub-queries are slower than non correlated subquery and should be avoided in favor of sql joins.<br />4.Common example of correlated subquery is using exits and not exists keyword while non correlated query mostly use IN or NOT IN keywords.</span></span><br />
<span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">Can we synchronize constructors?</span><br />
<span style="background-color: yellow; font-size: 13px; line-height: 18px;">HashCode Collision in HashMap: In case of hashCode collision, equals method is applied in same bucket with existing elements, if equals method return true, new value is applied on the old key value combination, if equals return false new entry is made with new key value in same bucket. Sample code below. I hav</span><span style="background-color: yellow;"><span style="font-size: 13px; line-height: 18px;">e created a custom object to be used as key in hashMap. Its hasCode will be the length of</span><span class="text_exposed_show" style="display: inline; font-size: 13px; line-height: 18px;"> member variable name, i.e. tow different objects having different values but same length will be having same hashCode but their equals will return false.</span></span><br />
<div role="article" style="font-size: 11px; line-height: 14px;">
<div class="_1x1" style="padding: 10px 0px 15px;">
<div class="userContentWrapper">
<div class="_wk" style="font-size: 13px; line-height: 18px;">
<span class="userContent"><span class="text_exposed_show" style="background-color: yellow; display: inline;"><br />import java.util.*;<br /><br />public class HashTest{<br />public static void main(String[] args) {<br />Map map = new HashMap();<br />System.out.println(1);<br />MyObj newOne1 = new MyObj("one");<br />MyObj newOne3 = new MyObj("tre1");<br />System.out.println(2);<br /><br />MyObj newOne2 = new MyObj("two");<br />System.out.println(3);<br /><br />map.put(newOne1, "one");<br />System.out.println(4);<br /><br />map.put(newOne2, "newOne");<br />System.out.println(5);<br /><br />map.put(newOne3, "tre");<br />System.out.println(6);<br /><br />System.out.println("Map is :"+map);<br />}<br />}<br /><br />class MyObj{<br />String name = null;<br />public MyObj(String s){<br />name = s;<br />}<br /><br />public int hashCode(){<br />System.out.println("Adding hash of -->"+name);<br />return name.length();//so that strings having same length but different value will return same hashCode<br />}<br /><br />public boolean equals(Object o){<br /><br />MyObj m = (MyObj)o;<br />System.out.println("equals called-->"+name+"="+m.name);<br /><br />if(name.equals(m.name))return true;<br /><br />return false;<br />}<br />}<br /><br />============Output =======================<br />1<br />2<br />3<br />Adding hash of -->one<br />4<br />Adding hash of -->two<br />equals called-->two=one<br />5<br />Adding hash of -->tre1<br />6<br />Adding hash of -->two<br />Adding hash of -->one<br />Adding hash of -->tre1<br />Map is :{MyObj@3=newOne, MyObj@3=one, MyObj@4=tre}</span></span></div>
<div class="_wk" style="font-size: 13px; line-height: 18px;">
EJB 3.0. Choosing Between a Local or Remote Client View</div>
<div class="_wk" style="font-size: 13px; line-height: 18px;">
The following considerations should be taken into account in determining whether a local or remote access should be used for an enterprise bean.<br />
• The remote programming model provides location independence and flexibility with regard to the distribution of components in the deployment environment. It provides a loose coupling between the clie<span class="text_exposed_show" style="display: inline;">nt and the bean.<br />• Remote calls involve pass-by-value. This copy semantics provides a layer of isolation between caller and callee, and protects against the inadvertant modification of data. The client and the bean may be programmed to assume this parameter copying.<br />• Remote calls are potentially expensive. They involve network latency, overhead of the client and server software stacks, argument copying, etc. Remote calls are typically programmed in a coarse-grained manner with few interactions between the client and bean.<br />• The objects that are passed as parameters on remote calls must be serializable.<br />• When the EJB 2.1 and earlier remote home and remote component interfaces are used, the narrowing of remote types requires the use of javax.rmi.PortableRemoteObject<wbr></wbr><span class="word_break" style="display: inline-block;"></span>.narrow rather than Java language casts.<br />• Remote calls may involve error cases due to communication, resource usage on other servers, etc., which are not expected in local calls. When the EJB 2.1 and earlier remote home and remote component interfaces are used, the client has to explicitly program handlers for handling the java.rmi.RemoteException.<br />• Because of the overhead of the remote programming model, it is typically used for relatively coarse-grained component access.<br />• Local calls involve pass-by-reference. The client and the bean may be programmed to rely on pass-by-reference semantics. For example, a client may have a large document which it wants to pass on to the bean to modify, and the bean further passes on. In the local programming model the sharing of state is possible. On the other hand, when the bean wants to return a data structure to the client but the bean does not want the client to modify it, the bean explicitly copies the data structure before returning it, while in the remote programming model the bean does not copy the data structure because it assumes that the system will do the copy.<br />• Because local calls involve pass-by-reference, the local client and the enterprise bean providing the local client view are collocated.<br />• The collocation entailed by the local programming model means that the enterprise bean cannot be deployed on a node different from that of its client—thus restricting the distribution of components.<br />• Because the local programming model provides more lightweight access to a component, it better supports more fine-grained component access.<br />Taken from EJB3.0 Specs</span></div>
<div class="_wk" style="font-size: 13px; line-height: 18px;">
<span class="text_exposed_show" style="display: inline;"><br /></span></div>
<div class="_wk" style="font-size: 13px; line-height: 18px;">
<span class="text_exposed_show" style="display: inline;"><img src="http://sphotos-e.ak.fbcdn.net/hphotos-ak-ash3/554205_371206936296590_2009730094_n.jpg" /></span></div>
</div>
</div>
</div>
<div class="fbTimelineUFI uiCommentContainer" style="font-size: 11px; line-height: 14px; margin-bottom: -12px; margin-left: -12px; margin-top: -12px; padding-top: 3px; position: relative; top: 12px; width: 403px;">
<form action="http://www.facebook.com/ajax/ufi/modify.php" class="commentable_item collapsed_comments autoexpand_mode" id="u_jsonp_4_4o" method="post" rel="async" style="margin: 0px; padding: 0px;">
<div class="fbTimelineFeedbackHeader">
<div class="fbTimelineFeedbackActions clearfix" style="background-color: #edeff4; padding: 5px 12px; zoom: 1;">
<span class="fbTimelineFeedbackComments tlFCC373349602748990" style="float: right; margin-left: 5px;"><a aria-controls="js_1" aria-haspopup="true" aria-label="Show comments" aria-owns="js_1" class="fbTimelineFeedbackCommentLoader" data-hover="tooltip" data-tooltip-alignh="right" href="http://www.facebook.com/java.application.programming?ref=hl#" id="js_9" style="color: #3b5998; cursor: pointer; padding-left: 18px; position: relative; text-decoration: initial;"></a></span><span class="fbTimelineFeedbackComments tlFCC373349602748990" style="float: right; margin-left: 5px;"><br /></span><span class="fbTimelineFeedbackComments tlFCC373349602748990" style="float: right; margin-left: 5px;"><br /></span><span class="fbTimelineFeedbackComments tlFCC373349602748990" style="float: right; margin-left: 5px;"><br /></span></div>
</div>
</form>
</div>
<br />
<span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;"><br /></span>
<img src="http://sphotos-d.ak.fbcdn.net/hphotos-ak-ash3/545416_369183293165621_231055591_n.jpg" /><br />
<br />
<div role="article">
<div class="_1x1" style="padding: 10px 0px 15px;">
<div class="userContentWrapper">
<div class="_wk">
<div class="_wk">
<span style="font-size: x-small;"><span style="background-color: yellow; line-height: 18px;">Primitive, Serializavble, Array or Colllection of primitive or serializables and Remote Objects are ship-able across the network for EJB calls.</span></span></div>
<div class="_wk">
<span style="font-size: x-small; line-height: 18px;">Object's serialized copy is shipped over network while calling a method of EJB, while in case of local method call, objects reference is copied as method parameter.</span></div>
<div class="_wk">
<span style="background-color: yellow; font-size: x-small; line-height: 18px;">javax.ejb.RemoteException is a checked exception.</span></div>
<div class="_wk">
<span style="font-size: x-small;"><span style="background-color: yellow; line-height: 18px;">Using Thread join() method</span></span></div>
<div class="_wk">
<span style="font-size: x-small;"><span style="background-color: yellow; line-height: 18px;">=====================</span></span></div>
<div class="_wk">
<span style="background-color: yellow; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">The join() method of a Thread instance can be used to "join" the start of a thread's execution to the end of another thread's execution so that a thread will not start running until another thread has ended. If join() is called on a Thread instance, the currently running thread will block until the Thread instance has finished executing.</span></div>
</div>
</div>
</div>
</div>
<span style="background-color: yellow;"><span style="color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">We can illu</span><span class="text_exposed_show" style="color: #333333; display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">strate this with an example. The RunnableJob class implements Runnable. Its run() method displays the current thread's name and the time at which the run() method is executed. It then sleeps for 1 second.<br /><br />public class RunnableJob implements Runnable {<br /><br />@Override<br />public void run() {<br />Thread thread = Thread.currentThread();<br />System.out.println("RunnableJo<wbr></wbr><span class="word_break" style="display: inline-block;"></span>b is being run by " + thread.getName() + " at " + new Date());<br />try {<br />Thread.sleep(1000);<br />} catch (InterruptedException e) {<br />e.printStackTrace();<br />}<br />}<br /><br />}<br /><br />The ThreadExample class creates a RunnableJob object. It creates 4 threads named "T1", "T2", "T3", and "T4" with the RunnableJob object. It calls start() and then join() on each thread, in order. This blocks the execution of the current (main) thread from proceeding until the thread has completed. This means that the main thread will block for 1 second at each join(), since the RunnableJob sleeps for 1 second. Following this, ThreadExample creates 4 more threads, "T5", "T6", "T7", and "T8". This time, no joins are called on these threads, so the main thread will not block.<br /><br />public class ThreadExample {<br /><br />public static void main(String[] args) throws InterruptedException {<br /><br />RunnableJob runnableJob = new RunnableJob();<br /><br />Thread thread1 = new Thread(runnableJob, "T1");<br />Thread thread2 = new Thread(runnableJob, "T2");<br />Thread thread3 = new Thread(runnableJob, "T3");<br />Thread thread4 = new Thread(runnableJob, "T4");<br /><br />thread1.start();<br />thread1.join();<br />thread2.start();<br />thread2.join();<br />thread3.start();<br />thread3.join();<br />thread4.start();<br />thread4.join();<br /><br />Thread thread5 = new Thread(runnableJob, "T5");<br />Thread thread6 = new Thread(runnableJob, "T6");<br />Thread thread7 = new Thread(runnableJob, "T7");<br />Thread thread8 = new Thread(runnableJob, "T8");<br /><br />thread5.start();<br />thread6.start();<br />thread7.start();<br />thread8.start();<br /><br />}<br /><br />}<br /><br />The console output of the execution of ThreadExample is shown here. Notice from the times displayed that we indeed see that T1, T2, T3, and T4 are all separated by 1 second delays. Also, notice that there are no delays for T5, T6, T7, and T8. Also, notice that T7 executes RunnableJob's run() method before T6. This occurred since there is no guarantee as to the order that T5, T6, T7, and T8 will execute the job code.<br /><br />RunnableJob is being run by T1 at Wed Nov 28 19:38:39 IST 2012<br />RunnableJob is being run by T2 at Wed Nov 28 19:38:40 IST 2012<br />RunnableJob is being run by T3 at Wed Nov 28 19:38:41 IST 2012<br />RunnableJob is being run by T4 at Wed Nov 28 19:38:42 IST 2012<br />RunnableJob is being run by T5 at Wed Nov 28 19:38:43 IST 2012<br />Hello World!-->main<br />RunnableJob is being run by T6 at Wed Nov 28 19:38:43 IST 2012<br />RunnableJob is being run by T7 at Wed Nov 28 19:38:43 IST 2012<br />RunnableJob is being run by T8 at Wed Nov 28 19:38:43 IST 2012</span></span><br />
<span style="background-color: white; color: #333333; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;">Use list.size() for browsing an ArrayList instead of using list.iterator(). Treating ArrayList like an array gives better performance than treating it as LinkedList.</span><br />
<span class="text_exposed_show" style="background-color: white; color: #333333; display: inline; font-family: 'lucida grande', tahoma, verdana, arial, sans-serif; font-size: 13px; line-height: 18px;"></span><br />
<div class="fbTimelineUFI uiCommentContainer" style="margin-bottom: -12px; margin-left: -12px; margin-top: -12px; padding-top: 3px; position: relative; top: 12px; width: 403px;">
<form action="http://www.facebook.com/ajax/ufi/modify.php" class="commentable_item collapsed_comments autoexpand_mode" id="u_jsonp_6_r" method="post" rel="async" style="margin: 0px; padding: 0px;">
<div class="fbTimelineFeedbackHeader">
<div class="fbTimelineFeedbackActions clearfix" style="background-color: #edeff4; padding: 5px 12px; zoom: 1;">
<span class="fbTimelineFeedbackComments tlFCC177941878956431 fbTimelineFeedbackCommentLoader" style="float: right; font-size: 11px; line-height: 14px; margin-left: 5px;"></span><span class="fbTimelineFeedbackLikes tlFLC177941878956431" style="float: right; font-size: 11px; line-height: 14px; margin-left: 5px;"></span><span class="UIActionLinks UIActionLinks_bottom" data-ft="{"tn":"=","type":20}" style="color: #999999; font-size: 11px; line-height: 14px;"></span></div>
</div>
</form>
</div>
Sanjeevhttp://www.blogger.com/profile/15497712476946085125noreply@blogger.com0