<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-650876660236490287</id><updated>2025-08-25T06:19:43.416-07:00</updated><category term="example"/><category term="setup"/><category term="alexa skill"/><category term="aws lambda"/><category term="grovepi"/><category term="iot"/><category term="iot programming"/><category term="jax-ws"/><category term="jaxws"/><category term="learning iot"/><category term="learning iot using rasperry pi"/><category term="maven"/><category term="node js"/><category term="raspberry pi"/><category term="raspberry pi 3"/><category term="raspberrypi"/><category term="spring"/><category term="JFreeChart"/><category term="JFreeChart Example"/><category term="Java  Images"/><category term="JaxWsPortProxyFactoryBean example"/><category term="ajax velocity xml templates"/><category term="angularjs comparsion"/><category term="angularjs features"/><category term="angularjs two-way binding"/><category term="api doc"/><category term="attach images to email"/><category term="call webservice"/><category term="clear solr"/><category term="delete everything from solr"/><category term="delete solr data"/><category term="dojo"/><category term="dojo notes"/><category term="dynamic sql from java"/><category term="email embedding images"/><category term="file processing"/><category term="gae maven"/><category term="google app engine maven setup"/><category term="images email"/><category term="images in email"/><category term="integration"/><category term="j2ee Webapp image"/><category term="jBPM ActionHandler"/><category term="jBPM ActionHandler After Workflow  Node"/><category term="jBPM decision node alternative"/><category term="java  dsl"/><category term="java functional programming"/><category term="java rest api test"/><category term="java rest api testing framework"/><category term="java8"/><category term="jax-ws create webservice"/><category term="json to object"/><category term="json to object utility"/><category term="json to pojo"/><category term="lambdas"/><category term="mongo"/><category term="mongodb"/><category term="mongodb features"/><category term="mongodb intro"/><category term="mongodb tutorial"/><category term="mysql connect by"/><category term="mysql connect by example"/><category term="mysql connect by using procedure"/><category term="nosql"/><category term="oracle array to procedure"/><category term="oracle pass array to stored procedure"/><category term="pass array to oracle stored procedure"/><category term="pass array to stored procedure"/><category term="prototype ajax"/><category term="prototype javascript framework"/><category term="prototype vs ajax"/><category term="redis"/><category term="rest api doc"/><category term="rest api testing java"/><category term="send email from velocity"/><category term="snmp call from java"/><category term="snmpj"/><category term="soap  ui groovyutils"/><category term="soap ui  mock service"/><category term="soap ui dynamic mock service"/><category term="spring REST integration"/><category term="spring boot"/><category term="spring integration"/><category term="spring integration soap webservice"/><category term="spring jaxb webservicetemplate"/><category term="spring soap webservice"/><category term="spring webservice"/><category term="spring webservicetemplate"/><category term="spring ws using jaxws"/><category term="spring-web"/><category term="swagger"/><category term="tomcat"/><category term="velocity email"/><category term="why use dojo"/><title type='text'>Java Stuff</title><subtitle type='html'>Java Stuff...</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default?start-index=26&amp;max-results=25&amp;redirect=false'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>34</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-3587262421273317904</id><published>2017-11-28T10:37:00.003-08:00</published><updated>2017-11-28T11:09:15.795-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="api doc"/><category scheme="http://www.blogger.com/atom/ns#" term="rest api doc"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><category scheme="http://www.blogger.com/atom/ns#" term="spring boot"/><category scheme="http://www.blogger.com/atom/ns#" term="swagger"/><title type='text'>Spring api docs using swagger</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
Just want to write a quick post on need for API specifications for your REST services. This is especially important if you are adopting microservices .&lt;br /&gt;
&lt;br /&gt;
How to provide documentation for your api&#39;s ?&amp;nbsp; What information is required and how to provide this information that can be easily understood and used by other teams?&amp;nbsp; &amp;nbsp;.&lt;br /&gt;
&lt;br /&gt;
This concept is same as WSDL when using a SOAP service , the interesting thing is when ever we want to consume a soap service immediately WSDL comes to mind . But so far I haven&#39;t seen this adoption to REST based service . Industry is moving towards a&amp;nbsp; micro-service model and light weight api&#39;s&amp;nbsp; become ubiquitous this becomes a compelling need.&lt;br /&gt;
&lt;br /&gt;
Swagger comes to the rescue in providing specifications for&amp;nbsp; defining the interface to the rest service.&lt;br /&gt;
&lt;a href=&quot;https://en.wikipedia.org/wiki/OpenAPI_Specification&quot;&gt;https://en.wikipedia.org/wiki/OpenAPI_Specification&lt;/a&gt;. Most important thing is when you use a framework like spring you&amp;nbsp; don&#39;t have to understand swagger to the extent of writing them manually . Spring can do that for you .&lt;br /&gt;
&lt;br /&gt;
Here is how you do it&lt;br /&gt;
&lt;br /&gt;
Include swagger library in pom.xml ( version I use in 2.7.0 , you can use the latest )&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;background-color: #f7f7f7; color: #333333; font-family: &amp;quot;open sans&amp;quot; , sans-serif; font-size: 13px;&quot;&gt;&amp;lt;dependency&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;background-color: #f7f7f7; color: #333333; font-family: &amp;quot;open sans&amp;quot; , sans-serif; font-size: 13px;&quot;&gt;&amp;nbsp;&amp;lt;groupId&amp;gt;io.springfox&lt;/span&gt;&lt;span style=&quot;background-color: #f7f7f7; color: #333333; font-family: &amp;quot;open sans&amp;quot; , sans-serif; font-size: 13px;&quot;&gt;&amp;lt;/groupId&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;background-color: #f7f7f7; color: #333333; font-family: &amp;quot;open sans&amp;quot; , sans-serif; font-size: 13px;&quot;&gt;&amp;nbsp;&amp;lt;artifactId&amp;gt;springfox-swagger2&amp;lt;/artifactId&amp;nbsp;&lt;/span&gt;&lt;span style=&quot;background-color: #f7f7f7; color: #333333; font-family: &amp;quot;open sans&amp;quot; , sans-serif; font-size: 13px;&quot;&gt;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;background-color: #f7f7f7; color: #333333; font-family: &amp;quot;open sans&amp;quot; , sans-serif; font-size: 13px;&quot;&gt;&amp;lt;version&amp;gt;2.7.0&amp;lt;/version&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;background-color: #f7f7f7; color: #333333; font-family: &amp;quot;open sans&amp;quot; , sans-serif; font-size: 13px;&quot;&gt;&amp;lt;/dependency&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span style=&quot;color: #009193;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot; style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot; style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;color: black;&quot;&gt;Enable swagger Configuration . I am using Swagger 2 , use the version that is accepted with in your organization&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
@Configuration&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
@EnableSwagger2&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;s1&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;class&lt;/span&gt; SwaggerConfig { &lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;span class=&quot;s2&quot;&gt;&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;/span&gt;@Bean&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;public&lt;/span&gt; Docket api() {&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span class=&quot;s1&quot;&gt;return&lt;/span&gt; &lt;span class=&quot;s1&quot;&gt;new&lt;/span&gt; Docket(DocumentationType.&lt;span class=&quot;s3&quot;&gt;SWAGGER_2&lt;/span&gt;) &lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;.select() &lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;.apis(RequestHandlerSelectors.any()) &lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;.paths(PathSelectors.any()) &lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;.build();&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
&lt;span class=&quot;Apple-converted-space&quot;&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;}&lt;/div&gt;
&lt;div class=&quot;p1&quot;&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #777777}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco}
span.s1 {color: #931a68}
span.s2 {color: #000000}
span.s3 {color: #0326cc}
&lt;/style&gt;













&lt;/div&gt;
&lt;div class=&quot;p2&quot;&gt;
}&lt;/div&gt;
&lt;br /&gt;
Now when you start your spring boot application&lt;br /&gt;
the api docs are available , it provides all the information for your consumers&lt;br /&gt;
&lt;br /&gt;
http://localhost:8080/v2/api-docs&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiv6KpDpYFQ5yNGGhzoe2wR307ECcNxiAnAX5VbAw7S79AFaaDrdg6jWDi-ngv2Hl2BOYM8ya6QvdOuEUtLmX-bStmdpM-b8fJxDULk97SICjspOnNPrUmxKKPk0SOLl5ILsnAZPZEizQ4t/s1600/Screen+Shot+2017-11-28+at+11.10.22+AM.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiv6KpDpYFQ5yNGGhzoe2wR307ECcNxiAnAX5VbAw7S79AFaaDrdg6jWDi-ngv2Hl2BOYM8ya6QvdOuEUtLmX-bStmdpM-b8fJxDULk97SICjspOnNPrUmxKKPk0SOLl5ILsnAZPZEizQ4t/s1600/Screen+Shot+2017-11-28+at+11.10.22+AM.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnrHyJDFR5o2ZEscIjtBPmzxjIHNRV_7Fs1FlhJcxTqibDhn7g6S5P6hQ813wlv8h0oEcZvXcmfhqEoSdajjVVW1FeEuggr7H7_nZ3MFt2h8FRHdm4AHPDc6Sw_hy2bbUmlMUIT8iJ_Cfu/s1600/Screen+Shot+2017-11-28+at+10.04.26+AM.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgnrHyJDFR5o2ZEscIjtBPmzxjIHNRV_7Fs1FlhJcxTqibDhn7g6S5P6hQ813wlv8h0oEcZvXcmfhqEoSdajjVVW1FeEuggr7H7_nZ3MFt2h8FRHdm4AHPDc6Sw_hy2bbUmlMUIT8iJ_Cfu/s1600/Screen+Shot+2017-11-28+at+10.04.26+AM.png&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
All these data along with the model objects are now part of my specification . I can share this information with other teams that want to consume my service .&lt;br /&gt;
&lt;br /&gt;
As your application grows and model changes the documentation is automatically reflected with the latest information .&lt;br /&gt;
&lt;br /&gt;
Here is an complete example in github&lt;br /&gt;
&lt;a href=&quot;https://github.com/arun2dot0/simple-rest-service-swagger&quot;&gt;https://github.com/arun2dot0/simple-rest-service-swagger&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco; color: #4e9192}
p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco}
span.s1 {color: #009193}
span.s2 {color: #4e9192}
span.s3 {text-decoration: underline}
span.s4 {color: #000000}
span.Apple-tab-span {white-space:pre}
&lt;/style&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/3587262421273317904/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/3587262421273317904' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/3587262421273317904'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/3587262421273317904'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2017/11/spring-api-docs-using-swagger.html' title='Spring api docs using swagger'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiv6KpDpYFQ5yNGGhzoe2wR307ECcNxiAnAX5VbAw7S79AFaaDrdg6jWDi-ngv2Hl2BOYM8ya6QvdOuEUtLmX-bStmdpM-b8fJxDULk97SICjspOnNPrUmxKKPk0SOLl5ILsnAZPZEizQ4t/s72-c/Screen+Shot+2017-11-28+at+11.10.22+AM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-5853656246181425822</id><published>2017-11-15T12:37:00.002-08:00</published><updated>2017-11-15T12:39:36.978-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="file processing"/><category scheme="http://www.blogger.com/atom/ns#" term="java  dsl"/><category scheme="http://www.blogger.com/atom/ns#" term="spring integration"/><title type='text'>Spring Integration file processing using DSL </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Simple Example of File processing using Spring Integration&amp;nbsp;&lt;/h3&gt;
Here is my use case , watch directory for new file and process files of certain format ( e.g *.txt ) . Process them and send to Message queue .&lt;br /&gt;
&lt;br /&gt;
Spring&amp;nbsp; integration can be used for both file processing and message queue . This blog provides example for&amp;nbsp; watching file folder for changes and invoking a message&lt;br /&gt;
&lt;br /&gt;
Its elegant and straight forward , example here watches directory in a certain directory and then process the files of type text .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;a href=&quot;https://github.com/arun2dot0/spring-file-process&quot;&gt;https://github.com/arun2dot0/spring-file-process&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Note : Example here will get you started , if you need to implement in load balanced environment , the &quot;AcceptOnceFileListFilter&quot; may not be enough , you will need persistent storage and use &quot;FileSystemPersistentAcceptOnceFileListFilter&quot;&lt;/i&gt;&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 11.0px Monaco}
span.s1 {text-decoration: underline}
&lt;/style&gt;


&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/5853656246181425822/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/5853656246181425822' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/5853656246181425822'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/5853656246181425822'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2017/11/spring-integration-file-processing.html' title='Spring Integration file processing using DSL '/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-6197197573545634313</id><published>2017-07-14T14:36:00.000-07:00</published><updated>2017-07-16T22:47:44.137-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="alexa skill"/><category scheme="http://www.blogger.com/atom/ns#" term="aws lambda"/><category scheme="http://www.blogger.com/atom/ns#" term="grovepi"/><category scheme="http://www.blogger.com/atom/ns#" term="iot"/><category scheme="http://www.blogger.com/atom/ns#" term="iot programming"/><category scheme="http://www.blogger.com/atom/ns#" term="learning iot"/><category scheme="http://www.blogger.com/atom/ns#" term="learning iot using rasperry pi"/><category scheme="http://www.blogger.com/atom/ns#" term="node js"/><category scheme="http://www.blogger.com/atom/ns#" term="raspberry pi"/><category scheme="http://www.blogger.com/atom/ns#" term="raspberry pi 3"/><category scheme="http://www.blogger.com/atom/ns#" term="raspberrypi"/><category scheme="http://www.blogger.com/atom/ns#" term="redis"/><title type='text'>Fun with IOT</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Publish -&amp;gt; Analyze -&amp;gt; Utilize&lt;/h2&gt;
&lt;br /&gt;
First project that I wanted to try when I looked at GrovePi and the connectors .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Architecture has 3 main components&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Edge - Get data temperature , light and humid readings and publish to the server&lt;/li&gt;
&lt;li&gt;Data Platform - Consume the data provided by Edge and store . Provide api to get analysis on the data&lt;/li&gt;
&lt;li&gt;Client - this can be anything that consumes rest api , mobile app or Alexa ( its fun this way !)&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfQuzXGo-H68DmGYXaV2r3i3kdqjv9xvWPYaBZgv_KAJapRJHeBRMNmam7ojQWMoweO0SRjwmj9H-U_dZ6lZHHM2J_ady_Pp7h-KUbyNf72T2SVQL_vJiBVRVx1bsS595rdOWiEMkxy5vJ/s1600/iot_readings.png&quot; imageanchor=&quot;1&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;342&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfQuzXGo-H68DmGYXaV2r3i3kdqjv9xvWPYaBZgv_KAJapRJHeBRMNmam7ojQWMoweO0SRjwmj9H-U_dZ6lZHHM2J_ady_Pp7h-KUbyNf72T2SVQL_vJiBVRVx1bsS595rdOWiEMkxy5vJ/s640/iot_readings.png&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Edge&lt;/h3&gt;
&lt;br /&gt;
Raspberry Pi and GrovePi module with the connectors act as the Edge .&lt;br /&gt;
Python module continuously &amp;nbsp;reads the readings every minute and pushes&lt;br /&gt;
to the server using Rest api .&lt;br /&gt;
&lt;br /&gt;
You need : &amp;nbsp;Raspberry and Grove pi with the Grove Sensors for Temp/Humidity ,light and Sound&lt;br /&gt;
Github Link : &lt;a href=&quot;https://github.com/arun2dot0/APIPython&quot;&gt;https://github.com/arun2dot0/APIPython&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;Data Platform&lt;/h3&gt;
&lt;br /&gt;
API interfaces to consume the data from edge and store . Developed using Spring Boot&lt;br /&gt;
Data can be stored in any db of your choice based on the analytical needs .&lt;br /&gt;
This project I have used Redis to store maximum of&lt;br /&gt;
100 values to provide simple analytics ( Average and Latest readings) on that data .&lt;br /&gt;
Readings are also exposed as rest api .&lt;br /&gt;
&lt;br /&gt;
You need : Cloud setup ( google cloud or aws ) . I setup my server in google cloud . If you need same setup&lt;br /&gt;
details are in the github link&lt;br /&gt;
Github Link :&lt;a href=&quot;https://github.com/arun2dot0/metrics-rest-service-redis.git&quot;&gt;https://github.com/arun2dot0/metrics-rest-service-redis.git&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;Client&lt;/h3&gt;
Rest API exposed can be consumed by mobile app . Its fun to integrate with Alexa to&lt;br /&gt;
get the readings . You will find the details in github link&lt;br /&gt;
&lt;br /&gt;
Alexa : you will need to create aws account and code using aws lambda&lt;br /&gt;
Github Link :&lt;a href=&quot;https://github.com/arun2dot0/AlexaSensorDataNodeJS&quot;&gt;https://github.com/arun2dot0/AlexaSensorDataNodeJS&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It&#39;s a fun project and just to get hands on IOT . Edge , Platform and Client&lt;br /&gt;
are totally decoupled and can be easily changed for a different use case .&lt;br /&gt;
Although it&#39;s a simple project it get exposure to variety of technologies&lt;br /&gt;
Python , Java , Spring Boot , Redis , Node js and AWS Lambda&#39;s&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Demo&lt;/h4&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;iframe allowfullscreen=&quot;&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/ucreQ1SE5yg/0.jpg&quot; frameborder=&quot;0&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/ucreQ1SE5yg?feature=player_embedded&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
Did you find it useful , did you try it , &amp;nbsp;hack it , improve it ?&lt;br /&gt;
do share in the comments below&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/6197197573545634313/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/6197197573545634313' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/6197197573545634313'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/6197197573545634313'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2017/07/fun-with-iot.html' title='Fun with IOT'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfQuzXGo-H68DmGYXaV2r3i3kdqjv9xvWPYaBZgv_KAJapRJHeBRMNmam7ojQWMoweO0SRjwmj9H-U_dZ6lZHHM2J_ady_Pp7h-KUbyNf72T2SVQL_vJiBVRVx1bsS595rdOWiEMkxy5vJ/s72-c/iot_readings.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-6960911253192344791</id><published>2017-06-06T15:37:00.003-07:00</published><updated>2017-08-09T16:02:17.376-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="alexa skill"/><category scheme="http://www.blogger.com/atom/ns#" term="aws lambda"/><category scheme="http://www.blogger.com/atom/ns#" term="grovepi"/><category scheme="http://www.blogger.com/atom/ns#" term="iot"/><category scheme="http://www.blogger.com/atom/ns#" term="iot programming"/><category scheme="http://www.blogger.com/atom/ns#" term="learning iot"/><category scheme="http://www.blogger.com/atom/ns#" term="learning iot using rasperry pi"/><category scheme="http://www.blogger.com/atom/ns#" term="node js"/><category scheme="http://www.blogger.com/atom/ns#" term="raspberry pi"/><category scheme="http://www.blogger.com/atom/ns#" term="raspberry pi 3"/><category scheme="http://www.blogger.com/atom/ns#" term="raspberrypi"/><title type='text'>IoT hands on using AWS Lamba -  Spring Boot - RaspberryPi GrovePi</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOtC24CBAsY6X_U6oNLYaD45iSdyt8sBOUd-0gHwi0qWM5vZ2qt6adeNjKs9LIY2N1uJOUm-QIBfUTLyeDE2dJ7GXhqq-aXhZ9kQSmqY3DygKX_D8B3zAB-5CD9yen9hsTntOiYtP19SU8/s1600/rasp-grove1.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; float: right; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;240&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOtC24CBAsY6X_U6oNLYaD45iSdyt8sBOUd-0gHwi0qWM5vZ2qt6adeNjKs9LIY2N1uJOUm-QIBfUTLyeDE2dJ7GXhqq-aXhZ9kQSmqY3DygKX_D8B3zAB-5CD9yen9hsTntOiYtP19SU8/s320/rasp-grove1.jpg&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;Started playing with the &lt;a href=&quot;https://www.amazon.com/GrovePi-Starter-Kit-Dexter-Industries/dp/B00TXTZ5SQ&quot;&gt;GrovePi Starter kit&lt;/a&gt; for RaspberryPi.&lt;br /&gt;
I chose GrovePi &amp;nbsp;this as there is no complex wiring, have a look at how nicely it fits the Raspberry pi .&lt;br /&gt;
&lt;br /&gt;
I got involved &amp;nbsp;and able to get some sensor data easily using GrovePi Software, checkout&lt;br /&gt;
projects in&lt;br /&gt;
&lt;a href=&quot;https://github.com/DexterInd/GrovePi&quot;&gt;https://github.com/DexterInd/GrovePi&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
Here is the tutorial on the first project ..&lt;br /&gt;
&lt;a href=&quot;https://www.dexterindustries.com/GrovePi/projects-for-the-raspberry-pi/raspberry-pi-led-tutorial/&quot;&gt;https://www.dexterindustries.com/GrovePi/projects-for-the-raspberry-pi/raspberry-pi-led-tutorial/&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtdodEg7yH5CsCSqVKqeV6GJVQTf3l8QwtIka1NyEjHbRDoG0pgutmYoa-fBYtMbbnDgtCpU82sMvwcoh6Snl9TLOHd9tPqT6xDVZl94aWJaFNJRzPRIMcaBfbTv7gPf-3PXcxIL-Ylp1O/s1600/weather-proj.jpg&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgtdodEg7yH5CsCSqVKqeV6GJVQTf3l8QwtIka1NyEjHbRDoG0pgutmYoa-fBYtMbbnDgtCpU82sMvwcoh6Snl9TLOHd9tPqT6xDVZl94aWJaFNJRzPRIMcaBfbTv7gPf-3PXcxIL-Ylp1O/s320/weather-proj.jpg&quot; width=&quot;287&quot; /&gt;&lt;/a&gt;
Journey starts ...&lt;/h3&gt;
After that I did couple of others , like home weather display and twitter feed .&lt;br /&gt;
I got excited now I want to do more , I want to do analytics . So &amp;nbsp;was thinking about gathering data from sensors- temperature , humidity &amp;nbsp;, sound and light readings and send it to thecloud for doing analytics . Python was new to me , but want to use it any way as I can learn a new language.It was easy and I wasn&#39;t stuck &amp;nbsp;with any thing .It was fun learning as well .&lt;br /&gt;
&lt;i&gt;Go Python&lt;/i&gt;&amp;nbsp;!&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Data Layer&amp;nbsp;&lt;/h3&gt;
Now I have to push data to a Data layer . Why not use an instance in &amp;nbsp;Google Cloud (they are giving 300$ in free credit!) .Rest API in cloud will be based on Java and Spring Boot .&lt;br /&gt;
Data will be stored in redis , as I don&#39;t want to store a lot of data . Just last 100 readings&lt;br /&gt;
or so and get the current and average readings from &amp;nbsp;the sensors ( this project info is in &lt;a href=&quot;http://ajaxrocks.blogspot.com/2017/07/fun-with-iot.html&quot;&gt;http://ajaxrocks.blogspot.com/2017/07/fun-with-iot.html&lt;/a&gt; ) for this but current integration is only for PubNub&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Alexa Skill&lt;/h3&gt;
&lt;iframe allowfullscreen=&quot;&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/v89i-w7BUmo/0.jpg&quot; frameborder=&quot;0&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/v89i-w7BUmo?feature=player_embedded&quot; style=&quot;clear: right; float: right;&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;While all this was going on , I see Alexa app demos . So I started looking into that&lt;br /&gt;
as well . Started building a sample app , using AWS Lambda&#39;s .. hey!! ..always want to get my hands on server-less programming as well . Alexa sample app Tutorial used node js .. this is good , I can sharpen my node js skills . Okay I built the sample app .. It was so much fun , the sample app used Facts as an array (that are &amp;nbsp;hardcoded ) . When you invoke it using Alexa , it chooses one of the Fact&lt;br /&gt;
randomly . Fun part is you change all the facts and then keep asking facts !! &amp;nbsp;. See programming can be fun&lt;br /&gt;
&lt;br /&gt;
Picture Time ..&lt;br /&gt;
&lt;div&gt;
&lt;div&gt;
&lt;iframe allowfullscreen=&quot;&quot; class=&quot;YOUTUBE-iframe-video&quot; data-thumbnail-src=&quot;https://i.ytimg.com/vi/-bvwUisHfb0/0.jpg&quot; frameborder=&quot;0&quot; height=&quot;266&quot; src=&quot;https://www.youtube.com/embed/-bvwUisHfb0?feature=player_embedded&quot; style=&quot;clear: right; float: right;&quot; width=&quot;320&quot;&gt;&lt;/iframe&gt;Concept is actually the time triggered to take&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
picture instead of LED blink&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div dir=&quot;rtl&quot; style=&quot;text-align: right;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;/h3&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Messaging using PubNub&lt;/h3&gt;
While all this was going on , I learnt about &lt;a href=&quot;https://en.wikipedia.org/wiki/PubNub&quot;&gt;PubNub&lt;/a&gt; in DevNetCreate conference&lt;br /&gt;
It provides Infrastructure as a Service for doing messaging . they have SDK for almost all the languages I use .Cool , now I can invoke the GroveSensors ( Light on ! ) using PubNub message . Tried it it worked great .. hey .. Next part if you haven&#39;t already guessed I can use Alexa to invoke it .. Yeah !&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Rewiring to use API&amp;nbsp;&lt;/h3&gt;
All set now I invoke , node js call to PubNub worked great .Deployed to AWS , now it just doesn&#39;t want to work !! Hmmmm... may be I am doing something wrong .. setup security , network interfaces .. still not working .. Don&#39;t know what the real reason was .Why waste time on this , let me set this up as a rest api in google cloud and use Alexa skill ( node js) to call that api... hey that can work .... setup the api .. changed the alexa app and everything worked like a charm&lt;br /&gt;
&lt;br /&gt;
Shoutout to Alexa SDK, Google Cloud , PubNub , Raspberry Pi and Grove Pi ... Thanks Guys&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Architecture&lt;/h3&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp6myuvv-YaVTDNDeiACVrdgoSN4zR533zkzmkVG4PEOODVqlmJU_dHuhzVwOM2z9t5XpRMu4AotZHMidHp81t4uJU42PSncy5HqsrUCaVR6Aj7JaQD05qOEY84VgsmB8CFYyHIFVPscSk/s1600/iot.jpg&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; data-original-height=&quot;429&quot; data-original-width=&quot;761&quot; height=&quot;360&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhp6myuvv-YaVTDNDeiACVrdgoSN4zR533zkzmkVG4PEOODVqlmJU_dHuhzVwOM2z9t5XpRMu4AotZHMidHp81t4uJU42PSncy5HqsrUCaVR6Aj7JaQD05qOEY84VgsmB8CFYyHIFVPscSk/s640/iot.jpg&quot; width=&quot;640&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Learn it &amp;nbsp;,Use it , Hack it &amp;nbsp;&lt;/h3&gt;
This project was fun , it also helped understand technologies involved with IOT better .&lt;br /&gt;
Learn &amp;nbsp;new languages in a very pragmatic way . I have all the code I used in the github links&lt;br /&gt;
, so play with them , hack them for your use case , make them better ..&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
github links&lt;/h3&gt;
Code for AWS Lambda ( Node js)&lt;br /&gt;
&lt;a href=&quot;https://github.com/arun2dot0/AlexaNodeJS.git&quot;&gt;https://github.com/arun2dot0/AlexaNodeJS.git&lt;/a&gt;&lt;br /&gt;
Code for API &amp;nbsp;( I setup in google cloud)&lt;br /&gt;
&lt;a href=&quot;https://github.com/arun2dot0/metrics-rest-service-redis.git&quot;&gt;https://github.com/arun2dot0/metrics-rest-service-redis.git&lt;/a&gt;&lt;br /&gt;
Code for Raspberry pi ( Python )&lt;br /&gt;
&lt;a href=&quot;https://github.com/arun2dot0/PubNubPython.git&quot;&gt;https://github.com/arun2dot0/PubNubPython.git&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/6960911253192344791/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/6960911253192344791' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/6960911253192344791'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/6960911253192344791'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2017/06/iot-hands-on-using-aws-lamba-spring.html' title='IoT hands on using AWS Lamba -  Spring Boot - RaspberryPi GrovePi'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgOtC24CBAsY6X_U6oNLYaD45iSdyt8sBOUd-0gHwi0qWM5vZ2qt6adeNjKs9LIY2N1uJOUm-QIBfUTLyeDE2dJ7GXhqq-aXhZ9kQSmqY3DygKX_D8B3zAB-5CD9yen9hsTntOiYtP19SU8/s72-c/rasp-grove1.jpg" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-1687982327219763620</id><published>2016-09-23T15:06:00.002-07:00</published><updated>2016-09-29T16:38:06.217-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java rest api test"/><category scheme="http://www.blogger.com/atom/ns#" term="java rest api testing framework"/><category scheme="http://www.blogger.com/atom/ns#" term="rest api testing java"/><title type='text'>Simple framework to Test your REST API </title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
REST api testing made easy .&lt;br /&gt;
&lt;br /&gt;
I am constantly involved in developing backend services for team and&lt;br /&gt;
worked on simple framework to test the services. Here is thought behind the framework .&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Http Responses Validation&lt;/h4&gt;
Services provide a response to indicate if the request was successful .&lt;br /&gt;
Usual Check &amp;nbsp;is HTTP Status &amp;nbsp;=200 . Also usually &amp;nbsp;part of JSON response is used to validate&lt;br /&gt;
eg &amp;nbsp;&quot;status&quot;:&quot;OK&quot; . Framework adapts to these conditions and would validate the response for all request . More test can be easily added on top of base validation&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;Set URL , HTTP Headers once&amp;nbsp;&lt;/h4&gt;
Base URL and the HTTP Headers to be setup can be setup once&lt;br /&gt;
and can be reused for all the tests .&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;Use Mustache templates to define HTTP Post and Put Payload&lt;/h4&gt;
&lt;br /&gt;
payload for POST and PUT are usually JSON and this can be easily setup as templates&lt;br /&gt;
This is the one from my example&lt;br /&gt;
&lt;i&gt;{&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &quot;firstName&quot;:&quot;{{firstName}}&quot;,&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &quot;lastName&quot;:&quot;{{lastName}}&quot;,&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &quot;phone&quot;:&quot;{{phone}}&quot;,&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &quot;email&quot;:&quot;{{email}}&quot;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;}&lt;/i&gt;&lt;br /&gt;
Data for the template can be driven from JSON.&lt;br /&gt;
Framework converts &amp;nbsp; JSON -&amp;gt; Java Object &amp;nbsp;and Object is used to populate the template .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Example of JSON data to populate the above template&lt;br /&gt;
&lt;i&gt;{&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp;&quot;firstName&quot;:&quot;Arun&quot;,&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp;&quot;lastName&quot;:&quot;Selvamami&quot;,&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp;&quot;phone&quot;:&quot;000-000-000&quot;,&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;&amp;nbsp; &amp;nbsp;&quot;email&quot;:&quot;arun2dot0@gmail.com&quot;&lt;/i&gt;&lt;br /&gt;
&lt;i&gt;}&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Easily setup for multiple environments&amp;nbsp;&lt;/h4&gt;
You can rerun the test for other environments by setting up different data&lt;br /&gt;
and changing the Base url&lt;br /&gt;
&lt;br /&gt;
framework is powered by RestAssured , hamcrest and mustache&lt;br /&gt;
&lt;br /&gt;
Check out the code at &lt;a href=&quot;https://github.com/arun2dot0/TestRest&quot;&gt;https://github.com/arun2dot0/TestRest&lt;/a&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/1687982327219763620/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/1687982327219763620' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/1687982327219763620'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/1687982327219763620'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2016/09/easily-framework-to-test-your-rest-api.html' title='Simple framework to Test your REST API '/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-8163531106306759979</id><published>2015-01-19T12:02:00.002-08:00</published><updated>2015-01-19T12:05:29.561-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="angularjs comparsion"/><category scheme="http://www.blogger.com/atom/ns#" term="angularjs features"/><category scheme="http://www.blogger.com/atom/ns#" term="angularjs two-way binding"/><title type='text'>AngularJS</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;

&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;

&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
AngularJS has been attracting a lot of attention for all the good reasons , this article is to look at angular &amp;nbsp;features and compare it to other frameworks .&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Two-Way Binding&lt;/h4&gt;
&lt;div&gt;
Let&#39;s look at the best and the dominating factor on why you should look at AngularJS . Its the two way binding . Most Javascript frameworks adapt the Model-View paradigm and the View is rendered from the model when the page is rendered . But what happens after that when the model changes or view gets updates? there are callbacks that the UI developers have to work with to make sure that the View is in sync with the model and the model gets updated with changes in View . &amp;nbsp;But AngularJS provides this capability by default &lt;i&gt;without any callbacks &lt;/i&gt;the Two-way binding is provided by default ( for Code - Have a look at the example provided under Directive )&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFkBjmsmwjs-ilb_g8SPv5zEwEHwjnzozphGQIfbsARR1jCXNdKeZB-h5TYD3BsKwlkNO9jl3_zefdobHy1ZZUu0myUeNZQDhtr_U3lQn5cpaYvU4bbjpFlT-yFmBlc33IqS2Dsol8276T/s1600/twoway-bind.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: right;&quot;&gt;&lt;img border=&quot;0&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFkBjmsmwjs-ilb_g8SPv5zEwEHwjnzozphGQIfbsARR1jCXNdKeZB-h5TYD3BsKwlkNO9jl3_zefdobHy1ZZUu0myUeNZQDhtr_U3lQn5cpaYvU4bbjpFlT-yFmBlc33IqS2Dsol8276T/s1600/twoway-bind.png&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Simple JS&lt;/h4&gt;
All the code for angular js doesn&#39;t require you to understand any new syntax or framework &amp;nbsp;. Its all fully Javascript. So you will already understand most of the &amp;nbsp;code even without knowing angular&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Easy to adapt and get Started&lt;/h4&gt;
Requires simple js include angular.js , angular-animation.js&lt;br /&gt;
&lt;i&gt;Example&lt;/i&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;html ng-app&amp;gt;

&amp;lt;body&amp;gt;
  &amp;lt;h1&amp;gt;Hello {{1 + 2}}&amp;lt;/h1&amp;gt;

&amp;lt;script src=&quot;https://ajax.googleapis.com/ajax/libs/angularjs/1.2.19/angular.js&quot;&amp;gt;
&amp;lt;/script&amp;gt;
&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;h4&gt;
Advantages&lt;/h4&gt;
&lt;h4&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;/div&gt;
&lt;ol style=&quot;font-weight: normal;&quot;&gt;
&lt;li&gt;&amp;nbsp; Reduce boilerplate&lt;/li&gt;
&lt;li&gt;&amp;nbsp; Use default structure that is self explanatory&lt;/li&gt;
&lt;li&gt;&amp;nbsp; Easy to test&amp;nbsp;&lt;/li&gt;
&lt;/ol&gt;
&lt;div style=&quot;font-weight: normal;&quot;&gt;
&lt;/div&gt;
&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Directive&lt;/h4&gt;
Directives are the AngularJS way of dealing with DOM manipulation and providing &amp;nbsp;the two-way binding , they are also responsible for &amp;nbsp;rendering and providing reusable UI widgets. They can be used for simple things like reusing HTML snippets or to more complex things like modifying the behavior of existing elements (like ng-show, ng-class) or integrating with third-party components like charts . Let&#39;s look at an example of ng-repeat&lt;br /&gt;
&lt;i&gt;Example&lt;/i&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;div ng-repeat=‘item in cart.items’&amp;gt;
          &amp;lt;span ng-bind=‘item.name’&amp;gt;&amp;lt;/span&amp;gt;
          &amp;lt;button ng-click=‘cart.delete($index)’&amp;gt;delete&amp;lt;/button&amp;gt;
  &amp;lt;/div&amp;gt;
 javascript

 var myApp = angular.module(‘coolApp’,[]);
 myApp.controller(‘CartCtrl’ , function () {
                                              this.items =[{ name:’Choclate’},
                                                                  { name:’bread’},
                                                                   { name:’Cofee’}];
 this.delete = function(index) {
                                              this.items.splice(index,1);
                       };
 });

&lt;/pre&gt;
&lt;div&gt;
The delete function just changes the model without any updates to the View, why ? because there is no need to do this , the view is automatically updated based on changes to the model . This is the power of two-way binding&amp;nbsp;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Databinding&lt;/h4&gt;
&lt;div&gt;
Databinding is achieved in javascript by using the double curly brackets - &amp;nbsp;{{}} &amp;nbsp; .&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Best way to understand this is by an example&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;Example&lt;/i&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;hello.js 
   this.greeting =‘Hello!’;

hello.html 
   {{greeter.greetings}}
   &amp;lt;input ng-model=‘greeter.greetings&#39;&amp;gt;
&lt;/pre&gt;
ng-cloak can be used to avoid unset values on load , can also be done by ng-bind

&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Controller (ng-controller)&lt;/h4&gt;
&lt;/div&gt;
&lt;div&gt;
Controller is a specialized Directive ng-controller and does the following&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&amp;nbsp;Expose model to View&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Expose functions to handle UX&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Update model to change the view&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Instantiate once per use in templates&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Can request $scope&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
$scope - can be nested , without proper $scope read can be propagated to the nested levels however write is always local to the method . To avoid this use $scope&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;myapp.Controller(‘GreetCtrl’ , function ( $scope ) {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;$scope.greeter = { greeting:’Hi’}&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; });&lt;/div&gt;
&lt;div&gt;
$watch(expression,callback ) &amp;nbsp;- executes callback when expression changes&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
$apply - used when the model changes outside the angular control&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Filters&lt;/h4&gt;
&lt;div&gt;
Mainly used for formatting the output and &amp;nbsp;the built in filters for currency and date&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;Example&lt;/i&gt;&lt;/div&gt;
&lt;div&gt;
{{invoice.total | currency}}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
custom filters can be added using&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
myApp.filter( ‘myfilter’ , function() { …});&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Server Interaction&lt;/h4&gt;
basically done by using $http or by $resource &amp;nbsp;(for REST) , there are also other options&lt;br /&gt;
&lt;div&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Restangular&lt;/li&gt;
&lt;li&gt;Angular Fire&lt;/li&gt;
&lt;li&gt;Breeze JS&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;i&gt;Example&lt;/i&gt;&lt;/div&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;$http.get(‘/someurl’);
$http.get(‘/someurl’).success( function ( data,status,header,config)  { ….})
                                 .error( function ( data,status,header,config)  { ….}). 

&lt;/pre&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ng-view&gt; &amp;nbsp;- specifies where angular is work on the view&lt;/ng-view&gt;&lt;/div&gt;
&lt;div&gt;
$routeProvider &amp;nbsp;for configuration specific to url &amp;nbsp;, following can be configured&lt;/div&gt;
&lt;ol&gt;
&lt;li&gt;&amp;nbsp;Controller&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Template&lt;/li&gt;
&lt;li&gt;&amp;nbsp;URL&amp;nbsp;&lt;/li&gt;
&lt;li&gt;custom values&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/8163531106306759979/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/8163531106306759979' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/8163531106306759979'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/8163531106306759979'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2015/01/angularjs.html' title='AngularJS'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhFkBjmsmwjs-ilb_g8SPv5zEwEHwjnzozphGQIfbsARR1jCXNdKeZB-h5TYD3BsKwlkNO9jl3_zefdobHy1ZZUu0myUeNZQDhtr_U3lQn5cpaYvU4bbjpFlT-yFmBlc33IqS2Dsol8276T/s72-c/twoway-bind.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-7223600831835448842</id><published>2015-01-15T12:24:00.003-08:00</published><updated>2015-05-06T17:41:24.358-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="mongodb"/><category scheme="http://www.blogger.com/atom/ns#" term="mongodb features"/><category scheme="http://www.blogger.com/atom/ns#" term="mongodb intro"/><category scheme="http://www.blogger.com/atom/ns#" term="mongodb tutorial"/><category scheme="http://www.blogger.com/atom/ns#" term="nosql"/><title type='text'>MongoDB</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;

&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;


&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Just a few years back all &amp;nbsp;data was usually &amp;nbsp;stored in relational db &amp;nbsp;, like Oracle or MySQL. Application developers had some form of understanding about the database and the tables and using them . Relational Databases supported ACID (Atomicity, Consistency, Isolation, Durability) and were the right choice for some of the applications . The transaction and join capabilities came at a cost of performance and scalability , which couldn&#39;t be solved easily without hardware upgrades and admin intervention . NoSQL databases provides a alternative with Replication and scalability features built in , and would provide a lot better alternative for high-traffic , performance oriented systems .Article is to describe features of MongoDB  with examples and the limitations&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;i&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Comparison with Relational DB&lt;/span&gt;&lt;/i&gt;&lt;/h4&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Relational DB  is normalized and unused columns are left as null&#39;s  . Table relations are not easily recognizable by just looking at data and usually would require understanding of the table design and the mapping information . &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;Comparing to Mongo DB , there is no defined  schema . Actual data represents the structure  and optional values are simply left blank . Flexible design provides easily understanding but there is replication of data when dealing with relations ,this is the tradeoff.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: black; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;MongoDB can horizontally scale like web servers . De-Normalized focussed on performance vs Join and &lt;/span&gt;&lt;span style=&quot;font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;Best Suited for - caching , event logging and High volume traffic.&lt;/span&gt;&lt;span style=&quot;font-size: 15px; font-style: italic; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Scaled for reading and writing using replicated set and Sharding &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;-webkit-text-stroke-width: 0px; color: black; font-family: Times; font-size: medium; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;&quot;&gt;
&lt;div style=&quot;font-style: normal; margin: 0px;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-style: normal; margin: 0px;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;MongoDB is not ideal for - Transactional applications , ad-hoc business intelligence , problems that require SQL .&lt;/span&gt;&lt;/div&gt;
&lt;div style=&quot;font-style: normal; margin: 0px;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;h4 style=&quot;margin: 0px; text-align: left;&quot;&gt;
&lt;i&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Features&lt;/span&gt;&lt;/i&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;MongoDB stores data as documents (BSON) and not rows . Rows are flat vs Documents that has embedded structure with other documents and arrays . Arrays can also have arrays inside &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;b id=&quot;docs-internal-guid-3a36e589-ea66-2b4f-fe39-1174280fd6a4&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;i&gt;References can be achieved in MongoDB like Relational databases, however its up to the user to maintain the relational reference - Mongo doesn’t support the relational integrity&lt;/i&gt;&lt;/span&gt;&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;MapReduce functions are available and  are written in JavaScript .&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;&lt;i&gt;Advantages &lt;/i&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;ul style=&quot;line-height: 1.15; text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;Replication and HA capabilities built-in . Its a &lt;/span&gt;&lt;span style=&quot;font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;Considerable advantage when moving to production as the data can scale horizontally &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;Map reduce and Aggregation framework is built in &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;color: black; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;GRID FS - can use  Mongo as File system . Provides a way to use Mongo just as file system&lt;/span&gt;&lt;span style=&quot;font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;. Effective when the application requires File . Working with Java the document can be accessed by java.io.File ,&lt;/span&gt;&lt;span style=&quot;font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;File can be breaker to chunks . When sharing however chunks cannot be stored in different shard &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;i&gt;BSON&lt;/i&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-weight: normal; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-weight: normal; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;color: black; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span id=&quot;docs-internal-guid-3a36e589-ea47-c5d8-1c6a-23070c3e939b&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-weight: normal; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;span style=&quot;color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Actual data ( Documents ) are stored as BSON ( Binary JSON ) .Driver takes care of transforming JSON &amp;gt;&amp;lt; BSON.&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-weight: normal; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;/div&gt;
&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;i&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/i&gt;&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;i&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;ObjectID&lt;/span&gt;&lt;/i&gt;&lt;/h4&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;ObjectID - unique id for each document . It can be generated without locking &amp;nbsp;or sequencing and is unique every time irrespective of the number of machines used. uses Time,machine id and process id and &amp;nbsp;sequence &amp;nbsp;for generation of object id . ObjectID is created if not provided during insert .&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-variant: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;i&gt;Index&lt;/i&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Mongo uses 3 kinds of indexes &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;normal using Strings numbers&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;text based indexing&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;Geospatial index based on location  , very useful for location based searches .&lt;/span&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Insert has to capture the location based on 2d or 2dsphere and search can be based on &lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;ol&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;$near around a point&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;min and max range within 2d space&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;around a particular area ( circle , box or arbitrary polygon ) using $within&lt;/span&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-weight: normal; line-height: 1.15; white-space: pre-wrap;&quot;&gt;First index from the scan is used for query and other attempts to find the scan are disregarded after the index is found .&lt;/span&gt;&lt;/h4&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; font-weight: normal; line-height: 1.15; white-space: pre-wrap;&quot;&gt;Index can be ensured using ensureIndex . query can &lt;/span&gt;&lt;span style=&quot;font-size: 15px; font-weight: normal; line-height: 1.15; white-space: pre-wrap;&quot;&gt;also use hints ( not a good idea because query analyzer &amp;nbsp;knows best ) &lt;/span&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-weight: normal; line-height: 1.15; white-space: pre-wrap;&quot;&gt;&lt;i&gt;Examples&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;db.collection.find(username:’foo’, city:’New York’}).hint({‘username’:1})&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;e.g &lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;db.posts.ensureIndex({“comments.author”:1})
db.posts.find({“comments.author”:”eliot”})
&lt;/pre&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;b style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Sort on large amount of data without index will result in error &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Full table scans - bad - so use indexes &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;b style=&quot;font-weight: normal;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/b&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Sparse index&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; introduced in mongo 2.0 to reduce storage of null fields&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; downside &amp;nbsp;can’t answer “not in index” queries.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;i style=&quot;line-height: 1.15;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Arrays&lt;/span&gt;&lt;/i&gt;&lt;/h4&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;Multiple data fields e.g author for books can be represented as an array . &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot;&gt;
&lt;/span&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Index on array works on each field ( each array item ) and also the array as a whole . This makes retrieval of data much easier &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Search can be powerful as the matching items can be easily searched from one table &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; font-style: italic; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$Operators&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; font-style: italic; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$in &amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; font-style: italic; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$or&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; font-style: italic; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;$set ( for update ) -&lt;/span&gt;&lt;span style=&quot;font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;for array the item that matches can be individually updated e.g {$set:{“author.$.company”:”abc corp”}}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span id=&quot;docs-internal-guid-3a36e589-eaa8-c9b4-73dc-c0b356c920fc&quot; style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;i&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Examples&lt;/span&gt;&lt;/i&gt;&lt;/h4&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;Example of some of the basic commands used in MongoDB&lt;/span&gt;&lt;/div&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;show dbs
show collections
  system.indexes special collection 
db.scores.findOne()
db.scores.distinct(“name”)
db.scores.count()
db.scores.count({“name”:”exam”})

fields returned can be included  (or) excluded but not both 
db.scores.find({“score”:{$gt:95}}, {“score”,1,_id:0})
sort  can be done by specifying field name and order ( 1 for ascending)  and (-1 for desc )

student ascending
 db.scores.find({“score”:{$gt:95}}, {“score”,1,“student”,1,_id:0}).sort({“student”:1})
student ascending and score descending 
 db.scores.find({“score”:{$gt:95}}, {“score”,1,“student”,1,_id:0}).sort({“student”:1,”score”,-1})

unset example
update all grade - first param {} is for all 
 db.scores.update({},{$unset:{“grade”:1}},false,true)
 
push / pull  ( to push items to array or pull items to array ) 
 add array item
db.books.update({“_id”: ObjectId(“16 digit text”)},
                            {$push:{“tags”:”classic and important”}})

addToSet can be added only once 
db.books.update({“_id”: ObjectId(“16 digit text”)},
                            {$addToSet:{“tags”:”classic and important”}})

 delete array item
db.books.update({“_id”: ObjectId(“16 digit text”)},
                            {$pull:{“tags”:”classic and important”}})

pullAll pushAll for multiple items

$inc - increment a field by a given value 
mongo figures out the increment value - takes away issue of atomicity that may be required to be done with web server &lt;/pre&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;i&gt;Deployment&lt;/i&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: italic; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: italic; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;RAM - frequently used data is stored in Ram for faster retrieval . Disk access is 100 times more slower than RAM . &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Deployment trick - fetch required data forcibly using query to have the data available in RAM for the users &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Production should be 64 bit as 32 bit supports only 2gb limit &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;b id=&quot;docs-internal-guid-3a36e589-ea49-6357-f7b7-9c44b756d574&quot; style=&quot;font-weight: normal;&quot;&gt;&lt;br /&gt;&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Mongo will pre allocate data so file systems matter - posix_fallocate() on linux system works fine with just marking start and end on memory map &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;reading data from memory will have padding to allow changes in data to be written to disk .&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;toString on any mongo data has the JSON information , this is very useful for debugging &lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;i&gt;Driver&#39;s and working with applications&lt;/i&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Native driver - How to &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;uses DBObject - Map interface with key value pair - Key -&amp;gt; “string” and Value -&amp;gt; Object of Mongo Data&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;ODM - Object Document mapping &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; Morphia &amp;nbsp;- Like JPA , Annotation Driven and Written for Mongo so it’s customized for Mongo&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; Spring-Data-Document - less strongly coupled as its used for all NoSQL databases , recommended for Spring &amp;nbsp;veterans&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Mongo has support for Hadoop and hadoop components - Pig , Hive &lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Capped Collection&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; designed for replication , No id , No Deletes , maintained in serration order , Updates only for it won’t grow above padding&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;Tailable Cursors &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;background-color: transparent; color: black; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap;&quot;&gt; &amp;nbsp;&amp;nbsp;like tail -f in unix , efficient , “Await” cursor can pull data until more documents arrive to the particular query&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;findAndModify - can use in specialized scenario where changed information is required back from Mongo&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;h4 style=&quot;line-height: 1.15; text-align: left;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;i&gt;Sharding and Replication&lt;/i&gt;&lt;/span&gt;&lt;/h4&gt;
&lt;div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;Scaling is not just about adding servers it has the following components&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt; Operations/Sec&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt; Storage needs go up - Capacity and IOPs&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt; Complexity goes up &lt;/span&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ul&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;Optimization and tuning is based of &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt; Schema and Index Design&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt; O/S Tuning&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt; Hardware &lt;/span&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ul&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;Vertical Scaling - Expensive and may be impossible when dealing with certain cloud based systems&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;Scaling can be done by &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Schema &amp;amp; Index Design&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt; Sharding &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt; Replication&lt;/span&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ul&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;div style=&quot;font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;Schema &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Use Embedded vs linking , facts to consider&lt;/span&gt;&lt;/li&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Round trip to DB&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Disk seek time&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;size of data to R/W&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Use Partition vs full document writes ( $set uses partial write )&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Use Partial vs full document read&lt;/span&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ul&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;div style=&quot;font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt; Index &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Mongo can use only one index at a time for a query &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Index common query  , but do not over index . (A)  and (A,B) are equivalent &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Right-balanced index&lt;/span&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ul&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;margin-bottom: 0pt; margin-top: 0pt;&quot;&gt;
&lt;div style=&quot;font-size: 15px; line-height: 1.15; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;font-weight: bold; vertical-align: baseline;&quot;&gt;Sharding&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Automatic partitioning and management &lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Range based&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Convert to sharded system with no downtime&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;font-size: 15px; line-height: 17.25px; white-space: pre-wrap;&quot;&gt;Fully consistent&lt;/span&gt;&lt;/li&gt;
&lt;/span&gt;&lt;/ul&gt;
&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;ul style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;&lt;/ul&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt;e.g of adding shard based on age&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt; db.runCommand({ addshard:”shard1”});&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;/span&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;&lt;span style=&quot;vertical-align: baseline;&quot;&gt; db.runCommand({ ShardCollection:”mydb.blogs”, key:{age:1}})&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: Arial, Helvetica, sans-serif; vertical-align: baseline;&quot;&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt; &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;ranges are stored as chunks&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;chunks are created automatically &lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;shard’s can be added as many as required using &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt; db.runCommand({ addshard:”shard2”});&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;shard can also be removed&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;Shard has no downtime and automatic balancing as data is written&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;Insert must have shard key&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;Update must have shard key&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;Query with Shard key routed to the right node&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt; &amp;nbsp;- no Shard key scattered and gathered&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;Indexed query &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;- with shard key rated in order&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;- without shard key is distributed sort and merge&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;font-style: italic; font-weight: bold; vertical-align: baseline;&quot;&gt;Replication&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-style: italic; font-weight: bold; vertical-align: baseline;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;line-height: 1.15;&quot;&gt;Replica set is not Master/Slave as in master/slave a new master has to be switched &amp;nbsp;if the master is down&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;Replica Set works as&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&lt;span style=&quot;line-height: 1.15;&quot;&gt;cluster of N Servers&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;line-height: 1.15;&quot;&gt;Any(one) can be primary&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;line-height: 1.15;&quot;&gt;Automatic failover, recovery&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;line-height: 1.15;&quot;&gt;All writes to Primary&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;line-height: 1.15;&quot;&gt;Read can be to Primary(default) or Secondary&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;line-height: 1.15;&quot;&gt;There has to be at least 2 or More replica set so that Primary can be elected&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style=&quot;line-height: 1.15;&quot;&gt;if Primary fails then negotiation happens for the new Primary &lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;Node can be &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt; &amp;nbsp;Normal ( priority:1} &amp;nbsp;or Passive { priority:0 } &amp;nbsp;- cannot become primary &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt; &amp;nbsp;Can also be Arbiter - can vote but cannot hold any data &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt; &amp;nbsp;Can be hidden { hidden:true }&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt; &amp;nbsp;Can allow tags ( after 2.0 version ) e.g tags { “dc”:”ny”, “rack” :”123”}&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;slaveOk()&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;-driver sends read request to the secondary &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;-write always happens to primary &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;Java - &lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;DB.slaveOk() or Collection.slaveOk()&lt;/span&gt;&lt;/div&gt;
&lt;br /&gt;&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;Read are consistent in Primary&lt;/span&gt;&lt;/div&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;font-size: 15px; line-height: 1.15; margin-bottom: 0pt; margin-top: 0pt; white-space: pre-wrap;&quot;&gt;
&lt;span style=&quot;vertical-align: baseline;&quot;&gt;Read for secondary are eventually consistent&lt;/span&gt;&lt;/div&gt;
&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: Arial; font-size: 15px; vertical-align: baseline; white-space: pre-wrap;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/7223600831835448842/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/7223600831835448842' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/7223600831835448842'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/7223600831835448842'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2015/01/mongodb.html' title='MongoDB'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-4576833900643937469</id><published>2014-12-16T15:02:00.002-08:00</published><updated>2014-12-16T15:18:19.371-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java functional programming"/><category scheme="http://www.blogger.com/atom/ns#" term="java8"/><category scheme="http://www.blogger.com/atom/ns#" term="lambdas"/><title type='text'>Java8</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Lambda&#39;s and Functional Interfaces&lt;/h2&gt;
&lt;div&gt;
Java 8 is a major improvement and has rich set of features since Java5 . Main draw back with java language was it lacked functional style of programming . Java8 Fixed &amp;nbsp;this , following set of examples to lambda&#39;s and other features &amp;nbsp;introduced in java8 .&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Lambda expressions are basically anonymous methods , Java can now do functional composition in addition to object composition .&amp;nbsp;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Example of Imperative style&amp;nbsp;&lt;/h4&gt;
&lt;div&gt;
public static void printArray(List&lt;string&gt; arrtoprint)&lt;/string&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for( int i =0; i&amp;lt; arrtoprint.size(); i++)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(arrtoprint.get(i));&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; public static void printArrayJava5(List&lt;string&gt; arrtoprint)&lt;/string&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; for( String s:arrtoprint)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; System.out.println(s);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
both use external iterators , and boundary conditions , algorithm of looping are all controlled by the code.&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Example of Declarative ( functional) Style&amp;nbsp;&lt;/h4&gt;
&lt;div&gt;
Implementation uses internal iterators&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;public static void printArrayJava8(List&lt;string&gt; arrtoprint)&lt;/string&gt;&lt;br /&gt;
&amp;nbsp; &amp;nbsp; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;arrtoprint.forEach(System.out::println);&lt;br /&gt;
&amp;nbsp; &amp;nbsp; }&lt;br /&gt;
lot of things inferred in the above implementation&lt;br /&gt;
&lt;br /&gt;
Descriptive syntax to show print element for each string element in arraylist&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; arrtoprint.forEach((String e)-&amp;gt;System.out.println(e));&lt;br /&gt;
&lt;br /&gt;
Can be shortened to this format , print the element in the arraylist&lt;br /&gt;
&amp;nbsp;arrtoprint.forEach(System.out.println(e));&lt;br /&gt;
&lt;br /&gt;
Can be further shortened to this .There is only one element to print , so not even have to mention that&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
arrtoprint.forEach(System.out::println);&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Why this is better&amp;nbsp;&lt;/h4&gt;
&lt;div&gt;
Declarative style , values go through &amp;nbsp;mutation - constantly changed&lt;/div&gt;
&lt;div&gt;
Imperative Style , No mutation - can be parallelized easily&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Remove the mechanics - e.g looping can be sequential , or be concurrent or lazy&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Implementation done through java interface Consumer&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
values.forEach( new Consumer&lt;integer&gt;() {&lt;/integer&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
public accept(Interger value)&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp;System.out.println(value);&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
});&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Example with return&amp;nbsp;&lt;/h4&gt;
&lt;div&gt;
Functional style can also be used with methods that have a return , example for sorting the implementation would be&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&amp;nbsp; arrtosort.sort((e1,e2)-&amp;gt; e1.compareTo(e2));&lt;br /&gt;
&lt;br /&gt;
return &amp;nbsp;is not required when there is only one variable to be returned . Descriptive syntax for this would be&lt;br /&gt;
&lt;br /&gt;
arrtosort..sort( ( e1, e2 ) -&amp;gt; {&lt;br /&gt;
&amp;nbsp; &amp;nbsp; int result = e1.compareTo( e2 );&lt;br /&gt;
&amp;nbsp; &amp;nbsp; return result;&lt;br /&gt;
} );&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Example using stream&lt;/h4&gt;
&lt;div&gt;
Java 8 provides a new API (called Streams) that supports many parallel operations to process data and resembles the way you might think in database query languages—you express what you want in a higher-level manner, and the implementation (here the Streams library) chooses the best low-level execution mechanism. As a result, it avoids the need for you to write code that uses synchronized, which is not only highly error prone but is also more expensive than you may realize on multicore CPUs.Here is an example to filter out only even numbers from a arraylist of integers and print them&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;nbsp;public static void printEvenFunctional(List&lt;integer&gt; intArr)&lt;/integer&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;intArr.stream().filter(e-&amp;gt;e%2!=0).forEach(System.out::println);&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This makes use of the Predicate interface&amp;nbsp;java.util.function.Predicate .&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Descriptive syntax would be&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp;public static void printEvenFunctionalDescriptive(List&lt;integer&gt; intArr)&lt;/integer&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; intArr.stream().filter(&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; new CheckInt()&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ).forEach(System.out::println); ;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
CheckInt class would be&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
class CheckInt implements Predicate&lt;integer&gt;&lt;/integer&gt;&lt;/div&gt;
&lt;div&gt;
{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; public boolean test(Integer i)&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; {&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return i%2==0 ;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; }&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
Stream api allows code to be written &amp;nbsp;that is&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Declarative— More concise and readable&lt;/li&gt;
&lt;li&gt;Composable— Greater flexibility&lt;/li&gt;
&lt;li&gt;Parallelizable— Better performance&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
parallelStream&lt;/h4&gt;
above example uses sequential stream , it can be changed to parallelStream by just changing&lt;br /&gt;
&lt;br /&gt;
intArr.stream()&lt;br /&gt;
to&lt;br /&gt;
intArr.parallelStream()&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Optional&amp;nbsp;&lt;/h3&gt;
&lt;/div&gt;
&lt;div&gt;
Java8 introduces new class java.util.Optional&lt;t&gt; . Its the idea inspired from Scala and Haskell and it attempts to solve the problem&amp;nbsp;&lt;/t&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
public class Person{&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Optional&lt;cellphone&gt; phone ;&lt;/cellphone&gt;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;public Optional getCellphone()&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;{&lt;/div&gt;
&lt;div&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;return phone;&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
}&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
ifPresent / orElse&amp;nbsp;&lt;/h4&gt;
&lt;/div&gt;
&lt;div&gt;
price = phone.orElse( defaultPhone ).getPrice();&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
phone.ifPresent( p -&amp;gt; System.out.println(&quot;Phone is present for person&quot;) );&lt;br /&gt;
&lt;br /&gt;
can also be applied on streams as shown below&lt;br /&gt;
&lt;br /&gt;
employee.stream()&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .filter(Employee::isRelocated)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .findAny()&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .ifPresent( e -&amp;gt; System.out.println(e.getName() );&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/4576833900643937469/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/4576833900643937469' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/4576833900643937469'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/4576833900643937469'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2014/12/java8.html' title='Java8'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-1405158001214606141</id><published>2013-11-15T23:55:00.002-08:00</published><updated>2013-11-15T23:58:58.971-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="gae maven"/><category scheme="http://www.blogger.com/atom/ns#" term="google app engine maven setup"/><title type='text'>Google App Engine Maven setup</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;

&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;

&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Maven Setup for Google App Engine&lt;/h2&gt;
&lt;div&gt;
Playing with Google App Engine to setup simple Spring application .It&#39;s &amp;nbsp;simple to setup simple Servlet application through Eclipse plugin but I don&#39;t want to maintain dependency in eclipse , got to have Maven . It&#39;s little tricky to setup , so here is the info .&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Download AppEngine ( Not just the Eclipse plugin for gae ) &amp;nbsp;&lt;/li&gt;
&lt;li&gt;Setup Maven master password and google password as encrypted value&amp;nbsp;&lt;/li&gt;
&lt;li&gt;pom.xml&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Password Setup&lt;/h3&gt;
&lt;/div&gt;
&lt;div&gt;
Setup the master password and the google password .Details for setting up password explained here&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;http://maven.apache.org/guides/mini/guide-encryption.html#How_to_create_a_master_password&quot;&gt;http://maven.apache.org/guides/mini/guide-encryption.html#How_to_create_a_master_password&lt;/a&gt;.&lt;/div&gt;
&lt;div&gt;
Your settings-security.xml and settings.xml has to be updated . Provided mine below for reference&lt;/div&gt;
&lt;div&gt;
settings-security.xml&lt;/div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;settingsSecurity&amp;gt;
 &amp;lt;master&amp;gt;encryptedvaluehere&amp;lt;/master&amp;gt;
&amp;lt;/settingsSecurity&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;div&gt;
Settings.xml
&lt;/div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;settings xmlns=&quot;http://maven.apache.org/SETTINGS/1.0.0&quot;
  xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
  xsi:schemaLocation=&quot;http://maven.apache.org/SETTINGS/1.0.0
                      http://maven.apache.org/xsd/settings-1.0.0.xsd&quot;&amp;gt;
  &amp;lt;localRepository/&amp;gt;
  &amp;lt;interactiveMode/&amp;gt;
  &amp;lt;usePluginRegistry/&amp;gt;
  &amp;lt;offline/&amp;gt;
  &amp;lt;pluginGroups/&amp;gt;
  &amp;lt;servers&amp;gt;
      &amp;lt;server&amp;gt;
            &amp;lt;id&amp;gt;appengine.google.com&amp;lt;/id&amp;gt;
            &amp;lt;username&amp;gt;emailhere&amp;lt;/username&amp;gt;
            &amp;lt;password&amp;gt;encryptedvaluehere&amp;lt;/password&amp;gt;
        &amp;lt;/server&amp;gt;
  &amp;lt;/servers&amp;gt;
  &amp;lt;mirrors/&amp;gt;
  &amp;lt;proxies/&amp;gt;
  &amp;lt;profiles/&amp;gt;
  &amp;lt;activeProfiles/&amp;gt;
&amp;lt;/settings&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Directory&lt;/h3&gt;
&lt;div&gt;
My case the source directory is src , not src/main and all the other required files are in src main as shown below&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrh4aBf8WftuB-FQvI32ERLLv7qaafPPWOWRwD-Fw-TYP8A7eZct7OG0v1mNKusQVbZQb3pP8Kj5iOQ479WpunF7Ee9B1IrqCTAeyvBsL6lwncoa9VCENeY6kan5GvVeGJGMidg_K2gbCX/s1600/Screen+Shot+2013-11-15+at+11.39.38+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em; text-align: center;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrh4aBf8WftuB-FQvI32ERLLv7qaafPPWOWRwD-Fw-TYP8A7eZct7OG0v1mNKusQVbZQb3pP8Kj5iOQ479WpunF7Ee9B1IrqCTAeyvBsL6lwncoa9VCENeY6kan5GvVeGJGMidg_K2gbCX/s320/Screen+Shot+2013-11-15+at+11.39.38+PM.png&quot; width=&quot;274&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
pom.xml&lt;/h3&gt;
Specify the Google App Engine home in gae.home tag.
&lt;br/&gt; Enter the group and artifact id &lt;br/&gt;
mvn gae:deploy will deploy the application to the app engine 

&lt;br/&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br/&gt;&amp;lt;project xmlns=&amp;quot;http://maven.apache.org/POM/4.0.0&amp;quot;&lt;br/&gt;         xmlns:xsi=&amp;quot;http://www.w3.org/2001/XMLSchema-instance&amp;quot;&lt;br/&gt;         xsi:schemaLocation=&amp;quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&amp;quot;&amp;gt;&lt;br/&gt;&lt;br/&gt;    &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;&lt;br/&gt;    &amp;lt;packaging&amp;gt;war&amp;lt;/packaging&amp;gt;&lt;br/&gt;    &amp;lt;version&amp;gt;1.0&amp;lt;/version&amp;gt;&lt;br/&gt;  &lt;br/&gt;    &lt;br/&gt;    &amp;lt;groupId&amp;gt;entergroupid&amp;lt;/groupId&amp;gt;&lt;br/&gt;    &amp;lt;artifactId&amp;gt;enterartifactid&amp;lt;/artifactId&amp;gt;&lt;br/&gt;&lt;br/&gt;   &amp;lt;pluginRepositories&amp;gt;&lt;br/&gt;        &amp;lt;pluginRepository&amp;gt;&lt;br/&gt;            &amp;lt;id&amp;gt;maven-gae-plugin-repo&amp;lt;/id&amp;gt;&lt;br/&gt;            &amp;lt;name&amp;gt;Maven Google App Engine Repository&amp;lt;/name&amp;gt;&lt;br/&gt;            &amp;lt;url&amp;gt;http://maven-gae-plugin.googlecode.com/svn/repository/&amp;lt;/url&amp;gt;&lt;br/&gt;        &amp;lt;/pluginRepository&amp;gt;&lt;br/&gt;        &amp;lt;pluginRepository&amp;gt;&lt;br/&gt;            &amp;lt;id&amp;gt;google-staging&amp;lt;/id&amp;gt;&lt;br/&gt;            &amp;lt;name&amp;gt;Google Staging&amp;lt;/name&amp;gt;&lt;br/&gt;            &amp;lt;url&amp;gt;https://oss.sonatype.org/content/repositories/comgoogleappengine-1004/&amp;lt;/url&amp;gt;&lt;br/&gt;        &amp;lt;/pluginRepository&amp;gt;&lt;br/&gt;    &amp;lt;/pluginRepositories&amp;gt;&lt;br/&gt;&lt;br/&gt; &amp;lt;repositories&amp;gt;&lt;br/&gt;        &amp;lt;repository&amp;gt;&lt;br/&gt;            &amp;lt;id&amp;gt;google-maven-repo&amp;lt;/id&amp;gt;&lt;br/&gt;            &amp;lt;name&amp;gt;Maven Google App Engine Repository&amp;lt;/name&amp;gt;&lt;br/&gt;            &amp;lt;url&amp;gt;http://maven-gae-plugin.googlecode.com/svn/repository/&amp;lt;/url&amp;gt;&lt;br/&gt;        &amp;lt;/repository&amp;gt;&lt;br/&gt;        &amp;lt;repository&amp;gt;&lt;br/&gt;            &amp;lt;id&amp;gt;codehaus&amp;lt;/id&amp;gt;&lt;br/&gt;            &amp;lt;name&amp;gt;codehaus&amp;lt;/name&amp;gt;&lt;br/&gt;            &amp;lt;url&amp;gt;http://repository.codehaus.org/org/codehaus/groovy/&amp;lt;/url&amp;gt;&lt;br/&gt;        &amp;lt;/repository&amp;gt;&lt;br/&gt;  &amp;lt;repository&amp;gt;&lt;br/&gt;   &amp;lt;id&amp;gt;repository.springsource.release&amp;lt;/id&amp;gt;&lt;br/&gt;   &amp;lt;name&amp;gt;SpringSource GA Repository&amp;lt;/name&amp;gt;&lt;br/&gt;   &amp;lt;url&amp;gt;http://repo.springsource.org/release&amp;lt;/url&amp;gt;&lt;br/&gt;  &amp;lt;/repository&amp;gt;&lt;br/&gt; &amp;lt;/repositories&amp;gt;&lt;br/&gt;    &lt;br/&gt;&lt;br/&gt;    &amp;lt;properties&amp;gt;&lt;br/&gt;        &amp;lt;appengine.app.version&amp;gt;1&amp;lt;/appengine.app.version&amp;gt;&lt;br/&gt;        &amp;lt;appengine.target.version&amp;gt;1.8.6&amp;lt;/appengine.target.version&amp;gt;&lt;br/&gt;        &amp;lt;project.build.sourceEncoding&amp;gt;UTF-8&amp;lt;/project.build.sourceEncoding&amp;gt;&lt;br/&gt;        &amp;lt;spring-framework.version&amp;gt;3.1.2.RELEASE&amp;lt;/spring-framework.version&amp;gt;&lt;br/&gt;     &amp;lt;spring-integration.version&amp;gt;2.1.3.RELEASE&amp;lt;/spring-integration.version&amp;gt;&lt;br/&gt;     &amp;lt;spring-ws.version&amp;gt;2.1.0.RELEASE&amp;lt;/spring-ws.version&amp;gt;&amp;lt;!--2.1.0.RELEASE--&amp;gt;&lt;br/&gt;     &amp;lt;spring-security-version&amp;gt;3.1.2.RELEASE&amp;lt;/spring-security-version&amp;gt;&lt;br/&gt;     &amp;lt;enunciate.version&amp;gt;1.27&amp;lt;/enunciate.version&amp;gt;&lt;br/&gt;     &amp;lt;gae.version&amp;gt;1.8.6&amp;lt;/gae.version&amp;gt;&lt;br/&gt;    &amp;lt;gae.port&amp;gt;9090&amp;lt;/gae.port&amp;gt;&lt;br/&gt;    &amp;lt;net.kindleit.version&amp;gt;0.9.6-SNAPSHOT&amp;lt;/net.kindleit.version&amp;gt;&lt;br/&gt;       &amp;lt;gae.home&amp;gt;/Library/appengine/appengine-java-sdk-${gae.version}&amp;lt;/gae.home&amp;gt;&lt;br/&gt;     &amp;lt;webappDirectory&amp;gt;${project.build.directory}/${project.build.finalName}&amp;lt;/webappDirectory&amp;gt;&lt;br/&gt;    &lt;br/&gt;    &amp;lt;/properties&amp;gt;&lt;br/&gt;&lt;br/&gt;    &amp;lt;dependencies&amp;gt;&lt;br/&gt;        &amp;lt;!-- Compile/runtime dependencies --&amp;gt;&lt;br/&gt;        &amp;lt;dependency&amp;gt;&lt;br/&gt;            &amp;lt;groupId&amp;gt;com.google.appengine&amp;lt;/groupId&amp;gt;&lt;br/&gt;            &amp;lt;artifactId&amp;gt;appengine-api-1.0-sdk&amp;lt;/artifactId&amp;gt;&lt;br/&gt;            &amp;lt;version&amp;gt;${appengine.target.version}&amp;lt;/version&amp;gt;&lt;br/&gt;        &amp;lt;/dependency&amp;gt;&lt;br/&gt;        &amp;lt;dependency&amp;gt;&lt;br/&gt;            &amp;lt;groupId&amp;gt;javax.servlet&amp;lt;/groupId&amp;gt;&lt;br/&gt;            &amp;lt;artifactId&amp;gt;servlet-api&amp;lt;/artifactId&amp;gt;&lt;br/&gt;            &amp;lt;version&amp;gt;2.5&amp;lt;/version&amp;gt;&lt;br/&gt;            &amp;lt;scope&amp;gt;provided&amp;lt;/scope&amp;gt;&lt;br/&gt;        &amp;lt;/dependency&amp;gt;&lt;br/&gt;        &amp;lt;dependency&amp;gt;&lt;br/&gt;            &amp;lt;groupId&amp;gt;jstl&amp;lt;/groupId&amp;gt;&lt;br/&gt;            &amp;lt;artifactId&amp;gt;jstl&amp;lt;/artifactId&amp;gt;&lt;br/&gt;            &amp;lt;version&amp;gt;1.2&amp;lt;/version&amp;gt;&lt;br/&gt;        &amp;lt;/dependency&amp;gt;&lt;br/&gt;        &lt;br/&gt;             &amp;lt;dependency&amp;gt;&lt;br/&gt;      &amp;lt;groupId&amp;gt;org.springframework&amp;lt;/groupId&amp;gt;&lt;br/&gt;      &amp;lt;artifactId&amp;gt;spring-context&amp;lt;/artifactId&amp;gt;&lt;br/&gt;      &amp;lt;version&amp;gt;${spring-framework.version}&amp;lt;/version&amp;gt;&lt;br/&gt;    &amp;lt;/dependency&amp;gt;&lt;br/&gt;  &amp;lt;dependency&amp;gt;&lt;br/&gt;      &amp;lt;groupId&amp;gt;org.springframework&amp;lt;/groupId&amp;gt;&lt;br/&gt;      &amp;lt;artifactId&amp;gt;spring-web&amp;lt;/artifactId&amp;gt;&lt;br/&gt;      &amp;lt;version&amp;gt;${spring-framework.version}&amp;lt;/version&amp;gt;&lt;br/&gt;    &amp;lt;/dependency&amp;gt;&lt;br/&gt;    &amp;lt;dependency&amp;gt;&lt;br/&gt;      &amp;lt;groupId&amp;gt;org.springframework&amp;lt;/groupId&amp;gt;&lt;br/&gt;      &amp;lt;artifactId&amp;gt;spring-webmvc&amp;lt;/artifactId&amp;gt;&lt;br/&gt;      &amp;lt;version&amp;gt;${spring-framework.version}&amp;lt;/version&amp;gt;&lt;br/&gt;    &amp;lt;/dependency&amp;gt;&lt;br/&gt;        &lt;br/&gt;     &amp;lt;dependency&amp;gt;&lt;br/&gt;         &amp;lt;groupId&amp;gt;org.codehaus.enunciate&amp;lt;/groupId&amp;gt;&lt;br/&gt;         &amp;lt;artifactId&amp;gt;enunciate-rt&amp;lt;/artifactId&amp;gt;&lt;br/&gt;         &amp;lt;version&amp;gt;${enunciate.version}&amp;lt;/version&amp;gt;&lt;br/&gt;      &amp;lt;/dependency&amp;gt;&lt;br/&gt;&lt;br/&gt;        &amp;lt;!-- Test Dependencies --&amp;gt;&lt;br/&gt;        &amp;lt;dependency&amp;gt;&lt;br/&gt;            &amp;lt;groupId&amp;gt;junit&amp;lt;/groupId&amp;gt;&lt;br/&gt;            &amp;lt;artifactId&amp;gt;junit&amp;lt;/artifactId&amp;gt;&lt;br/&gt;            &amp;lt;version&amp;gt;4.10&amp;lt;/version&amp;gt;&lt;br/&gt;            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;&lt;br/&gt;        &amp;lt;/dependency&amp;gt;&lt;br/&gt;        &amp;lt;dependency&amp;gt;&lt;br/&gt;            &amp;lt;groupId&amp;gt;org.mockito&amp;lt;/groupId&amp;gt;&lt;br/&gt;            &amp;lt;artifactId&amp;gt;mockito-all&amp;lt;/artifactId&amp;gt;&lt;br/&gt;            &amp;lt;version&amp;gt;1.9.0&amp;lt;/version&amp;gt;&lt;br/&gt;            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;&lt;br/&gt;        &amp;lt;/dependency&amp;gt;&lt;br/&gt;        &amp;lt;dependency&amp;gt;&lt;br/&gt;            &amp;lt;groupId&amp;gt;com.google.appengine&amp;lt;/groupId&amp;gt;&lt;br/&gt;            &amp;lt;artifactId&amp;gt;appengine-testing&amp;lt;/artifactId&amp;gt;&lt;br/&gt;            &amp;lt;version&amp;gt;${appengine.target.version}&amp;lt;/version&amp;gt;&lt;br/&gt;            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;&lt;br/&gt;        &amp;lt;/dependency&amp;gt;&lt;br/&gt;        &amp;lt;dependency&amp;gt;&lt;br/&gt;            &amp;lt;groupId&amp;gt;com.google.appengine&amp;lt;/groupId&amp;gt;&lt;br/&gt;            &amp;lt;artifactId&amp;gt;appengine-api-stubs&amp;lt;/artifactId&amp;gt;&lt;br/&gt;            &amp;lt;version&amp;gt;${appengine.target.version}&amp;lt;/version&amp;gt;&lt;br/&gt;            &amp;lt;scope&amp;gt;test&amp;lt;/scope&amp;gt;&lt;br/&gt;        &amp;lt;/dependency&amp;gt;&lt;br/&gt;    &amp;lt;/dependencies&amp;gt;&lt;br/&gt;      &lt;br/&gt;    &amp;lt;build&amp;gt;&lt;br/&gt;         &amp;lt;sourceDirectory&amp;gt;src&amp;lt;/sourceDirectory&amp;gt;&lt;br/&gt;          &amp;lt;resources&amp;gt;&lt;br/&gt;        &amp;lt;resource&amp;gt;&lt;br/&gt;          &amp;lt;directory&amp;gt;src/resources&amp;lt;/directory&amp;gt;&lt;br/&gt;        &amp;lt;/resource&amp;gt;&lt;br/&gt;      &amp;lt;/resources&amp;gt;   &lt;br/&gt;         &amp;lt;outputDirectory&amp;gt;target/${project.artifactId}-${project.version}/WEB-INF/classes&amp;lt;/outputDirectory&amp;gt; &lt;br/&gt;                          &lt;br/&gt;        &amp;lt;plugins&amp;gt;&lt;br/&gt;           &amp;lt;plugin&amp;gt;&lt;br/&gt;          &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;&lt;br/&gt;          &amp;lt;artifactId&amp;gt;maven-compiler-plugin&amp;lt;/artifactId&amp;gt;&lt;br/&gt;          &amp;lt;version&amp;gt;3.1&amp;lt;/version&amp;gt;&lt;br/&gt;         &amp;lt;configuration&amp;gt;&lt;br/&gt;            &amp;lt;source&amp;gt;1.6&amp;lt;/source&amp;gt;&lt;br/&gt;            &amp;lt;target&amp;gt;1.6&amp;lt;/target&amp;gt;&lt;br/&gt;          &amp;lt;/configuration&amp;gt; &lt;br/&gt;        &amp;lt;/plugin&amp;gt; &lt;br/&gt;        &lt;br/&gt;             &amp;lt;plugin&amp;gt;&lt;br/&gt;                &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;&lt;br/&gt;                &amp;lt;artifactId&amp;gt;maven-war-plugin&amp;lt;/artifactId&amp;gt;&lt;br/&gt;                &amp;lt;version&amp;gt;2.4&amp;lt;/version&amp;gt;&lt;br/&gt;                &amp;lt;configuration&amp;gt;&lt;br/&gt;                    &amp;lt;webResources&amp;gt;&lt;br/&gt;              &amp;lt;resource&amp;gt;&lt;br/&gt;                &amp;lt;directory&amp;gt;src/resources&amp;lt;/directory&amp;gt;&lt;br/&gt;              &amp;lt;/resource&amp;gt;&lt;br/&gt;            &amp;lt;/webResources&amp;gt;&lt;br/&gt;                &amp;lt;/configuration&amp;gt;&lt;br/&gt;            &amp;lt;/plugin&amp;gt; &lt;br/&gt; &lt;br/&gt;             &amp;lt;plugin&amp;gt;&lt;br/&gt;                &amp;lt;groupId&amp;gt;com.google.appengine&amp;lt;/groupId&amp;gt;&lt;br/&gt;                &amp;lt;artifactId&amp;gt;appengine-maven-plugin&amp;lt;/artifactId&amp;gt;&lt;br/&gt;                &amp;lt;version&amp;gt;${gae.version}&amp;lt;/version&amp;gt;&lt;br/&gt;                &amp;lt;configuration&amp;gt;&lt;br/&gt;                   &amp;lt;fullScanSeconds&amp;gt;1&amp;lt;/fullScanSeconds&amp;gt;&lt;br/&gt;                   &amp;lt;server&amp;gt;preview.appengine.google.com&amp;lt;/server&amp;gt;&lt;br/&gt;                &amp;lt;/configuration&amp;gt;&lt;br/&gt;            &amp;lt;/plugin&amp;gt; &lt;br/&gt;            &lt;br/&gt;         &lt;br/&gt;         &lt;br/&gt;             &amp;lt;plugin&amp;gt;&lt;br/&gt;                &amp;lt;groupId&amp;gt;net.kindleit&amp;lt;/groupId&amp;gt;&lt;br/&gt;                &amp;lt;artifactId&amp;gt;maven-gae-plugin&amp;lt;/artifactId&amp;gt;&lt;br/&gt;                &amp;lt;version&amp;gt;0.9.2&amp;lt;/version&amp;gt;&lt;br/&gt;                &amp;lt;configuration&amp;gt;&lt;br/&gt;                    &amp;lt;unpackVersion&amp;gt;${gae.version}&amp;lt;/unpackVersion&amp;gt;&lt;br/&gt;                    &amp;lt;serverId&amp;gt;appengine.google.com&amp;lt;/serverId&amp;gt;&lt;br/&gt;                &amp;lt;/configuration&amp;gt;&lt;br/&gt;                &amp;lt;dependencies&amp;gt;&lt;br/&gt;                    &amp;lt;dependency&amp;gt;&lt;br/&gt;                        &amp;lt;groupId&amp;gt;net.kindleit&amp;lt;/groupId&amp;gt;&lt;br/&gt;                        &amp;lt;artifactId&amp;gt;gae-runtime&amp;lt;/artifactId&amp;gt;&lt;br/&gt;                        &amp;lt;version&amp;gt;${gae.version}&amp;lt;/version&amp;gt;&lt;br/&gt;                        &amp;lt;type&amp;gt;pom&amp;lt;/type&amp;gt;&lt;br/&gt;                    &amp;lt;/dependency&amp;gt;&lt;br/&gt;                &amp;lt;/dependencies&amp;gt;&lt;br/&gt;            &amp;lt;/plugin&amp;gt;&lt;br/&gt;            &lt;br/&gt;               &amp;lt;plugin&amp;gt;&lt;br/&gt;                &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;&lt;br/&gt;                &amp;lt;artifactId&amp;gt;maven-release-plugin&amp;lt;/artifactId&amp;gt;&lt;br/&gt;                &amp;lt;version&amp;gt;2.2.2&amp;lt;/version&amp;gt;&lt;br/&gt;                &amp;lt;configuration&amp;gt;&lt;br/&gt;                    &amp;lt;goals&amp;gt;gae:deploy&amp;lt;/goals&amp;gt;&lt;br/&gt;                &amp;lt;/configuration&amp;gt;&lt;br/&gt;            &amp;lt;/plugin&amp;gt;&lt;br/&gt;         &lt;br/&gt;            &lt;br/&gt;        &amp;lt;/plugins&amp;gt;&lt;br/&gt;    &amp;lt;/build&amp;gt;&lt;br/&gt;&lt;br/&gt;    &lt;br/&gt;  &lt;br/&gt;&amp;lt;/project&amp;gt;


&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/1405158001214606141/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/1405158001214606141' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/1405158001214606141'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/1405158001214606141'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/11/google-app-engine-maven-setup.html' title='Google App Engine Maven setup'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhrh4aBf8WftuB-FQvI32ERLLv7qaafPPWOWRwD-Fw-TYP8A7eZct7OG0v1mNKusQVbZQb3pP8Kj5iOQ479WpunF7Ee9B1IrqCTAeyvBsL6lwncoa9VCENeY6kan5GvVeGJGMidg_K2gbCX/s72-c/Screen+Shot+2013-11-15+at+11.39.38+PM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-6769682612059975412</id><published>2013-11-12T14:33:00.000-08:00</published><updated>2016-09-29T16:30:40.723-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="spring integration soap webservice"/><category scheme="http://www.blogger.com/atom/ns#" term="spring soap webservice"/><title type='text'>Spring Integration - Calling SOAP Service using Gateway , Channel and Chain</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;

&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
WebService using Spring Integration&lt;/h2&gt;
&lt;div&gt;
Article to show WebService call  ( SOAP ) using &amp;nbsp;Spring Integration . It uses &amp;nbsp;Gateway , &amp;nbsp;Channel and Router&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
What you will need&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
1. Schema or WSDL to generate the Marshaller and UnMarshaller Objects .&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
2. Java Interface to Call WebService&lt;/div&gt;
&lt;div&gt;
3. Bean configuration defining &amp;nbsp;gateway , channel , router etc&lt;/div&gt;
&lt;div&gt;
4. Java Transformer&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
Refer to the example in github&lt;br /&gt;
&lt;a href=&quot;https://github.com/arun2dot0/spring-integration-consumer&quot;&gt;https://github.com/arun2dot0/spring-integration-consumer&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Generation of Marshaller and UnMarshaller&lt;/h3&gt;
&lt;div&gt;
&lt;div&gt;
Marshaller and a UnMarshaller are basically Java representation of the Request and Response &amp;nbsp;, these can be generated by&amp;nbsp;&lt;b&gt;xjc&lt;/b&gt;&amp;nbsp;utility on schema (or)&amp;nbsp;&lt;b&gt;wsimport&lt;/b&gt;&amp;nbsp;on WSDL. If you don&#39;t have the schema , it can be generated by the xml using many tools like&amp;nbsp;&lt;a href=&quot;http://www.freeformatter.com/&quot;&gt;http://www.freeformatter.com/&lt;/a&gt;&amp;nbsp; Here is example of generating them from schema &amp;nbsp;using ant ( uses xjc )&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:xml&quot;&gt; 
  &amp;lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&amp;gt;

&amp;lt;project name = &quot;mywsproject&quot; 
        default = &quot;generate&quot;&amp;gt;
 &amp;lt;property file = &quot;build.properties&quot;/&amp;gt;
 
  &amp;lt;fileset id = &quot;tools&quot; 
           dir = &quot;tools&quot;&amp;gt;
    &amp;lt;include name = &quot;**/*.jar&quot;/&amp;gt;
  &amp;lt;/fileset&amp;gt; 
 
 &amp;lt;taskdef name = &quot;xjc&quot; classname = &quot;com.sun.tools.xjc.XJCTask&quot;&amp;gt;
   &amp;lt;classpath&amp;gt;
     &amp;lt;fileset refid = &quot;tools&quot;/&amp;gt;
   &amp;lt;/classpath&amp;gt;
 &amp;lt;/taskdef&amp;gt;
 
 &amp;lt;target name = &quot;generate&quot;&amp;gt;
  &amp;lt;xjc schema = &quot;src/main/xml/country.xsd&quot; 
      destdir = &quot;src/main/java&quot; 
      package = &quot;com.my.services.model&quot;/&amp;gt;
 &amp;lt;/target&amp;gt; 
&amp;lt;/project&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div style=&quot;margin: 0px;&quot;&gt;
&amp;nbsp;WSDL will have the schema and &quot;wsimport&quot; utility will generate the Classes for Marshaling and Un-Marshaling ( details of the wsimport utility can be found here&amp;nbsp;&lt;a href=&quot;http://ajaxrocks.blogspot.com/2013/08/jax-ws-call-ws-using-maven.html&quot; style=&quot;background-color: white; color: dimgrey; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;http://ajaxrocks.blogspot.com/2013/08/jax-ws-call-ws-using-maven.html&lt;/a&gt;) . If you are generating using the WSDL there will be the WebService and PortType classes , delete them after generation .&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Java Interface to Call WebService&lt;/h3&gt;
&lt;div&gt;
Interface to call the webservice , it uses the generated classes . My case the class is GetCountryRequest and GetCountryResponse&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;package com.my.services.api;
import javax.xml.bind.annotation.XmlElement;
import io.spring.guides.gs_producing_web_service.GetCountryRequest;
import io.spring.guides.gs_producing_web_service.GetCountryResponse;
public interface MyService {
GetCountryResponse  countryRequest(GetCountryRequest request);
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Stuff to Configure ( full xml shown below )&lt;/h3&gt;
&lt;div&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Gateway&lt;/h4&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Specify&#39;s the interface and map the method to the header&amp;nbsp;&lt;/div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;int:gateway id=&quot;myService&quot; service-interface=&quot;com.my.services.api.MyService&quot;
  default-request-channel=&quot;myService_routingChannel&quot;&amp;gt;
  &amp;lt;int:method name=&quot;countryRequest&quot;&amp;gt;
   &amp;lt;int:header name=&quot;REQUEST_TYPE&quot; value=&quot;countryRequest&quot; /&amp;gt;
  &amp;lt;/int:method&amp;gt;
 &amp;lt;/int:gateway&amp;gt;

&lt;/pre&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Publish-Subscribe Channel&lt;/h4&gt;
Specify the Channel to map this way we can map the header value to the channel&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;int:publish-subscribe-channel id=&quot;myService_routingChannel&quot; /&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Header-Value Router&lt;/h4&gt;
Route the call based on the header value to the chain&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt; &amp;lt;int:header-value-router input-channel=&quot;myService_routingChannel&quot; header-name=&quot;REQUEST_TYPE&quot;&amp;gt;
  &amp;lt;int:mapping value=&quot;countryRequest&quot; channel=&quot;myService_countryRequestChannel&quot; /&amp;gt;
 &amp;lt;/int:header-value-router&amp;gt;
 
 &amp;lt;int:channel id=&quot;myService_countryRequestChannel&quot; /&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Chain&lt;/h4&gt;
&lt;br /&gt;
&lt;b&gt;Service-Activation&lt;/b&gt; - &amp;nbsp;transformer and the method to be called in the java class&lt;br /&gt;
&lt;b&gt;Soap-Action&lt;/b&gt; (&amp;nbsp;&lt;b&gt;ws:header-enricher&lt;/b&gt;&amp;nbsp;) - soap-action to be called ( you will find this in the wsdl ). Example this one is commented out as soap-action is empty . You need to provide this otherwise&lt;br /&gt;
&lt;b&gt;outbound-gateway&lt;/b&gt; &amp;nbsp;- &amp;nbsp;WebService end point with message-sender &amp;nbsp;and unmarshaller&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt; &amp;lt;int:chain input-channel=&quot;myService_countryRequestChannel&quot;
output-channel=&quot;myService_countryRequestOutputChannel&quot; &amp;gt;
 
  &amp;lt;int:service-activator ref=&quot;MyWSTransformer&quot;
   method=&quot;countryRequestSOAPRequest&quot; /&amp;gt;
 
  &amp;lt;!--  &amp;lt;ws:header-enricher&amp;gt;
   &amp;lt;ws:soap-action value=&quot;&quot; /&amp;gt;
  &amp;lt;/ws:header-enricher&amp;gt; --&amp;gt;
 
  &amp;lt;ws:outbound-gateway
   uri=&quot;http://localhost:8080/ws&quot;
   message-sender=&quot;MY.SOAP-MessageSender&quot;  unmarshaller=&quot;myrequestJAXBUnMarshaller&quot;/&amp;gt;
 &amp;lt;/int:chain&amp;gt;
 

&lt;/pre&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Outbound gateway&lt;/h3&gt;
Configure the outbound gateway 
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;  &amp;lt;ws:outbound-gateway

   uri=&quot;${my.purchase.url}&quot;

   message-sender=&quot;MY.SOAP-MessageSender&quot; &amp;nbsp;unmarshaller=&quot;mypurchaseJAXBUnMarshaller&quot;/&amp;gt;

 &amp;lt;/int:chain&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
Authentication can also be added using 
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt; &amp;lt;beans:bean id = &quot;org.apache.commons.httpclient.Credentials-Service&quot;
               class = &quot;org.apache.commons.httpclient.UsernamePasswordCredentials&quot;
               c:userName = &quot;${userName}&quot;
               c:password = &quot;${password}&quot;/&amp;gt;
&lt;/pre&gt;
and specify the ref as &lt;i&gt;credentials-ref&lt;/i&gt; in the ws:outbound-gateway

&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Full XML&lt;/h3&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&amp;gt;

&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;beans:beans  xmlns:int=&quot;http://www.springframework.org/schema/integration&quot;
 xmlns:http=&quot;http://www.springframework.org/schema/integration/http&quot;
 xmlns:ws=&quot;http://www.springframework.org/schema/integration/ws&quot;
 xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; 
 xmlns:beans=&quot;http://www.springframework.org/schema/beans&quot;
 xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
 xmlns:si-xml=&quot;http://www.springframework.org/schema/integration/xml&quot;
  xmlns:oxm = &quot;http://www.springframework.org/schema/oxm&quot;
 xsi:schemaLocation=&quot;
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/integration http://www.springframework.org/schema/integration/spring-integration.xsd
  http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
    http://www.springframework.org/schema/integration/ws http://www.springframework.org/schema/integration/ws/spring-integration-ws.xsd
     http://www.springframework.org/schema/integration/xml http://www.springframework.org/schema/integration/xml/spring-integration-xml.xsd
     http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm.xsd&quot;&amp;gt;
 

&amp;lt;!-- &amp;lt;beans:bean id=&quot;myManager&quot;
     class=&quot;com.my.services.manager.MyServiceImpl&quot; &amp;gt;
    &amp;lt;beans:property name=&quot;myService&quot; ref=&quot;myService&quot; /&amp;gt;
 &amp;lt;/beans:bean&amp;gt;
  --&amp;gt;
  &amp;lt;beans:bean id=&quot;MyWSTransformer&quot;
     class=&quot;com.my.services.transformer.MyWSTransformer&quot; /&amp;gt;
 
 &amp;lt;beans:bean id=&quot;MY.SOAP-MessageSender&quot;
  class=&quot;org.springframework.ws.transport.http.HttpComponentsMessageSender&quot;&amp;gt;
  &amp;lt;beans:property name=&quot;connectionTimeout&quot; value=&quot;3000&quot; /&amp;gt;
  &amp;lt;beans:property name=&quot;readTimeout&quot; value=&quot;5000&quot; /&amp;gt;
 &amp;lt;/beans:bean&amp;gt;
 
  &amp;lt;int:publish-subscribe-channel id=&quot;myService_routingChannel&quot; /&amp;gt;
  
 &amp;lt;int:gateway id=&quot;myService&quot; service-interface=&quot;com.my.services.api.MyService&quot;
  default-request-channel=&quot;myService_routingChannel&quot;&amp;gt;
  &amp;lt;int:method name=&quot;countryRequest&quot;&amp;gt;
   &amp;lt;int:header name=&quot;REQUEST_TYPE&quot; value=&quot;countryRequest&quot; /&amp;gt;
  &amp;lt;/int:method&amp;gt;
 &amp;lt;/int:gateway&amp;gt;
  
 &amp;lt;int:header-value-router input-channel=&quot;myService_routingChannel&quot; header-name=&quot;REQUEST_TYPE&quot;&amp;gt;
  &amp;lt;int:mapping value=&quot;countryRequest&quot; channel=&quot;myService_countryRequestChannel&quot; /&amp;gt;
 &amp;lt;/int:header-value-router&amp;gt;
 
 &amp;lt;int:channel id=&quot;myService_countryRequestChannel&quot; /&amp;gt;
 
 &amp;lt;int:chain input-channel=&quot;myService_countryRequestChannel&quot;
output-channel=&quot;myService_countryRequestOutputChannel&quot; &amp;gt;
 
  &amp;lt;int:service-activator ref=&quot;MyWSTransformer&quot;
   method=&quot;countryRequestSOAPRequest&quot; /&amp;gt;
 
  &amp;lt;!--  &amp;lt;ws:header-enricher&amp;gt;
   &amp;lt;ws:soap-action value=&quot;&quot; /&amp;gt;
  &amp;lt;/ws:header-enricher&amp;gt; --&amp;gt;
 
  &amp;lt;ws:outbound-gateway
   uri=&quot;http://localhost:8080/ws&quot;
   message-sender=&quot;MY.SOAP-MessageSender&quot;  unmarshaller=&quot;myrequestJAXBUnMarshaller&quot;/&amp;gt;
 &amp;lt;/int:chain&amp;gt;
 
 
   &amp;lt;si-xml:unmarshalling-transformer id=&quot;countryRequestUnmarshaller&quot;
  input-channel=&quot;myService_countryRequestOutputChannel&quot;
  unmarshaller=&quot;myrequestJAXBUnMarshaller&quot; /&amp;gt;
 
   &amp;lt;oxm:jaxb2-marshaller id = &quot;myrequestJAXBUnMarshaller&quot;&amp;gt;
    &amp;lt;oxm:class-to-be-bound name = &quot;io.spring.guides.gs_producing_web_service.GetCountryResponse&quot;/&amp;gt;
   &amp;lt;oxm:class-to-be-bound name = &quot;io.spring.guides.gs_producing_web_service.Country&quot;/&amp;gt;
   &amp;lt;oxm:class-to-be-bound name = &quot;io.spring.guides.gs_producing_web_service.Currency&quot;/&amp;gt;
  &amp;lt;!--   &amp;lt;oxm:class-to-be-bound name = &quot;io.spring.guides.gs_producing_web_service.GetCountryRequest&quot;/&amp;gt; --&amp;gt;
  
 &amp;lt;/oxm:jaxb2-marshaller&amp;gt;  
 
 
&amp;lt;/beans:beans&amp;gt;
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Java Transformer&lt;/h3&gt;
&lt;div&gt;
Transformer has the method that makes the SOAP Request call , its clear if you look at the requestXML string.&lt;br /&gt;
GetCountryRequest is already marshaled and available as a input parameter .&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:java&quot;&gt;package com.my.services.transformer;



import java.text.SimpleDateFormat;
 
import java.util.Calendar;
 

import org.slf4j.Logger;
 
import org.slf4j.LoggerFactory;
 
import org.springframework.integration.annotation.Header;
import org.springframework.stereotype.Component;

import io.spring.guides.gs_producing_web_service.GetCountryRequest;
 
 
@Component
public class MyWSTransformer {
 
 static private final Logger logger = LoggerFactory.getLogger(MyWSTransformer.class);
 
 public static String countryRequestSOAPRequest(GetCountryRequest request)
 
 {
 
 logger.info(&quot;Calling MyWSTransformer with GetCountryRequest &quot; +request.getName());
  String requestXml =&quot; &amp;lt;gs:getCountryRequest xmlns:gs=\&quot;http://spring.io/guides/gs-producing-web-service\&quot;&amp;gt;&quot;+
         &quot;  &amp;lt;gs:name&amp;gt;&quot;+request.getName()+&quot;&amp;lt;/gs:name&amp;gt; &quot;+
      &quot; &amp;lt;/gs:getCountryRequest&amp;gt;&quot;;
    
  return requestXml; 
 
 }
 
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/6769682612059975412/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/6769682612059975412' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/6769682612059975412'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/6769682612059975412'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/11/spring-integration-calling-soap-service.html' title='Spring Integration - Calling SOAP Service using Gateway , Channel and Chain'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-3760622030780689055</id><published>2013-10-24T15:30:00.002-07:00</published><updated>2013-10-24T16:12:26.970-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jBPM ActionHandler After Workflow  Node"/><title type='text'>jBPM process after workflow node using ActionHandler</title><content type='html'>
&lt;link href=&#39;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&#39; rel=&#39;stylesheet&#39; type=&#39;text/css&#39;/&gt;
&lt;link href=&#39;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&#39; rel=&#39;stylesheet&#39; type=&#39;text/css&#39;/&gt;

&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;

&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
jBPM process after workflow node using ActionHandler&lt;/h2&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Simple article to show how to do processing after each workflow node and also send values from workflow to ActionHandler&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;
&amp;lt;node name=&amp;quot;Process Node&amp;quot;&amp;gt;&lt;br/&gt;  &amp;lt;action class=&amp;quot;org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler&amp;quot;&amp;gt;&lt;br/&gt;   &amp;lt;esbCategoryName&amp;gt;&lt;br/&gt;    ESB_PROCESSOR_QUOTE&lt;br/&gt;   &amp;lt;/esbCategoryName&amp;gt;&lt;br/&gt;  &amp;lt;/action&amp;gt;&lt;br/&gt;  &amp;lt;event type=&amp;quot;node-leave&amp;quot;&amp;gt;&lt;br/&gt;                    &amp;lt;action class=&amp;quot;event.CustomNodeComplete&amp;quot;&amp;gt;&lt;br/&gt;                              &amp;lt;actionName&amp;gt;Quote Successful&amp;lt;/actionName&amp;gt;&lt;br/&gt;                     &amp;lt;/action&amp;gt;&lt;br/&gt;         &amp;lt;/event&amp;gt;&lt;br/&gt;  &amp;lt;transition to=&amp;quot;Complete&amp;quot;&amp;gt;&amp;lt;/transition&amp;gt;&lt;br/&gt; &amp;lt;/node&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Workflow ProcessDefinition&lt;/h3&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
actionName is passed to the ActionHandler and &amp;nbsp;execute method will be called  if workflow node completes &amp;nbsp;successfully&amp;nbsp;&lt;/div&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
ActionHandler&lt;/h3&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:java&quot;&gt;
public class  CustomNodeComplete implements ActionHandler {&lt;br/&gt;&lt;br/&gt;&lt;br/&gt; private static final long serialVersionUID = -6446921306976005512L;&lt;br/&gt; String actionName;&lt;br/&gt; &lt;br/&gt; &lt;br/&gt; @Override&lt;br/&gt; public void execute(ExecutionContext execContext) throws Exception {&lt;br/&gt;&lt;br/&gt;     //actionName  from workflow available&lt;br/&gt;&lt;br/&gt;     // send notification&lt;br/&gt; }
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/3760622030780689055/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/3760622030780689055' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/3760622030780689055'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/3760622030780689055'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/10/jbpm-process-after-workflow-node-using.html' title='jBPM process after workflow node using ActionHandler'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-5978835038890762033</id><published>2013-10-22T18:17:00.000-07:00</published><updated>2013-10-22T18:23:18.317-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jBPM ActionHandler"/><category scheme="http://www.blogger.com/atom/ns#" term="jBPM decision node alternative"/><title type='text'>jBPM Node for Decision using ActionHandler </title><content type='html'>&lt;link href=&#39;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&#39; rel=&#39;stylesheet&#39; type=&#39;text/css&#39;/&gt;
&lt;link href=&#39;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&#39; rel=&#39;stylesheet&#39; type=&#39;text/css&#39;/&gt;

&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;

&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
jBPM use non-decision node to choose workflow path&lt;/h2&gt;
&lt;div&gt;
You can use the decision node to choose one of the workflow path . This is to show a workaround if you have constrains using the decision node.&amp;nbsp;
Shown below simple workflow and can either branch to &amp;nbsp;&quot;Yes&quot; path or &quot;No&quot; path based on the decision by Node - ValidQuote&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7LGCotH06tXHYZbwX6vZSKTgzyIzFdulzzC3Dh_fGomFt8lmASZRklWHre107K1yVXWMXtQZICswzMgGZrV-Mb4n_oxAOw9RT3JKbOwA4GQVpj-IALU-9E3wN1HGaTriFciDPjjnHgMYB/s1600/Screen+Shot+2013-10-22+at+6.06.02+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;373&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7LGCotH06tXHYZbwX6vZSKTgzyIzFdulzzC3Dh_fGomFt8lmASZRklWHre107K1yVXWMXtQZICswzMgGZrV-Mb4n_oxAOw9RT3JKbOwA4GQVpj-IALU-9E3wN1HGaTriFciDPjjnHgMYB/s400/Screen+Shot+2013-10-22+at+6.06.02+PM.png&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Process Definition&amp;nbsp;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;
&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot;?&amp;gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;process-definition  xmlns=&amp;quot;&amp;quot;  name=&amp;quot;Quote Process&amp;quot;&amp;gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt; &amp;lt;start-state name=&amp;quot;Start&amp;quot;&amp;gt;&lt;br/&gt;  &amp;lt;transition to=&amp;quot;Process Quote&amp;quot;&amp;gt;&amp;lt;/transition&amp;gt;&lt;br/&gt; &amp;lt;/start-state&amp;gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt; &amp;lt;node name=&amp;quot;Process Quote&amp;quot;&amp;gt;&lt;br/&gt;  &amp;lt;action class=&amp;quot;org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler&amp;quot;&amp;gt;&lt;br/&gt;   &amp;lt;esbServiceName&amp;gt;&lt;br/&gt;    ProcessQuote&lt;br/&gt;   &amp;lt;/esbServiceName&amp;gt;&lt;br/&gt;   &amp;lt;esbCategoryName&amp;gt;&lt;br/&gt;    ESB_PROCESS_QUOTE&lt;br/&gt;   &amp;lt;/esbCategoryName&amp;gt;&lt;br/&gt;  &amp;lt;/action&amp;gt;&lt;br/&gt;  &amp;lt;transition to=&amp;quot;ValidQuote&amp;quot;&amp;gt;&amp;lt;/transition&amp;gt;&lt;br/&gt; &amp;lt;/node&amp;gt;&lt;br/&gt;&lt;br/&gt; &amp;lt;node name=&amp;quot;ValidQuote&amp;quot;&amp;gt;&lt;br/&gt;  &amp;lt;action name=&amp;quot;ValidQuote&amp;quot; class=&amp;quot;event.ValidQuote&amp;quot;&amp;gt;&amp;lt;/action&amp;gt;&lt;br/&gt;  &amp;lt;transition to=&amp;quot;Log-NotifyCSR&amp;quot; name=&amp;quot;No&amp;quot;&amp;gt;&amp;lt;/transition&amp;gt;&lt;br/&gt;  &amp;lt;transition to=&amp;quot;EmailCustomer&amp;quot; name=&amp;quot;Yes&amp;quot;&amp;gt;&amp;lt;/transition&amp;gt;&lt;br/&gt; &amp;lt;/node&amp;gt;&lt;br/&gt;&lt;br/&gt; &amp;lt;node name=&amp;quot;EmailCustomer&amp;quot;&amp;gt;&lt;br/&gt;  &amp;lt;action class=&amp;quot;org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler&amp;quot;&amp;gt;&lt;br/&gt;   &amp;lt;esbCategoryName&amp;gt;&lt;br/&gt;    ESB_EMAIL&lt;br/&gt;   &amp;lt;/esbCategoryName&amp;gt;&lt;br/&gt;  &amp;lt;/action&amp;gt;&lt;br/&gt;  &amp;lt;transition to=&amp;quot;Complete&amp;quot;&amp;gt;&amp;lt;/transition&amp;gt;&lt;br/&gt; &amp;lt;/node&amp;gt;&lt;br/&gt;&lt;br/&gt; &amp;lt;node name=&amp;quot;Log-NotifyCSR&amp;quot;&amp;gt;&lt;br/&gt;  &amp;lt;action class=&amp;quot;org.jboss.soa.esb.services.jbpm.actionhandlers.EsbActionHandler&amp;quot;&amp;gt;&lt;br/&gt;   &amp;lt;esbCategoryName&amp;gt;&lt;br/&gt;    ESB_CSR&lt;br/&gt;   &amp;lt;/esbCategoryName&amp;gt;&lt;br/&gt;  &amp;lt;/action&amp;gt;&lt;br/&gt;  &amp;lt;transition to=&amp;quot;Complete&amp;quot;&amp;gt;&amp;lt;/transition&amp;gt;&lt;br/&gt; &amp;lt;/node&amp;gt;&lt;br/&gt;&lt;br/&gt; &amp;lt;end-state name=&amp;quot;Complete&amp;quot;&amp;gt;&amp;lt;/end-state&amp;gt;&lt;br/&gt;&lt;br/&gt;&lt;br/&gt;&amp;lt;/process-definition&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
Action Handler ( defined in the ValidQuote)&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;pre class=&quot;brush:java&quot;&gt;
package event;&lt;br/&gt;import org.jbpm.graph.exe.ExecutionContext;&lt;br/&gt;&lt;br/&gt;public class  ValidQuote implements ActionHandler {&lt;br/&gt;&lt;br/&gt; @Override&lt;br/&gt; public void execute(ExecutionContext execContext) throws Exception {&lt;br/&gt;&lt;br/&gt; if( somecondition...)&lt;br/&gt;  execContext.leaveNode(&amp;quot;Yes&amp;quot;);&lt;br/&gt; else&lt;br/&gt;  execContext.leaveNode(&amp;quot;No&amp;quot;);&lt;br/&gt; }&lt;br/&gt;&lt;br/&gt;}
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: left;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/5978835038890762033/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/5978835038890762033' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/5978835038890762033'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/5978835038890762033'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/10/jbpm-node-for-decision-using.html' title='jBPM Node for Decision using ActionHandler '/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi7LGCotH06tXHYZbwX6vZSKTgzyIzFdulzzC3Dh_fGomFt8lmASZRklWHre107K1yVXWMXtQZICswzMgGZrV-Mb4n_oxAOw9RT3JKbOwA4GQVpj-IALU-9E3wN1HGaTriFciDPjjnHgMYB/s72-c/Screen+Shot+2013-10-22+at+6.06.02+PM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-1711389952317271059</id><published>2013-10-16T15:14:00.001-07:00</published><updated>2013-10-16T15:32:31.091-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="soap  ui groovyutils"/><category scheme="http://www.blogger.com/atom/ns#" term="soap ui  mock service"/><category scheme="http://www.blogger.com/atom/ns#" term="soap ui dynamic mock service"/><title type='text'>SOAP UI Dynamic mock service using Groovy Script</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;

&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;

&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
SOAP UI Dynamic mock service using Groovy Script&lt;/h2&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
Create dynamic mock service using SOAP UI . You will just need the WSDL . You should be familiar using the soap ui and creating the mock service . Following is to only make it dynamic&lt;/div&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Create a SoapUI project using the WSDL . Right click and select the mock service .&lt;/li&gt;
&lt;li&gt;Select the &amp;nbsp;WebService Method and Open the Response that has to be customized&lt;/li&gt;
&lt;li&gt;Create two files for Success and Error response and place them in folder &amp;nbsp;{Project-Path}/responses&lt;/li&gt;
&lt;li&gt;WebService Response ( Right portion of the Soap UI Window )will be made dynamic based on request. &amp;nbsp;Delete everything from mock response and &amp;nbsp;replace with&lt;b&gt;${content} &lt;/b&gt;. &amp;nbsp;This value will be dynamically rendered from &amp;nbsp;groovy script&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh82BbBiKv4267V4YiFS_ZQq6ft2UA1rZZogLbbudPtRV3LlYbH0w-snEoK3A2-MXWr5ZtltP4zVPwBBKGuoNXRjI77oqe-113TJo-aF1eA2qEKymST-hxSdFOWe1F9GIYsRLbGlYHPm3DK/s1600/Screen+Shot+2013-10-16+at+3.30.27+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;244&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh82BbBiKv4267V4YiFS_ZQq6ft2UA1rZZogLbbudPtRV3LlYbH0w-snEoK3A2-MXWr5ZtltP4zVPwBBKGuoNXRjI77oqe-113TJo-aF1eA2qEKymST-hxSdFOWe1F9GIYsRLbGlYHPm3DK/s320/Screen+Shot+2013-10-16+at+3.30.27+PM.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Choose Dispatch -&amp;gt; Script , and then choose Dynamic Reponse&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMFDFpp_8We4QubCrhQ5RTj4kAgijuNhvk8qF4vP_U9PZAWpF-kLl9piGCrvAI4y5gPZEISId9jUcJ6XbaqvOjn11CNPywSETYKYKcempOgFY0Ui7YEbfqoO4LnClvTBqFfdvQ-4tXnC03/s1600/Screen+Shot+2013-10-16+at+3.30.58+PM.png&quot; imageanchor=&quot;1&quot; style=&quot;margin-left: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;132&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMFDFpp_8We4QubCrhQ5RTj4kAgijuNhvk8qF4vP_U9PZAWpF-kLl9piGCrvAI4y5gPZEISId9jUcJ6XbaqvOjn11CNPywSETYKYKcempOgFY0Ui7YEbfqoO4LnClvTBqFfdvQ-4tXnC03/s320/Screen+Shot+2013-10-16+at+3.30.58+PM.png&quot; width=&quot;320&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;Use the groovy script below , to render Success and Error Responses .&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
It works in the following way ,&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;if quotenumber is 9999 &amp;nbsp;- send Error response&lt;/li&gt;
&lt;li&gt;anything else - send Success Response&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you can create more test cases and test them by changing the input in the xml . Providing &amp;nbsp;the input , output and the script below &lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;&lt;br /&gt;&lt;/i&gt;
&lt;i&gt;Input ( for ref )&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:test=&quot;http://www.testing.com/WS/quoteWS&quot;&amp;gt;

&amp;nbsp; &amp;lt;soapenv:Header/&amp;gt;

&amp;nbsp; &amp;lt;soapenv:Body&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;test:Quote&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;QuoteRequest&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;quoteNumber&amp;gt;9999&amp;lt;/quoteNumber&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;quoteTitle&amp;gt;?&amp;lt;/quoteTitle&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;quotePrice&amp;gt;?&amp;lt;/quotePrice&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/QuoteRequest&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/test:Quote&amp;gt;

&amp;nbsp; &amp;lt;/soapenv:Body&amp;gt;

&amp;lt;/soapenv:Envelope&amp;gt;&#39;

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Output&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Success&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:test=&quot;http://www.testing.com/WS/quoteWS&quot;&amp;gt;

&amp;nbsp; &amp;lt;soapenv:Header/&amp;gt;

&amp;nbsp; &amp;lt;soapenv:Body&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;test:QuoteResponse&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;QuoteReply&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;status&amp;gt;Success&amp;lt;/status&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!--Optional:--&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;errorCode&amp;gt;0&amp;lt;/errorCode&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!--Optional:--&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;errorMessage&amp;gt;&amp;lt;/errorMessage&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!--Optional:--&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;errorDetail&amp;gt;&amp;lt;/errorDetail&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/QuoteReply&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/test:QuoteResponse&amp;gt;

&amp;nbsp; &amp;lt;/soapenv:Body&amp;gt;

&amp;lt;/soapenv:Envelope&amp;gt;

&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Error&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;soapenv:Envelope xmlns:soapenv=&quot;http://schemas.xmlsoap.org/soap/envelope/&quot; xmlns:test=&quot;http://www.testing.com/WS/quoteWS&quot;&amp;gt;

&amp;nbsp; &amp;lt;soapenv:Header/&amp;gt;

&amp;nbsp; &amp;lt;soapenv:Body&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;test:QuoteResponse&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;QuoteReply&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;status&amp;gt;ERROR&amp;lt;/status&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!--Optional:--&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;errorCode&amp;gt;11&amp;lt;/errorCode&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!--Optional:--&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;errorMessage&amp;gt;Failed&amp;lt;/errorMessage&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;!--Optional:--&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;errorDetail&amp;gt;Something failed &amp;lt;/errorDetail&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/QuoteReply&amp;gt;

&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/test:QuoteResponse&amp;gt;

&amp;nbsp; &amp;lt;/soapenv:Body&amp;gt;

&amp;lt;/soapenv:Envelope&amp;gt;

&lt;/pre&gt;
&lt;i&gt;&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;/i&gt;
&lt;i&gt;&lt;b&gt;Groovy Script 
&lt;/b&gt;&lt;/i&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;import com.eviware.soapui.support.GroovyUtils

import groovy.xml.XmlUtil

log.info &#39;start&#39;

def groovyUtils = new GroovyUtils(context)

def xmlParser = new XmlParser()

def responseContent

def requestXmlHolder = groovyUtils.getXmlHolder(mockRequest.getRequestContent())

requestXmlHolder.declareNamespace(&quot;test&quot;,&quot;http://www.testing.com/WS/quoteWS&quot;)

def quoteNumber = requestXmlHolder.getNodeValue(&quot;//test:Quote/QuoteRequest[1]/quoteNumber[1]&quot;)

log.info &amp;nbsp;quoteNumber



if(quoteNumber == &#39;9999&#39;)

{

responseContent = xmlParser.parse(groovyUtils.projectPath +&quot;/responses/error-response.xml&quot;)


}

else

{

responseContent = xmlParser.parse(groovyUtils.projectPath +&quot;/responses/success-response.xml&quot;)

}

context.content = XmlUtil.serialize(responseContent)

log.info &#39;complete&#39;
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/1711389952317271059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/1711389952317271059' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/1711389952317271059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/1711389952317271059'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/10/soap-ui-dynamic-mock-service-using.html' title='SOAP UI Dynamic mock service using Groovy Script'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh82BbBiKv4267V4YiFS_ZQq6ft2UA1rZZogLbbudPtRV3LlYbH0w-snEoK3A2-MXWr5ZtltP4zVPwBBKGuoNXRjI77oqe-113TJo-aF1eA2qEKymST-hxSdFOWe1F9GIYsRLbGlYHPm3DK/s72-c/Screen+Shot+2013-10-16+at+3.30.27+PM.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-4237265997350041374</id><published>2013-10-09T16:31:00.001-07:00</published><updated>2013-10-11T08:53:10.914-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="spring jaxb webservicetemplate"/><category scheme="http://www.blogger.com/atom/ns#" term="spring webservice"/><category scheme="http://www.blogger.com/atom/ns#" term="spring webservicetemplate"/><title type='text'>Spring Webservice  using WebServiceTemplate</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;

&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;


&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
WebServiceTemplate 
&lt;/h2&gt;
&lt;div&gt;
Here is the bean&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:xml&quot;&gt; &amp;lt;bean id=&quot;wsTemplate&quot; class=&quot;org.springframework.ws.client.core.WebServiceTemplate&quot;&amp;gt;
                &amp;lt;property name=&quot;defaultUri&quot; value=&quot;http://localhost:8080/quote_test&quot;/&amp;gt;
                &amp;lt;property name=&quot;marshaller&quot; ref=&quot;QuoteRequestJAXBMarshaller&quot;/&amp;gt;                 
                &amp;lt;property name=&quot;unmarshaller&quot; ref=&quot;QuoteResponseJAXBMarshaller&quot;/&amp;gt;
        &amp;lt;/bean&amp;gt; 
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
You will need  Marshaller and Unmarshaller , its part of oxm 
&lt;br /&gt;
include these in the header
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;  xmlns:oxm = &quot;http://www.springframework.org/schema/oxm&quot;
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
setup the marshaller and unmarshaller
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;  
&amp;lt;oxm:jaxb2-marshaller id = &quot;QuoteRequestJAXBMarshaller&quot;&amp;gt;
    &amp;lt;oxm:class-to-be-bound name = &quot;com.quote.services.model.Quote&quot;/&amp;gt;
  &amp;lt;/oxm:jaxb2-marshaller&amp;gt;  
  
  &amp;lt;oxm:jaxb2-marshaller id = &quot;QuoteResponseJAXBMarshaller&quot;&amp;gt;
    &amp;lt;oxm:class-to-be-bound name = &quot;com.quote.services.model.QuoteResponse&quot;/&amp;gt;
  &amp;lt;/oxm:jaxb2-marshaller&amp;gt;  
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
Marshaller and a UnMarshaller can be generated by  &lt;b&gt;xjc&lt;/b&gt; utility on schema (or) &lt;b&gt;wsimport&lt;/b&gt; on WSDL. If you don&#39;t have the schema , it can be generated by the xml using many tools like&amp;nbsp;&lt;a href=&quot;http://www.freeformatter.com/&quot;&gt;http://www.freeformatter.com/&lt;/a&gt;&amp;nbsp; Here is example of xjc using ant&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:xml&quot;&gt; 
  &amp;lt;?xml version = &quot;1.0&quot; encoding = &quot;UTF-8&quot;?&amp;gt;

&amp;lt;project name = &quot;mywsproject&quot; 
        default = &quot;generate&quot;&amp;gt;
 &amp;lt;property file = &quot;build.properties&quot;/&amp;gt;
 
  &amp;lt;fileset id = &quot;tools&quot; 
           dir = &quot;tools&quot;&amp;gt;
    &amp;lt;include name = &quot;**/*.jar&quot;/&amp;gt;
  &amp;lt;/fileset&amp;gt; 
 
 &amp;lt;taskdef name = &quot;xjc&quot; classname = &quot;com.sun.tools.xjc.XJCTask&quot;&amp;gt;
   &amp;lt;classpath&amp;gt;
     &amp;lt;fileset refid = &quot;tools&quot;/&amp;gt;
   &amp;lt;/classpath&amp;gt;
 &amp;lt;/taskdef&amp;gt;
 
 &amp;lt;target name = &quot;generate&quot;&amp;gt;
  &amp;lt;xjc schema = &quot;src/main/xml/quote.xsd&quot; 
      destdir = &quot;src/main/java&quot; 
      package = &quot;com.quote.services.model&quot;/&amp;gt;
 &amp;lt;/target&amp;gt; 
&amp;lt;/project&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;div style=&quot;-webkit-text-stroke-width: 0px; color: black; font-family: Times; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;&quot;&gt;
&lt;div style=&quot;margin: 0px;&quot;&gt;
&amp;nbsp;WSDL will have the schema and &quot;wsimport&quot; utility will generate the Classes for Marshaling and Un-Marshaling ( details of the wsimport utility can be found here&amp;nbsp;&lt;a href=&quot;http://ajaxrocks.blogspot.com/2013/08/jax-ws-call-ws-using-maven.html&quot; style=&quot;background-color: white; color: dimgrey; font-family: Arial, Tahoma, Helvetica, FreeSans, sans-serif; font-size: 13px; line-height: 18px; text-decoration: none;&quot; target=&quot;_blank&quot;&gt;http://ajaxrocks.blogspot.com/2013/08/jax-ws-call-ws-using-maven.html&lt;/a&gt;) ,after generation delete the &amp;nbsp;webservice and webservice port type classes .&lt;/div&gt;
&lt;div style=&quot;margin: 0px;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
No matter which way you use for generating the classes , you have to review and look for &amp;nbsp;&lt;b&gt;JAXBElement&lt;/b&gt;. Basically if jaxb-api can&#39;t find the type of the element , it will generate as JAXBElement , so your response &amp;nbsp;instead of a &quot;QuoteResponse&quot; will be JAXBElement&amp;lt;&amp;nbsp;QuoteResponse&amp;nbsp;&amp;gt; . It can be fixed by commenting the create method in the ObjectFactory class&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt; 
//   @XmlElementDecl(namespace = &quot;http://www.test.com/WS/QuoteWS&quot;, name = &quot;QuoteResponse&quot;)
//   public JAXBElement&amp;lt;QuoteResponse&amp;gt; createQuoteResponse(QuoteResponse value) {
//       return new JAXBElement&amp;lt;QuoteResponse&amp;gt;( , QuoteResponse.class, null, value);
//   
}
&lt;/pre&gt;
&lt;br /&gt;
This also can happen with the attributes . Example below &quot;errorMessage&quot; is string but not defined correctly in the schema &amp;nbsp;so it become a JAXBElement . Comment these out and create them as String , generate getters and Setters&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt; 

//   @XmlElementRef(name = &quot;errorMessage&quot;, type = JAXBElement.class)
//    protected JAXBElement&amp;lt;String&amp;gt; errorMessage;

&lt;/pre&gt;
Calling from Java Service , is now easy as calling a method and getting a response
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;@Service(&quot;myQuoteService&quot;)
public class QuoteServiceImpl {
    @Autowired
    private WebServiceOperations wsTemplate;
    
    
    public QuoteResponse generateQuote()
    {
     Quote quote = new Quote();
     quote.setPrice(&quot;99.99&quot;);
     quote.setAmount(&quot;100&quot;);
     
     QuoteRequest quoterequest = new QuoteRequest();
     quoterequest.setQuote(quote);
     
     return  (QuoteResponse)wsTemplate.marshalSendAndReceive(quoterequest);
     
    }
}
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/4237265997350041374/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/4237265997350041374' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/4237265997350041374'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/4237265997350041374'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/10/spring-webservice-using.html' title='Spring Webservice  using WebServiceTemplate'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-7958242309174527034</id><published>2013-10-08T21:43:00.002-07:00</published><updated>2013-10-24T15:32:46.487-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JaxWsPortProxyFactoryBean example"/><category scheme="http://www.blogger.com/atom/ns#" term="spring ws using jaxws"/><category scheme="http://www.blogger.com/atom/ns#" term="spring-web"/><title type='text'>Spring Webservice using JAXWS and JaxWsPortProxyFactoryBean</title><content type='html'>&lt;link href=&#39;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&#39; rel=&#39;stylesheet&#39; type=&#39;text/css&#39;/&gt;
&lt;link href=&#39;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&#39; rel=&#39;stylesheet&#39; type=&#39;text/css&#39;/&gt;

&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;




&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Calling WebService using&amp;nbsp;JaxWsPortProxyFactoryBean&lt;/h2&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
This is probably the easiest way to call the webservice . Generate the necessary classes for the webservice by using the &quot;wsimport&quot; utility ( have a look at&lt;a href=&quot;http://ajaxrocks.blogspot.com/2013/08/jax-ws-call-ws-using-maven.html&quot; target=&quot;_blank&quot;&gt;&amp;nbsp;http://ajaxrocks.blogspot.com/2013/08/jax-ws-call-ws-using-maven.html&lt;/a&gt;) . Then you can configure the bean to use the generated classes as shown&lt;/div&gt;
&lt;div&gt;
&amp;nbsp;&lt;/div&gt;
&lt;/div&gt;

&lt;pre class=&quot;brush:xml&quot;&gt;
&amp;lt;bean  id=&amp;quot;myWebservice&amp;quot; class=&amp;quot;org.springframework.remoting.jaxws.JaxWsPortProxyFactoryBean&amp;quot;&amp;gt;&lt;br/&gt;            &amp;lt;property name=&amp;quot;serviceInterface&amp;quot; value=&amp;quot;com.myws.proxy.MyTestWebService&amp;quot; /&amp;gt;&lt;br/&gt;            &amp;lt;property name=&amp;quot;wsdlDocumentUrl&amp;quot; value=&amp;quot;wsdl/mytest-service.wsdl&amp;quot; /&amp;gt;&lt;br/&gt;            &amp;lt;property name=&amp;quot;namespaceUri&amp;quot; value=&amp;quot;http://mycompany.com/myservice&amp;quot; /&amp;gt;&lt;br/&gt;            &amp;lt;property name=&amp;quot;serviceName&amp;quot; value=&amp;quot;MyTestService&amp;quot; /&amp;gt;&lt;br/&gt;            &amp;lt;property name=&amp;quot;endpointAddress&amp;quot; value=&amp;quot;http://www.test.com/webservices/mytest-service?wsdl&amp;quot; /&amp;gt;&lt;br/&gt;            &amp;lt;property name=&amp;quot;username&amp;quot; value=&amp;quot;username&amp;quot;/&amp;gt;  &lt;br/&gt;            &amp;lt;property name=&amp;quot;password&amp;quot; value=&amp;quot;password&amp;quot;/&amp;gt;  &lt;br/&gt;        &amp;lt;/bean&amp;gt;
&lt;/pre&gt;

Use username and password if required otherwise it can be removed .  Just wire this bean to your class and call the webservice 
&lt;P&gt;
JaxWsPortProxyFactoryBean is part of spring-web utility ,You have to include the following in your pom.xml 
&lt;pre class=&quot;brush:xml&quot;&gt;
   &amp;lt;dependency&amp;gt;&lt;br/&gt;         &amp;lt;groupId&amp;gt;org.springframework&amp;lt;/groupId&amp;gt;&lt;br/&gt;         &amp;lt;artifactId&amp;gt;spring-web&amp;lt;/artifactId&amp;gt;&lt;br/&gt;         &amp;lt;version&amp;gt;3.2.3.RELEASE&amp;lt;/version&amp;gt;&lt;br/&gt;       &amp;lt;/dependency&amp;gt;
&lt;/pre&gt;


</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/7958242309174527034/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/7958242309174527034' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/7958242309174527034'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/7958242309174527034'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/10/spring-webservice-using-jaxws-and.html' title='Spring Webservice using JAXWS and JaxWsPortProxyFactoryBean'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-6386377840079526531</id><published>2013-10-03T06:52:00.004-07:00</published><updated>2013-10-03T06:52:34.472-07:00</updated><title type='text'>Garbage Collection Mechanisms and Collectors</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Why is Garbage Collecition desirable ?&lt;/h3&gt;
GC&amp;nbsp;-&amp;nbsp;Programmer&amp;nbsp;not&amp;nbsp;responsible&amp;nbsp;for&amp;nbsp;freeing&amp;nbsp;objects&lt;br /&gt;
Eliminates&amp;nbsp;areas&amp;nbsp;of&amp;nbsp;instability&amp;nbsp;,&amp;nbsp;delay&amp;nbsp;and&amp;nbsp;maintenance&lt;br /&gt;
&lt;br /&gt;
No&amp;nbsp;GC&amp;nbsp;-&amp;nbsp;&quot;memory&amp;nbsp;management&amp;nbsp;contract&quot;&lt;br /&gt;
Uncoordinated&amp;nbsp;libraries,&amp;nbsp;frameworks&amp;nbsp;,&amp;nbsp;utilities&lt;br /&gt;
&lt;br /&gt;
GC&amp;nbsp;is&amp;nbsp;efficient&amp;nbsp;for&amp;nbsp;allocating&amp;nbsp;and&amp;nbsp;freeing&amp;nbsp;memory&lt;br /&gt;
%&amp;nbsp;of&amp;nbsp;CPU&amp;nbsp;can&amp;nbsp;be&amp;nbsp;tuned&amp;nbsp;for&amp;nbsp;GC&lt;br /&gt;
Dead&amp;nbsp;Objects&amp;nbsp;cost&amp;nbsp;nothing&amp;nbsp;to&amp;nbsp;collect&lt;br /&gt;
GC&amp;nbsp;will&amp;nbsp;find&amp;nbsp;all&amp;nbsp;dead&amp;nbsp;objects&amp;nbsp;(&amp;nbsp;don&#39;t&amp;nbsp;worry&amp;nbsp;about&amp;nbsp;complexity&amp;nbsp;)&lt;br /&gt;
&lt;br /&gt;
Rate 1 sec&amp;nbsp;per&amp;nbsp;live&amp;nbsp;GB&amp;nbsp;-&amp;nbsp;most&amp;nbsp;JVM&lt;br /&gt;
General&amp;nbsp;Usage&amp;nbsp;Heap&amp;nbsp;Size&amp;nbsp;use&amp;nbsp;-&amp;nbsp;1&amp;nbsp;-4GB&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Improve Garbage Collection&amp;nbsp;&lt;/h3&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Architecture&lt;/li&gt;
&lt;li&gt;Object&amp;nbsp;Pooling&lt;/li&gt;
&lt;li&gt;Off&amp;nbsp;heap&amp;nbsp;storage&lt;/li&gt;
&lt;li&gt;Distributed&amp;nbsp;heaps&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Types of Garbage Collection&lt;/h3&gt;
&lt;ol style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;Concurrent&amp;nbsp;Collector&amp;nbsp;-&amp;nbsp;runs&amp;nbsp;with&amp;nbsp;your&amp;nbsp;application&lt;/li&gt;
&lt;li&gt;Parallel&amp;nbsp;Collector&amp;nbsp;-&amp;nbsp;more&amp;nbsp;than&amp;nbsp;1&amp;nbsp;thread&amp;nbsp;to&amp;nbsp;do&amp;nbsp;GC&lt;/li&gt;
&lt;li&gt;Stop-the-World&amp;nbsp;-&amp;nbsp;GC&amp;nbsp;when&amp;nbsp;application&amp;nbsp;is&amp;nbsp;stopped&lt;/li&gt;
&lt;li&gt;Incremental&amp;nbsp;-&amp;nbsp;performs&amp;nbsp;as&amp;nbsp;small&amp;nbsp;discrete&amp;nbsp;operations&lt;/li&gt;
&lt;li&gt;Mostly&amp;nbsp;-&amp;nbsp;mix&amp;nbsp;of&amp;nbsp;GC&amp;nbsp;techniques&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
&lt;br /&gt;
Precise&amp;nbsp;vs&amp;nbsp;Conservative&amp;nbsp;Collector&lt;br /&gt;
Conservative&amp;nbsp;-&amp;nbsp;unaware&amp;nbsp;of&amp;nbsp;object&amp;nbsp;references&lt;br /&gt;
Precise&amp;nbsp;-&amp;nbsp;fully&amp;nbsp;identify&amp;nbsp;object&amp;nbsp;references&amp;nbsp;at&amp;nbsp;time&amp;nbsp;collector&amp;nbsp;needs&amp;nbsp;to&amp;nbsp;run&lt;br /&gt;
(&amp;nbsp;required&amp;nbsp;for&amp;nbsp;moving&amp;nbsp;objects&amp;nbsp;)&lt;br /&gt;
&lt;br /&gt;
Commercial&amp;nbsp;all Garbage Collectors are Precise&lt;br /&gt;
&lt;br /&gt;
&lt;h4 style=&quot;text-align: left;&quot;&gt;
Safepoint&lt;/h4&gt;
GC&amp;nbsp;Safepoint&amp;nbsp;-&amp;nbsp;point&amp;nbsp;or&amp;nbsp;rage&amp;nbsp;in&amp;nbsp;thread&amp;nbsp;execution&amp;nbsp;where&amp;nbsp;the&amp;nbsp;collector&amp;nbsp;can&amp;nbsp;identify&amp;nbsp;all&amp;nbsp;the&lt;br /&gt;
thread&#39;s&amp;nbsp;execution&amp;nbsp;stack&lt;br /&gt;
-&amp;nbsp;Bring&amp;nbsp;a&amp;nbsp;thread&amp;nbsp;to&amp;nbsp;safe&amp;nbsp;point&amp;nbsp;,&amp;nbsp;to&amp;nbsp;reach&amp;nbsp;a&amp;nbsp;safe&amp;nbsp;point&amp;nbsp;but&amp;nbsp;not&amp;nbsp;to&amp;nbsp;stop&lt;br /&gt;
Global&amp;nbsp;Safepoint&amp;nbsp;-&amp;nbsp;all&amp;nbsp;threads&amp;nbsp;are&amp;nbsp;at&amp;nbsp;safe&amp;nbsp;point&amp;nbsp;&amp;nbsp;-&amp;nbsp;need&amp;nbsp;of&amp;nbsp;Stop-the-World&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Precise&lt;/h3&gt;
Identify&amp;nbsp;live&amp;nbsp;objects&lt;br /&gt;
Reclaim&amp;nbsp;resources&amp;nbsp;by&amp;nbsp;dead&amp;nbsp;objects&lt;br /&gt;
Periodically&amp;nbsp;relocate&amp;nbsp;live&amp;nbsp;objects&lt;br /&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Mechanisms&lt;/h2&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Mark/Sweep/Compact&amp;nbsp;-&amp;nbsp;Old&amp;nbsp;Generation&lt;/h3&gt;
Mark&amp;nbsp;-&amp;nbsp;start&amp;nbsp;from&amp;nbsp;&quot;roots&quot;&amp;nbsp;and&amp;nbsp;paint&amp;nbsp;anything&amp;nbsp;reachable&amp;nbsp;as&amp;nbsp;&quot;live&quot;&amp;nbsp;,&amp;nbsp;anything&amp;nbsp;not&amp;nbsp;reachable&amp;nbsp;is&amp;nbsp;dead&lt;br /&gt;
Sweep&amp;nbsp;-&amp;nbsp;identify&amp;nbsp;&quot;dead&quot;&amp;nbsp;objects&amp;nbsp;and&amp;nbsp;put&amp;nbsp;in&amp;nbsp;free&amp;nbsp;list&lt;br /&gt;
Compact&amp;nbsp;-&amp;nbsp;contiguous&amp;nbsp;dead&amp;nbsp;space&amp;nbsp;between&amp;nbsp;objects&amp;nbsp;may&amp;nbsp;become&amp;nbsp;too&amp;nbsp;large&amp;nbsp;(&amp;nbsp;similar&amp;nbsp;to&amp;nbsp;&quot;swiss&amp;nbsp;cheesed&quot;)&lt;br /&gt;
&amp;nbsp;1.&amp;nbsp;move&amp;nbsp;live&amp;nbsp;objects&amp;nbsp;to&amp;nbsp;get&amp;nbsp;contiguous&amp;nbsp;empty&amp;nbsp;space&amp;nbsp;-&quot;relocate&quot;&lt;br /&gt;
&amp;nbsp;2.&amp;nbsp;Correct&amp;nbsp;all&amp;nbsp;object&amp;nbsp;references&amp;nbsp;-&quot;remap&quot;&lt;br /&gt;
&lt;br /&gt;
requires&amp;nbsp;2x&amp;nbsp;only&amp;nbsp;the&amp;nbsp;full&amp;nbsp;GC&amp;nbsp;has&amp;nbsp;to&amp;nbsp;be&amp;nbsp;run&amp;nbsp;,&amp;nbsp;can&amp;nbsp;be&amp;nbsp;stopped&amp;nbsp;and&amp;nbsp;restarted&lt;br /&gt;
Its&amp;nbsp;not&amp;nbsp;Monolithic&amp;nbsp;.&lt;br /&gt;
Linear&amp;nbsp;to&amp;nbsp;heap&amp;nbsp;size&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Copying&amp;nbsp;Collectors&lt;/h3&gt;
Copy&amp;nbsp;Collectors&amp;nbsp;-&amp;nbsp;move&amp;nbsp;from&amp;nbsp;space&amp;nbsp;a&amp;nbsp;to&amp;nbsp;b&amp;nbsp;,&amp;nbsp;copy&amp;nbsp;happens&amp;nbsp;by&amp;nbsp;&quot;root&quot;reference&amp;nbsp;and&amp;nbsp;copies&amp;nbsp;reachable&amp;nbsp;objects.Monolithic&amp;nbsp;-&amp;nbsp;Start&amp;nbsp;can&#39;t&amp;nbsp;be&amp;nbsp;stopped&amp;nbsp;.&amp;nbsp;Copy&amp;nbsp;requires&amp;nbsp;2x&amp;nbsp;memory&amp;nbsp;.&lt;br /&gt;
Linear&amp;nbsp;to&amp;nbsp;live-set&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;Generational&amp;nbsp;Collection&lt;/h3&gt;
&amp;nbsp;&amp;nbsp;-&amp;nbsp;Weak&amp;nbsp;generational&amp;nbsp;hypothesis&amp;nbsp;-&quot;most&amp;nbsp;objects&amp;nbsp;die&amp;nbsp;young&quot;&lt;br /&gt;
&amp;nbsp;Focus&amp;nbsp;collection&amp;nbsp;efforts&lt;br /&gt;
&amp;nbsp;&amp;nbsp;-&amp;nbsp;use&amp;nbsp;moving&amp;nbsp;collector&amp;nbsp;:&amp;nbsp;work&amp;nbsp;is&amp;nbsp;linear&amp;nbsp;to&amp;nbsp;the&amp;nbsp;live&amp;nbsp;set&lt;br /&gt;
&amp;nbsp;&amp;nbsp;-&amp;nbsp;live&amp;nbsp;set&amp;nbsp;in&amp;nbsp;the&amp;nbsp;young&amp;nbsp;generation&amp;nbsp;is&amp;nbsp;a&amp;nbsp;small&amp;nbsp;%&amp;nbsp;of&amp;nbsp;space&lt;br /&gt;
&amp;nbsp;&amp;nbsp;-&amp;nbsp;Promote&amp;nbsp;objects&amp;nbsp;that&amp;nbsp;live&amp;nbsp;long&amp;nbsp;enough&amp;nbsp;to&amp;nbsp;older&amp;nbsp;generations&lt;br /&gt;
&lt;br /&gt;
Moving&amp;nbsp;collector&amp;nbsp;for&amp;nbsp;recent&amp;nbsp;objects&amp;nbsp;,&amp;nbsp;and&amp;nbsp;use&amp;nbsp;Mark&amp;nbsp;sweep&amp;nbsp;for&amp;nbsp;old&amp;nbsp;objects&amp;nbsp;-&amp;nbsp;Efficient&amp;nbsp;and&amp;nbsp;works&amp;nbsp;for&amp;nbsp;most&amp;nbsp;objects&lt;br /&gt;
&lt;br /&gt;
-&amp;nbsp;Required&amp;nbsp;&quot;Remembered&amp;nbsp;set&quot;&amp;nbsp;-&amp;nbsp;say&amp;nbsp;to&amp;nbsp;track&amp;nbsp;all&amp;nbsp;references&amp;nbsp;into&amp;nbsp;the&amp;nbsp;young&amp;nbsp;generation&lt;br /&gt;
&amp;nbsp;basically&amp;nbsp;multiple&amp;nbsp;roots&amp;nbsp;for&amp;nbsp;different&amp;nbsp;collectors&amp;nbsp;.&amp;nbsp;Move&amp;nbsp;surviving&amp;nbsp;objects&amp;nbsp;to&amp;nbsp;old&amp;nbsp;generation&lt;br /&gt;
&lt;br /&gt;
&quot;Remembered&amp;nbsp;set&quot;&amp;nbsp;needs&amp;nbsp;memory&amp;nbsp;for&amp;nbsp;execution&lt;br /&gt;
&lt;br /&gt;
&quot;Card&amp;nbsp;Marking&quot;-&amp;nbsp;&amp;nbsp;bit&amp;nbsp;to&amp;nbsp;generate&amp;nbsp;oldGen&amp;nbsp;is&amp;nbsp;a&amp;nbsp;suspect&lt;br /&gt;
&lt;br /&gt;
Empty&amp;nbsp;memory&amp;nbsp;==&amp;nbsp;CPU&amp;nbsp;power&lt;br /&gt;
&lt;br /&gt;
Concurrent&amp;nbsp;Marking&amp;nbsp;-&amp;nbsp;may&amp;nbsp;take&amp;nbsp;a&amp;nbsp;while&amp;nbsp;and&amp;nbsp;you&amp;nbsp;may&amp;nbsp;be&amp;nbsp;left&amp;nbsp;with&amp;nbsp;no&amp;nbsp;free&amp;nbsp;memory&lt;br /&gt;
Incremental&amp;nbsp;Compaction&lt;br /&gt;
&lt;br /&gt;
HotSpot&amp;nbsp;&amp;nbsp;-&amp;nbsp;ParallelGC&amp;nbsp;&amp;nbsp;(&amp;nbsp;Default&amp;nbsp;Collector&amp;nbsp;)&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&amp;nbsp;Monolithic&amp;nbsp;STW&amp;nbsp;&amp;nbsp;copy&amp;nbsp;NewGen&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Monolithic&amp;nbsp;STW&amp;nbsp;Mark/Sweep/Compact&amp;nbsp;OldGen&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
HotSpot&amp;nbsp;&amp;nbsp;-&amp;nbsp;CocMarkSweepGC&amp;nbsp;(&amp;nbsp;aka&amp;nbsp;CMS&amp;nbsp;)&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&amp;nbsp; Monolithic&amp;nbsp;STW&amp;nbsp;copy&amp;nbsp;NewGen&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(&amp;nbsp;ParNew&amp;nbsp;)&lt;/li&gt;
&lt;li&gt;&amp;nbsp; Mostly&amp;nbsp;Concurrent&amp;nbsp;,&amp;nbsp;non-Compacting&amp;nbsp;&amp;nbsp;OldGen&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Fallback&amp;nbsp;to&amp;nbsp;Full&amp;nbsp;Collection&amp;nbsp;(&amp;nbsp;Monolithic&amp;nbsp;&amp;nbsp;STW&amp;nbsp;)&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
HotSpot&amp;nbsp;G1GC&amp;nbsp;(&amp;nbsp;aka&amp;nbsp;&quot;Garbage&amp;nbsp;First&quot;)&lt;br /&gt;
&lt;br /&gt;
&lt;ul style=&quot;text-align: left;&quot;&gt;
&lt;li&gt;&amp;nbsp;Monolithic&amp;nbsp;STW&amp;nbsp;copying&amp;nbsp;NewGen&lt;/li&gt;
&lt;li&gt;&amp;nbsp;Mostly&amp;nbsp;Concurrent,OldGen&amp;nbsp;marker&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&amp;nbsp;STW&amp;nbsp;mostly&amp;nbsp;incremental&amp;nbsp;compacting&amp;nbsp;olden&lt;br /&gt;
&amp;nbsp;Fallback&amp;nbsp;to&amp;nbsp;Full&amp;nbsp;Collections&lt;br /&gt;
&lt;br /&gt;
When there is a &quot;Application&amp;nbsp;Memory&amp;nbsp;Wall&quot; phenomenon its important to look at GC and Tuning&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/6386377840079526531/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/6386377840079526531' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/6386377840079526531'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/6386377840079526531'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/10/garbage-collection-mechanisms-and.html' title='Garbage Collection Mechanisms and Collectors'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-590497349526500605</id><published>2013-10-02T16:10:00.002-07:00</published><updated>2013-11-19T15:40:48.731-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="json to object"/><category scheme="http://www.blogger.com/atom/ns#" term="json to object utility"/><category scheme="http://www.blogger.com/atom/ns#" term="json to pojo"/><title type='text'>JSON String to Object transformer</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;link href=&#39;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&#39; rel=&#39;stylesheet&#39; type=&#39;text/css&#39;/&gt;
&lt;link href=&#39;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&#39; rel=&#39;stylesheet&#39; type=&#39;text/css&#39;/&gt;

&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Consider you have a Simple Json with two values ( lable and value ) &amp;nbsp;to read  and these have to map to the POJO Class - ContentType .&lt;br /&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;JSON Data
&lt;/h3&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;[

    {
        &quot;label&quot;: &quot;Movies&quot;,
        &quot;value&quot;: &quot;movie&quot;
    },
    {
        &quot;label&quot;: &quot;TV Shows&quot;,
        &quot;value&quot;: &quot;tvshow&quot;
    }

]
&lt;/pre&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&lt;br /&gt;POJO&lt;/h3&gt;
&lt;pre class=&quot;brush:java&quot;&gt;public class ContentType {
 
 
 private String label;
 private String value;

 public String getLabel() {
  return label;
 }
 public void setLabel(String label) {
  this.label = label;
 }
 public String getValue() {
  return value;
 }
 public void setValue(String value) {
  this.value = value;
 }

}
&lt;/pre&gt;
&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
Jackson ObjectMapper for Reading&lt;/h3&gt;
&lt;div&gt;
It can be reaad by using the Jackson mapper , as shown below . reply - has the POJO string shown above&lt;/div&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;ObjectMapper mapper = new ObjectMapper();   
List&amp;lt;contenttype&amp;gt; ctl = mapper.readValue(reply, List.class);

&lt;/pre&gt;
Package : org.codehaus.jackson.map&lt;br /&gt;
&lt;br /&gt;
Library can be included in the project by using the following in the pom.xml or just get the latest from&amp;nbsp;&lt;a href=&quot;http://jackson.codehaus.org/&quot;&gt;http://jackson.codehaus.org/&lt;/a&gt;&lt;br /&gt;
&lt;h3 style=&quot;text-align: left;&quot;&gt;
&amp;nbsp;pom.xml

&lt;/h3&gt;
&lt;pre class=&quot;brush:xml&quot;&gt; 
    &amp;lt;dependency&amp;gt;
      &amp;lt;groupid&amp;gt;org.codehaus.jackson&amp;lt;/groupid&amp;gt;
      &amp;lt;artifactid&amp;gt;jackson-mapper-asl&amp;lt;/artifactid&amp;gt;
      &amp;lt;version&amp;gt;1.9.13&amp;lt;/version&amp;gt;
    &amp;lt;/dependency&amp;gt;
    
    &amp;lt;dependency&amp;gt;
      &amp;lt;groupid&amp;gt;org.codehaus.jackson&amp;lt;/groupid&amp;gt;
      &amp;lt;artifactid&amp;gt;jackson-core-asl&amp;lt;/artifactid&amp;gt;
      &amp;lt;version&amp;gt;1.9.13&amp;lt;/version&amp;gt;
    &amp;lt;/dependency&amp;gt;&amp;nbsp;
&lt;/pre&gt;
Using Generics you can have a utility to parse data in JSON and get String data from POJO  

&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt; 
package util;
&lt;br/&gt;import java.util.ArrayList;&lt;br/&gt;import java.util.HashMap;&lt;br/&gt;&lt;br/&gt;import org.codehaus.jackson.map.ObjectMapper;&lt;br/&gt;import org.codehaus.jackson.map.type.TypeFactory;&lt;br/&gt;import org.codehaus.jackson.map.DeserializationConfig;&lt;br/&gt;&lt;br/&gt;public class JsonStringConverter {&lt;br/&gt;  &lt;br/&gt; public static final &amp;lt;E&amp;gt; String getAsJSON(E inClass) throws Exception {&lt;br/&gt;     ObjectMapper mapper = new ObjectMapper();&lt;br/&gt;     return mapper.writeValueAsString(inClass) ; &lt;br/&gt; }&lt;br/&gt; &lt;br/&gt; public  static final &amp;lt;E&amp;gt; E parseAsInputClassForArrayList(String json,Class outClass) throws Exception {&lt;br/&gt;  ObjectMapper mapper = new ObjectMapper();&lt;br/&gt;  TypeFactory t = TypeFactory.defaultInstance();&lt;br/&gt;  mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);&lt;br/&gt;     return (E) mapper.readValue(json,t.constructCollectionType(ArrayList.class,outClass));  &lt;br/&gt; }&lt;br/&gt; &lt;br/&gt; public  static final &amp;lt;E&amp;gt; E parseAsInputClassForSimpleClass(String json,Class outClass) throws Exception {&lt;br/&gt;  ObjectMapper mapper = new ObjectMapper();&lt;br/&gt;     return (E) mapper.readValue(json,outClass);  &lt;br/&gt; }&lt;br/&gt; &lt;br/&gt; public  static final &amp;lt;E&amp;gt; E parseAsInputClassForHashMap(String json,Class key,Class outClass) throws Exception {&lt;br/&gt;  ObjectMapper mapper = new ObjectMapper();&lt;br/&gt;  TypeFactory t = TypeFactory.defaultInstance();&lt;br/&gt;  mapper.configure(DeserializationConfig.Feature.ACCEPT_SINGLE_VALUE_AS_ARRAY, true);&lt;br/&gt;     return (E) mapper.readValue(json,t.constructMapType(HashMap.class,key,outClass));  &lt;br/&gt; }&lt;br/&gt; &lt;br/&gt;}
&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/590497349526500605/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/590497349526500605' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/590497349526500605'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/590497349526500605'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/10/json-string-to-object-transformer.html' title='JSON String to Object transformer'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-2118351852321765773</id><published>2013-10-02T12:34:00.004-07:00</published><updated>2013-10-02T12:34:55.252-07:00</updated><title type='text'>Force Stop server using Script</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
You have scripts to stop / start servers and sometimes due to memory leak or other reasons the server just doesn&#39;t shutdown . &amp;nbsp;Script doesn&#39;t work because of this.&lt;br /&gt;
&lt;br /&gt;
Work around ? , is to kill the process . &amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
for tomcat&lt;br /&gt;
&lt;br /&gt;
ps xu | grep &#39;tomcat&#39; | grep -v grep | awk &#39;{ print $2 }&#39; | xargs kill -9&lt;br /&gt;
&lt;br /&gt;
for jboss , you can use &#39;Standalone&#39; keyword if you are using jboss7 or try to find the unique name from the process description&lt;br /&gt;
&lt;br /&gt;
ps xu | grep &#39;Standalone&#39; | grep -v grep | awk &#39;{ print $2 }&#39; | xargs kill -9&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/2118351852321765773/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/2118351852321765773' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/2118351852321765773'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/2118351852321765773'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/10/force-stop-server-using-script.html' title='Force Stop server using Script'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-8499492252681185865</id><published>2013-10-02T12:20:00.002-07:00</published><updated>2013-10-02T16:19:03.260-07:00</updated><title type='text'>Memcached debugging using telnet</title><content type='html'>&lt;link href=&#39;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&#39; rel=&#39;stylesheet&#39; type=&#39;text/css&#39;/&gt;
&lt;link href=&#39;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&#39; rel=&#39;stylesheet&#39; type=&#39;text/css&#39;/&gt;

&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;

&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;h2 style=&quot;text-align: left;&quot;&gt;
Telnet for Memcached
&lt;/h2&gt;
&lt;div&gt;
You can use telnet for doing some debugging for Memcache .&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Connect using telnet , port is usually 11211&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;telnet {memcachehost} &amp;nbsp;11211
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
commands&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
general &amp;nbsp;purpose to find version , memory etc&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;stats
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Remove everything&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;flush_all
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Keys - there is no way to list all the keys&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
get the stats items using&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;stats items
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
request cache dump of each slab id with limit&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;stats cachedump 3 10
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
3 refers to the slab id&lt;/div&gt;
&lt;div&gt;
10 &amp;nbsp;limit&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
exit&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;quit
&lt;/pre&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/8499492252681185865/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/8499492252681185865' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/8499492252681185865'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/8499492252681185865'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/10/memcached-debugging-using-telnet.html' title='Memcached debugging using telnet'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-1435609265617036334</id><published>2013-09-24T20:29:00.002-07:00</published><updated>2013-09-25T15:04:14.322-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="clear solr"/><category scheme="http://www.blogger.com/atom/ns#" term="delete everything from solr"/><category scheme="http://www.blogger.com/atom/ns#" term="delete solr data"/><title type='text'>Delete/Clear Solr</title><content type='html'>&lt;link href=&#39;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&#39; rel=&#39;stylesheet&#39; type=&#39;text/css&#39;/&gt;
&lt;link href=&#39;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&#39; rel=&#39;stylesheet&#39; type=&#39;text/css&#39;/&gt;

&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;


&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Here is the simple shell script I use for clearning everything from Solr .&lt;br /&gt;

&lt;pre class=&quot;brush:xml&quot;&gt;
!/bin/sh&lt;br/&gt;URL=&amp;quot;http://user:password@host:portnum/solr.master/core/update&amp;quot;&lt;br/&gt;DATA=&amp;quot;&amp;lt;delete&amp;gt;&amp;lt;query&amp;gt;*:*&amp;lt;/query&amp;gt;&amp;lt;/delete&amp;gt;&amp;quot;&lt;br/&gt;echo&amp;nbsp;Posting&amp;nbsp;&amp;quot;\&amp;quot;$DATA\&amp;quot;&amp;quot;&amp;nbsp;to&amp;nbsp;&amp;quot;\&amp;quot;$URL\&amp;quot;&amp;quot;&amp;nbsp;with&amp;nbsp;commit=true&lt;br/&gt;curl&amp;nbsp;$URL?commit=true&amp;nbsp;-H&amp;nbsp;&amp;quot;Content-Type:&amp;nbsp;text/xml&amp;quot;&amp;nbsp;--data-binary&amp;nbsp;$DATA&lt;br/&gt;echo&amp;nbsp;Complete
&lt;br /&gt;&lt;/div&gt;
&lt;/pre&gt;</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/1435609265617036334/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/1435609265617036334' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/1435609265617036334'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/1435609265617036334'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/09/delete-everything-from-solr.html' title='Delete/Clear Solr'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-4867369262649915025</id><published>2013-08-23T16:19:00.001-07:00</published><updated>2013-10-29T10:18:53.040-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="call webservice"/><category scheme="http://www.blogger.com/atom/ns#" term="example"/><category scheme="http://www.blogger.com/atom/ns#" term="jax-ws"/><category scheme="http://www.blogger.com/atom/ns#" term="jaxws"/><category scheme="http://www.blogger.com/atom/ns#" term="maven"/><category scheme="http://www.blogger.com/atom/ns#" term="setup"/><title type='text'>JAX-WS Call WS using Maven</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;

&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;

Use Maven to Generate all Stubs using &quot;wsimport&quot; utility . After generating the webservice you can call the service using Java class. This method will can be easily reused , you just have to use different wsdl url every time you have to consume the webservice and modify the java code , it&#39;s light weight and no need to use any third party libraries .  So you will need the following

&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;
wsdl file
&lt;/li&gt;
&lt;li&gt;
pom.xml
&lt;/li&gt;
&lt;li&gt; 
Java Class 
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
First step is to copy the wsdl file and place it in the src/wsdl directory
&lt;br /&gt;
Setup the pom.xml
pom.xml &lt;br /&gt;
&lt;i&gt;Folder : Project root dir&lt;/i&gt;

&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;project&amp;nbsp;xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;&amp;nbsp;xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
 xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0&amp;nbsp;http://maven.apache.org/maven-v4_0_0.xsd&quot;&amp;gt;
 &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;
 &amp;lt;groupId&amp;gt;com.myws.testconsumews&amp;lt;/groupId&amp;gt;
 &amp;lt;artifactId&amp;gt;TestWSConsume&amp;lt;/artifactId&amp;gt;
 &amp;lt;packaging&amp;gt;war&amp;lt;/packaging&amp;gt;
 &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;

 &amp;lt;name&amp;gt;Test&amp;nbsp;Webservice&amp;lt;/name&amp;gt;
 &amp;lt;url&amp;gt;http://maven.apache.org&amp;lt;/url&amp;gt;
 
 
 &amp;lt;build&amp;gt;
  
  &amp;lt;plugins&amp;gt;
   
   &amp;lt;plugin&amp;gt;
    &amp;lt;groupId&amp;gt;org.codehaus.mojo&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;jaxws-maven-plugin&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;1.7&amp;lt;/version&amp;gt;
    &amp;lt;executions&amp;gt;
     
     &amp;nbsp;&amp;lt;execution&amp;gt;
      &amp;lt;id&amp;gt;generate-stubs&amp;lt;/id&amp;gt;
      &amp;lt;phase&amp;gt;generate-sources&amp;lt;/phase&amp;gt;
      &amp;lt;goals&amp;gt;
       &amp;lt;goal&amp;gt;wsimport&amp;lt;/goal&amp;gt;
      &amp;lt;/goals&amp;gt;
      &amp;lt;configuration&amp;gt;
       &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;wsdlDirectory&amp;gt;src/wsdl&amp;lt;/wsdlDirectory&amp;gt;
       &amp;lt;wsdlFiles&amp;gt;
        &amp;lt;wsdlFile&amp;gt;myservice.wsdl&amp;lt;/wsdlFile&amp;gt;
       &amp;lt;/wsdlFiles&amp;gt;
       &amp;lt;wsdlLocation&amp;gt;http://localhost:8080/TestWS/myservice?wsdl&amp;lt;/wsdlLocation&amp;gt;
      &amp;nbsp; &amp;lt;sourceDestDir&amp;gt;src/main/java&amp;lt;/sourceDestDir&amp;gt;
  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;packageName&amp;gt;com.myservice.proxy&amp;lt;/packageName&amp;gt;
  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/configuration&amp;gt;
      &amp;nbsp;
     &amp;lt;/execution&amp;gt;&amp;nbsp;
    &amp;lt;/executions&amp;gt;
   &amp;lt;/plugin&amp;gt;
   &amp;lt;plugin&amp;gt;
    &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;maven-war-plugin&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;2.2&amp;lt;/version&amp;gt;
    &amp;nbsp;&amp;lt;configuration&amp;gt;
     &amp;lt;failOnMissingWebXml&amp;gt;false&amp;lt;/failOnMissingWebXml&amp;gt;
    &amp;lt;/configuration&amp;gt;
   &amp;lt;/plugin&amp;gt;

  &amp;lt;/plugins&amp;gt;
 &amp;lt;/build&amp;gt;
&amp;lt;/project&amp;gt;

&lt;/pre&gt;
&lt;br /&gt;
run &quot;mvn generate-sources&quot; command , this will generate the files in src/main/java folder . Its specified as &amp;lt;sourceDestDir&amp;gt;src/main/java&amp;lt;/sourceDestDir&amp;gt; in pom.xml
&lt;br /&gt;
Stubs are generated ,You can call the webservice with following Java program

&lt;pre class=&quot;brush:java&quot;&gt;package com.myservice.client;

import com.myservice.proxy.MyService;
import com.myservice.proxy.MyServiceService;

public class CallMyService {
 
 
 
 public static void main(String[] args) {
  MyServiceService mss = new MyServiceService();
  MyService serv = mss.getMyServicePort();
   
     System.out.println(serv.sayHello());
 }
 
 
  
}

&lt;/pre&gt;
Now that was simple right . So what if you want to generate numerous webservice clients for testing and scripting needs you can simply reuse the pom.xml ( change the wsdl file ) , generate the stubs  and change the program to call the new webservice . 
&lt;br /&gt;
Note
&lt;br /&gt;
If your webservice requires  authentication , you can set that up as shown below

&lt;pre class=&quot;brush:java&quot;&gt;     ((BindingProvider) serv).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, userName);
      ((BindingProvider) serv).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, passWord);
          
&lt;/pre&gt;
Cheers, hope that was helpful
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/4867369262649915025/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/4867369262649915025' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/4867369262649915025'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/4867369262649915025'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/08/jax-ws-call-ws-using-maven.html' title='JAX-WS Call WS using Maven'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-8384263767178776803</id><published>2013-08-22T15:44:00.001-07:00</published><updated>2013-10-29T10:20:08.644-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="example"/><category scheme="http://www.blogger.com/atom/ns#" term="jax-ws"/><category scheme="http://www.blogger.com/atom/ns#" term="jax-ws create webservice"/><category scheme="http://www.blogger.com/atom/ns#" term="jaxws"/><category scheme="http://www.blogger.com/atom/ns#" term="maven"/><category scheme="http://www.blogger.com/atom/ns#" term="setup"/><category scheme="http://www.blogger.com/atom/ns#" term="tomcat"/><title type='text'>JAX-WS Create WS using Maven</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;

&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;

Article describes setting up JAX-WS using Maven and various ways to deploy the webservice . Creating WS using JAX-WS is super simple , simply annotate the class  with @WebService and its basically done. Simpicity is good not only for development but also creating mock services and testing error cases.

Maven makes it   more reusable be able to  distibute easily to developers. Also maven takes care of wsgen and  dependent libraries.

I use Tomcat 7 and running Java 6 . If you are using Java7  , wsgen fails ( yeah it has to be fixed)  , so till then configure the IDE to use Java6 for the project
&amp;nbsp;&amp;nbsp;
&lt;br /&gt;
Java Code - Your WebService ( Simple .. basically you can return POJO or collection of objects for practical use case)
&lt;br /&gt;&lt;i&gt;folder - src/main/java&lt;/i&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;package com.services;

import javax.jws.WebMethod;
import javax.jws.WebService;
@WebService

public class MyService {

 @WebMethod
 public String sayHello()
 {
  return &quot;Hello World&quot;;
 }
}

&lt;/pre&gt;
Pom.xml&lt;br /&gt;
&lt;i&gt;folder - project folder&lt;/i&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;project&amp;nbsp;xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;&amp;nbsp;xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;
 xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0&amp;nbsp;http://maven.apache.org/maven-v4_0_0.xsd&quot;&amp;gt;
 &amp;lt;modelVersion&amp;gt;4.0.0&amp;lt;/modelVersion&amp;gt;
 &amp;lt;groupId&amp;gt;com.myws.testws&amp;lt;/groupId&amp;gt;
 &amp;lt;artifactId&amp;gt;TestWS&amp;lt;/artifactId&amp;gt;
 &amp;lt;packaging&amp;gt;war&amp;lt;/packaging&amp;gt;
 &amp;lt;version&amp;gt;1.0-SNAPSHOT&amp;lt;/version&amp;gt;

 &amp;lt;name&amp;gt;Test&amp;nbsp;Webservice&amp;lt;/name&amp;gt;
 &amp;lt;url&amp;gt;http://maven.apache.org&amp;lt;/url&amp;gt;
 
 &amp;lt;dependencies&amp;gt;
 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;dependency&amp;gt;
  &amp;lt;groupId&amp;gt;com.sun.xml.ws&amp;lt;/groupId&amp;gt;
  &amp;lt;artifactId&amp;gt;jaxws-rt&amp;lt;/artifactId&amp;gt;
  &amp;lt;version&amp;gt;2.1.3&amp;lt;/version&amp;gt;
  &amp;lt;/dependency&amp;gt;
 &amp;lt;/dependencies&amp;gt;

 &amp;lt;build&amp;gt;
  
  &amp;lt;plugins&amp;gt;
   &amp;lt;plugin&amp;gt;
    &amp;lt;groupId&amp;gt;org.apache.maven.plugins&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;maven-war-plugin&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;2.2&amp;lt;/version&amp;gt;
    &amp;nbsp;&amp;lt;configuration&amp;gt;
     &amp;lt;failOnMissingWebXml&amp;gt;false&amp;lt;/failOnMissingWebXml&amp;gt;
    &amp;lt;/configuration&amp;gt;
   &amp;lt;/plugin&amp;gt;
   &amp;lt;plugin&amp;gt;
    &amp;lt;groupId&amp;gt;org.codehaus.mojo&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;jaxws-maven-plugin&amp;lt;/artifactId&amp;gt;
    &amp;lt;version&amp;gt;1.7&amp;lt;/version&amp;gt;
    &amp;lt;executions&amp;gt;
     &amp;lt;execution&amp;gt;
      &amp;lt;id&amp;gt;generate-wsdl&amp;lt;/id&amp;gt;
      &amp;lt;phase&amp;gt;process-classes&amp;lt;/phase&amp;gt;
      &amp;lt;goals&amp;gt;
       &amp;lt;goal&amp;gt;wsgen&amp;lt;/goal&amp;gt;
      &amp;lt;/goals&amp;gt;
      &amp;lt;configuration&amp;gt;
       &amp;lt;sei&amp;gt;com.services.MyService&amp;lt;/sei&amp;gt;
       &amp;lt;genWsdl&amp;gt;true&amp;lt;/genWsdl&amp;gt;
      &amp;lt;/configuration&amp;gt;
     &amp;lt;/execution&amp;gt;
    
    &amp;lt;/executions&amp;gt;
   &amp;lt;/plugin&amp;gt;

   
  &amp;lt;/plugins&amp;gt;
 &amp;lt;/build&amp;gt;
&amp;lt;/project&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;b&gt;Running it using EndPoint&lt;/b&gt;&lt;br /&gt;
Using Endpoint just use the publisher and  WebService is running .

&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;package com.services;

import javax.xml.ws.Endpoint;
 

public class MyServicePublisher{
 
 public static void main(String[] args) {
    Endpoint.publish(&quot;http://localhost:8888/TestWS/MyService&quot;, new MyService());
    }
 
}
&lt;/pre&gt;
&lt;br /&gt;
test service : http://localhost:888/TestWS/MyService?wsdl
&lt;br /&gt;
&lt;b&gt;Running it in Tomcat.&lt;/b&gt;&lt;br /&gt;
My preferred method is to run it in tomcat . You will need couple of more files

&lt;br /&gt;
web.xml&lt;br /&gt;
folder :src/webapp/WEB-INF
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;?xml&amp;nbsp;version=&quot;1.0&quot;&amp;nbsp;encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;!DOCTYPE&amp;nbsp;web-app&amp;nbsp;PUBLIC&amp;nbsp;&quot;-//Sun&amp;nbsp;Microsystems,&amp;nbsp;
Inc.//DTD&amp;nbsp;Web&amp;nbsp;Application&amp;nbsp;2.3//EN&quot;
&quot;http://java.sun.com/j2ee/dtds/web-app_2_3.dtd&quot;&amp;gt;
&amp;nbsp;
&amp;lt;web-app&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;listener&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;listener-class&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;com.sun.xml.ws.transport.http.servlet.WSServletContextListener
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/listener-class&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/listener&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;servlet&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;servlet-name&amp;gt;myservice&amp;lt;/servlet-name&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;servlet-class&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; com.sun.xml.ws.transport.http.servlet.WSServlet
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/servlet-class&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;load-on-startup&amp;gt;1&amp;lt;/load-on-startup&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/servlet&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;servlet-mapping&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;servlet-name&amp;gt;myservice&amp;lt;/servlet-name&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;url-pattern&amp;gt;/myservice&amp;lt;/url-pattern&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/servlet-mapping&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;session-config&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;session-timeout&amp;gt;120&amp;lt;/session-timeout&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;lt;/session-config&amp;gt;
&amp;lt;/web-app&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
sun-jaxws.xml&lt;br /&gt;
folder :src/webapp/WEB-INF
&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;?xml&amp;nbsp;version=&quot;1.0&quot;&amp;nbsp;encoding=&quot;UTF-8&quot;?&amp;gt;
&amp;lt;endpoints
&amp;nbsp;&amp;nbsp;xmlns=&quot;http://java.sun.com/xml/ns/jax-ws/ri/runtime&quot;
&amp;nbsp;&amp;nbsp;version=&quot;2.0&quot;&amp;gt;
&amp;nbsp;&amp;nbsp;&amp;lt;endpoint
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;name=&quot;MyService&quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;implementation=&quot;com.services.MyService&quot;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;url-pattern=&quot;/myservice&quot;/&amp;gt;
&amp;lt;/endpoints&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
Deploy the war file to tomcat 
&lt;br /&gt;
test deployment : http://localhost:8080/TestWS/myservice?wsdl&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/8384263767178776803/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/8384263767178776803' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/8384263767178776803'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/8384263767178776803'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/08/jax-ws-create-ws-using-maven.html' title='JAX-WS Create WS using Maven'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-2282977976386440059</id><published>2013-08-10T22:34:00.002-07:00</published><updated>2015-01-30T16:07:50.977-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="example"/><category scheme="http://www.blogger.com/atom/ns#" term="integration"/><category scheme="http://www.blogger.com/atom/ns#" term="mongo"/><category scheme="http://www.blogger.com/atom/ns#" term="setup"/><category scheme="http://www.blogger.com/atom/ns#" term="spring"/><title type='text'>Spring Mongo Integration</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;

&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;
Setting up and using MongoDB in the Spring application is a simple two step process.Specify the  Mongo template in the application configuration , then customize the ApplicationConfig . 

Step 1
Include the Mongo configuration in the application context

&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&lt;/pre&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&amp;lt;mongo:db-factory id=&quot;mongoDbFactory&quot; dbname=&quot;my-store&quot; /&amp;gt;
 
 &amp;lt;mongo:mapping-converter id=&quot;mongoConverter&quot; base-package=&quot;springdata.mongodb&quot;&amp;gt;
  &amp;lt;mongo:custom-converters base-package=&quot;springdata.mongodb&quot; /&amp;gt;
 &amp;lt;/mongo:mapping-converter&amp;gt;
 
 &amp;lt;bean id=&quot;mongoTemplate&quot; class=&quot;org.springframework.data.mongodb.core.MongoTemplate&quot;&amp;gt;
  &amp;lt;constructor-arg ref=&quot;mongoDbFactory&quot; /&amp;gt;
  &amp;lt;constructor-arg ref=&quot;mongoConverter&quot; /&amp;gt;
  &amp;lt;property name=&quot;writeConcern&quot; value=&quot;SAFE&quot; /&amp;gt;
 &amp;lt;/bean&amp;gt;
 
 &amp;lt;mongo:repositories base-package=&quot;springdata.mongodb&quot; /&amp;gt;
&lt;/pre&gt;
Step2
Setup the ApplicationConfig in the base-package 
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;@ComponentScan
@EnableMongoRepositories
class ApplicationConfig extends AbstractMongoConfiguration {

 
 @Override
 protected String getDatabaseName() {
 return &quot;my-store&quot;;
 
 }

 
 @Override
 public Mongo mongo() throws Exception {

  Mongo mongo = new Mongo();
  mongo.setWriteConcern(WriteConcern.SAFE);

  return mongo;
 }

}
&lt;/pre&gt;
After the two steps the Mongo can be included in the application by simply autowiring 

&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;@Autowired Mongo mongo;
&lt;/pre&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/2282977976386440059/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/2282977976386440059' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/2282977976386440059'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/2282977976386440059'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/08/spring-mongo-integration.html' title='Spring Mongo Integration'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-8623391314232656777</id><published>2013-08-10T18:51:00.002-07:00</published><updated>2017-11-22T13:36:51.473-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="spring REST integration"/><title type='text'>Spring Integration to Consume and Publish REST</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;
&lt;link href=&quot;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;&gt;&lt;/link&gt;

&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script src=&quot;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;

&lt;br /&gt;
&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Spring Integration using gateways makes it possible to consume services from multiple sources and expose them as api&#39;s . API&#39;s can be exposed with or without further processing . &amp;nbsp;Lets look at an example without Processing .&lt;br /&gt;
&lt;br /&gt;
If you need a code ref you can find it here &lt;a href=&quot;https://github.com/arun2dot0/spring-integration-example&quot;&gt;https://github.com/arun2dot0/spring-integration-example&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
getFoo is a Restful service &amp;nbsp;consumed by Spring and exposes back as service .&lt;br /&gt;
First thing to define is the publish-subscribe-channel ,then configure the input-channel with all the mappings .Example shows the method &amp;nbsp;getFoo but there can be many mappings added for each of the service .&lt;br /&gt;
&lt;br /&gt;
Next step is to specify the gateway to accept the incoming request to the channel . Service interface with the list of interface methods is specified .&lt;br /&gt;
&lt;br /&gt;
Finally the http-oubound gateway is defined with the url , http-method with the transformer.&lt;br /&gt;
Transformer can be easily implemented by json-to-object trasnfromation as show. &lt;br /&gt;
&lt;br /&gt;
Update :&lt;br /&gt;
It can be done using Java DSL as well and you can find the implementation here&lt;br /&gt;
&lt;a href=&quot;https://github.com/arun2dot0/spring-integration-example-dsl&quot;&gt;https://github.com/arun2dot0/spring-integration-example-dsl&lt;/a&gt;&lt;br /&gt;
DSL uses newer version of spring integration and http library .&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Spring Configuration&lt;br /&gt;
&lt;pre class=&quot;brush:xml;&quot;&gt;&amp;lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&amp;gt;  
&amp;lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;  
 xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:p=&quot;http://www.springframework.org/schema/p&quot;  
 xmlns:int=&quot;http://www.springframework.org/schema/integration&quot;  
 xmlns:http=&quot;http://www.springframework.org/schema/integration/http&quot;
 xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans   
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd  
 http://www.springframework.org/schema/integration/http http://www.springframework.org/schema/integration/http/spring-integration-http-2.1.xsd 
http://www.springframework.org/schema/integration   
http://www.springframework.org/schema/integration/spring-integration-2.1.xsd&quot;&amp;gt;  
  
&amp;lt;!-- Channel for incoming request--&amp;gt;
&amp;lt;int:publish-subscribe-channel id=&quot;pubsubChannel&quot;&amp;gt;&amp;lt;/int:publish-subscribe-channel&amp;gt;
 
 &amp;lt;!-- Define header with all the necessary mapping--&amp;gt; 
&amp;lt;int:header-value-router input-channel=&quot;pubsubChannel&quot; header-name=&quot;REQUEST_TYPE&quot;&amp;gt;
 &amp;lt;int:mapping value=&quot;getFoo&quot; channel=&quot;getFooChannel&quot;/&amp;gt;
&amp;lt;/int:header-value-router&amp;gt; 

&amp;lt;int:channel id=&quot;getFooChannel&quot;/&amp;gt;

&amp;lt;!-- Simple facade method which accepts messages into channel --&amp;gt;
&amp;lt;int:gateway  id=&quot;firstGatewayID&quot; service-interface=&quot;services.api.FirstGatewayService&quot;     default-request-channel=&quot;pubsubChannel&quot; &amp;gt;
  &amp;lt;!--Provide method in the gateway --&amp;gt;
 &amp;lt;int:method name=&quot;getFoo&quot;&amp;gt;
   &amp;lt;int:header name=&quot;REQUEST_TYPE&quot; value=&quot;getFoo&quot;/&amp;gt;
  &amp;lt;/int:method&amp;gt;
&amp;lt;/int:gateway&amp;gt;  


 &amp;lt;!--outbound gateway to get data from url--&amp;gt;
&amp;lt;http:outbound-gateway id=&quot;getFooGateway&quot; 
                   url=&quot;http://somehost.com/GetFoo&quot; 
                request-channel=&quot;getFooChannel&quot; 
                reply-channel=&quot;getFooChannel_response&quot;
                http-method=&quot;GET&quot; 
                expected-response-type=&quot;java.lang.String&quot;&amp;gt;
 &amp;lt;/http:outbound-gateway&amp;gt;
 
 &amp;lt;int:json-to-object-transformer input-channel=&quot;getFooChannel_response&quot; type=&quot;model.FooResponse&quot;/&amp;gt;  
&amp;lt;/beans&amp;gt;&lt;/pre&gt;
&lt;br /&gt;
Java Code&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;Gateway Service
&lt;/i&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;package services.api;
import org.springframework.integration.annotation.Header;
import org.springframework.integration.annotation.Payload;
public interface FirstGatewayService {
 @Payload(&quot;new java.util.Date()&quot;)
 public FooResponse getFoo();
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;i&gt;Response
&lt;/i&gt;&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;package model;
import org.codehaus.jackson.annotate.JsonProperty;
public class FooResponse {
 @JsonProperty(&quot;status&quot;)
 boolean status;
 @JsonProperty(&quot;data&quot;)
 String data;
 public boolean isStatus() {
  return status;
 }
 public void setStatus(boolean status) {
  this.status = status;
 }
 public String getData() {
  return data;
 }
 public void setData(String data) {
  this.data = data;
 }
}
&lt;/pre&gt;
&lt;i&gt;Controller&lt;/i&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;@Autowired
private FirstGatewayService gatewayService;
@Override
 @RequestMapping(value&amp;nbsp;=&amp;nbsp;&amp;lt;url&amp;nbsp;to&amp;nbsp;access&amp;gt;,&amp;nbsp;method&amp;nbsp;=&amp;nbsp;RequestMethod.GET)
 public&amp;nbsp;@ResponseBody&amp;nbsp;BaseResponse&amp;nbsp;getFoo()&amp;nbsp;{
  return&amp;nbsp;gatewayService.getFoo();
 }
&lt;/pre&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/8623391314232656777/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/8623391314232656777' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/8623391314232656777'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/8623391314232656777'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2013/08/spring-integration-to-consume-and.html' title='Spring Integration to Consume and Publish REST'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-650876660236490287.post-7711799813078719387</id><published>2010-08-12T16:17:00.000-07:00</published><updated>2013-08-10T19:11:26.011-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="attach images to email"/><category scheme="http://www.blogger.com/atom/ns#" term="email embedding images"/><category scheme="http://www.blogger.com/atom/ns#" term="images email"/><category scheme="http://www.blogger.com/atom/ns#" term="images in email"/><title type='text'>Embedding images in E-Mail</title><content type='html'>&lt;link href=&#39;http://alexgorbatchev.com/pub/sh/current/styles/shCore.css&#39; rel=&#39;stylesheet&#39; type=&#39;text/css&#39;/&gt;
&lt;link href=&#39;http://alexgorbatchev.com/pub/sh/current/styles/shThemeEclipse.css&#39; rel=&#39;stylesheet&#39; type=&#39;text/css&#39;/&gt;

&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushJava.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script src=&#39;http://alexgorbatchev.com/pub/sh/current/scripts/shBrushXml.js&#39; type=&#39;text/javascript&#39;&gt;&lt;/script&gt;
&lt;script&gt;
SyntaxHighlighter.config.bloggerMode = true;
SyntaxHighlighter.all();
&lt;/script&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;style type=&quot;text/css&quot;&gt;
        @import &quot;http://ajax.googleapis.com/ajax/libs/dojo/1.4/dijit/themes/soria/soria.css&quot;;
        @import &quot;http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/resources/dojo.css&quot;;
    
&lt;/style&gt;&lt;br /&gt;
&lt;br /&gt;
We have been using XML XSL transformation for generating the emails and it was working well . XML Provides the data and Styling is provided in XSL . It becomes tricky when including images . One easy way to do is to include images as URL . This may not be the right approach as the user may not be online when looking a the email and can be lost during forwarding . &lt;br /&gt;
&lt;br /&gt;
Best way  is to use javax.mail.internet.MimeMultipart and set the images as header . &lt;br /&gt;
Here is the example &lt;br /&gt;
XSL to include images will look like this&lt;br /&gt;
&lt;pre class=&quot;brush:xml&quot;&gt;&lt;br /&gt;
&amp;lt;img&amp;gt;&lt;br /&gt;
&amp;lt;xsl:attribute name=&quot;src&quot;&amp;gt;cid:image1&amp;lt;/xsl:attribute&amp;gt;&lt;br /&gt;
&amp;lt;xsl:attribute name=&quot;border&quot;&amp;gt;0&amp;lt;/xsl:attribute&amp;gt;&lt;br /&gt;
&amp;lt;/img&amp;gt;&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Include the images in the email service after the transformation&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;brush:java&quot;&gt;&lt;br /&gt;
MimeMultipart multipart = new MimeMultipart();&lt;br /&gt;
BodyPart messageBodyPart = new MimeBodyPart();&lt;br /&gt;
&lt;br /&gt;
messageBodyPart.setContent(&quot;All Email contents from Transformation&quot;, &quot;text/html&quot;);&lt;br /&gt;
multipart.addBodyPart(messageBodyPart);&lt;br /&gt;
&lt;br /&gt;
// add first image&lt;br /&gt;
messageBodyPart = new MimeBodyPart();&lt;br /&gt;
DataSource fds = new FileDataSource&lt;br /&gt;
(&quot;C:\\image_path&quot;);&lt;br /&gt;
messageBodyPart.setHeader(&quot;Content-ID&quot;,&quot;&amp;lt;image1&amp;gt;&quot;);&lt;br /&gt;
messageBodyPart.setDataHandler(new DataHandler(fds));&lt;br /&gt;
multipart.addBodyPart(messageBodyPart);&lt;br /&gt;
&lt;br /&gt;
//add another image&lt;br /&gt;
messageBodyPart = new MimeBodyPart();&lt;br /&gt;
DataSource fds1 = new FileDataSource&lt;br /&gt;
(&quot;C:\\image-path&quot;);&lt;br /&gt;
messageBodyPart.setHeader(&quot;Content-ID&quot;,&quot;&amp;lt;image2&amp;gt;&quot;);&lt;br /&gt;
messageBodyPart.setDataHandler(new DataHandler(fds1));&lt;br /&gt;
multipart.addBodyPart(messageBodyPart);&lt;br /&gt;
&lt;br /&gt;
message.setContent(multipart);&lt;br /&gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
You will see the image replaced .Images are downloaded with the message and is replaced where the tag is used . It&#39;s solves all the issues related to using them as URL.</content><link rel='replies' type='application/atom+xml' href='http://ajaxrocks.blogspot.com/feeds/7711799813078719387/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment/fullpage/post/650876660236490287/7711799813078719387' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/7711799813078719387'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/650876660236490287/posts/default/7711799813078719387'/><link rel='alternate' type='text/html' href='http://ajaxrocks.blogspot.com/2010/08/embedding-images-in-e-mail.html' title='Embedding images in E-Mail'/><author><name>Arun Selvamani</name><uri>http://www.blogger.com/profile/06714147942079177451</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='23' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgB3w3Xa7GLEHUrwoOnnrxUDmmRjUr5IoYBnU3krWdTIT9cSvud5vVAIyQjx2D_8iS5_3dOfFM3-BtpsX7ybFnliTh7XCUNtMbTnocO_k51_OMp1WA8fYXOnbeST5_KhRkVOoKL2rSyxkHlwvJLvYAafj_2WaICd5ghyphenhyphengd979jc1ExxNg/s220/profile_small.png'/></author><thr:total>0</thr:total></entry></feed>