Posts

ActiveMQ message producer and consumer with durable subscriber example

Image
When I heard about JMS, it's something like having a message producer, a message broker (you can compare it with message media ) and a message consumer. It is very simple to understand the basic specification of jms. The figure will be explained well. JMS is nothing but a specification. But we have many providers like weblogic jms, ActiveMQ , hornetQ, RabbitMQ and much more. Here I used Apache ActiveMQ . It has many features and you can see it on their official website . Here I want to implement a message producer who produces message topic. And a durable subscriber consumes those messages. Using durable subscriber ensures that each and every message delivered to the consumers. Though a subscriber goes offline, a message stored in activemq context and when it will become online message delivered to the client. Internally it uses KahaDB (a file based persistence database) for message persistence. Now dive into the code. I used maven so here is the maven dependency <

Creating Simple Spring Boot Web Application Using Maven

What is spring-boot ? To answer this, I directly quoted from the official website : Spring Boot makes it easy to create stand-alone, production-grade Spring based Applications that you can "just run". "Just run" refers that it has embedded Tomcat [servlet container] so that we can run the application anywhere  [where installed java] . No need to configure any server.  Before Starting this tutorial we need to ensure that Maven installed properly. [ if not installed then you can follow the tutorial how to install  ] Installed Java properly. You can create a spring-boot project from your favorite IDE (In my case Netbeans 8.0.2) or from the direct web ( http://start.spring.io/ ). Let me describe both. How to Create maven project in Netbeans: Click on File ->new project ->maven (category) -> web application and click next. Give your project a name and click next to select server (tomcat) and then click finish. Open POM xml and <packa

Create Maven Local Repository, Upload your own artifact & download jar from local mirror with Artifactory and Nexus OSS

Image
Maven is nothing but a software project management tool as well as build tool unlike Ant  (Wheres ant is only a build tool). From maven official website Apache Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting, and documentation from a central piece of information. Well, Now we go to direct how to configure a local repo for maven. Here I used   JFrog Artifactory   for repo manager but you can do it with other software like Nexus OSS  and so on. I'll tell you both how to install. Download zip format  [JFrog Artifactory] from here . After download extracts the zip file and it contains everything that you need. It also includes the tomcat. It looks more or less something like that, Now we are going to deploy webapps   artifactory.war and access.war which is in webapps folder. Remember that we need to install java-8(at least ) in our system too. So goto

Spring MVC form submission by ajax don't hitting the given ajax url: ERROR

Recently i experienced a problem regarding posting a form in spring mvc with ajax. i used bootstrap for css design. here i set data by using serialize method.but the form always submitted the url used in form action. <form:form class="" id="horizontalForm" name="horizontalForm" action="enroll.html"> so when i called ajax method it always hits say "enroll.html", not the given ajax url.I tried a lot, but not found any solution. then i found my problem when i clicked submit button. we can design our submit button a lot of ways. by input type submit, <input type="submit" value="Submit" id="submit"/> by input type button <input type="button" id="submit">Submit</input> by using bootstrap button <button type="button" class="btn btn-default">Submit</button> and suppose the ajax method is something like below, $.

ElasticSearch Tutorial : Creating index,updating an index,getting value by index search and delete index operation

Image
What is Elastic search?? Why we need it?? Where Elastic search used?? a lot of question..... huh?? so lets start with minimum answer say "short ans". I also assume that you know about elasticsearch but don't know how to code it in java. ElasticSearch is noting but a full Text search engine with an http web interface. ElasticSearch is developed in java. it also supports distributed operation as well. we need it because it's search like NRT(Near Real Time). that's means search is significantly faster than database. it's schema free. Data store and pull both in json format. High availability and easy to scale. Large and big big system like Github, Facebook, StackOverFlow etc. usages ElasticSearch. Architecture is like it has some cluster. under the cluster it has some nodes, under the nodes it has document (we can say it "Index"). to insert data we need to specify the cluster name as well as node name. then create index, index t

Java RMI (Remote Method Invocation)

Image
Hi, now I am gonna show you how to write java RMI process to create server and client. from oracle documentation "Java Remote Method Invocation (Java RMI) enables the programmer to create distributed Java technology-based to Java technology-based applications, in which the methods of remote Java objects can be invoked from other Java virtual machines*, possibly on different hosts. RMI uses object serialization to marshal and unmarshal parameters and does not truncate types, supporting true object-oriented polymorphism." So from here, we can easily understand that java rmi server can be located in remote or same jvm host. we can call the remote method from a client that can be located different hosts or same from sever. so what is the difference between "Web Service" and "Java RMI" as both are called from remote client and send responses to the client. Well, the difference is "Java RMI" server and client both should be java process that mean

Java Message Service (JMS)

Image
Java message service is pretty good to send message to another. its maintain a queue and when any message stay in that queue, the publisher immediately publish the message. From the EJB (Enterprise Java Beans) context, generally JMS is used for distributed asynchronous computing. Also its can be used for debugging, web chat service for customer and the provider etc. here i used it for doing logging for web service operation. the response can not wait for log write rather response return to the user and the log message sent to the HornetQ (a message Queue). then log will insert to database. Here i used JPA for query and Bean managed transaction. necessary tools given below, 1) JBoss-eap-6.2 or 7 2) MySql DB. here is the project structure. first we need to add the HornetQ module and for this make a xml file say named "hornetq-jms.xml" and put the code here. put the xml file in META-INF folder in your class path. <?xml version="1.0" encoding="U