Search More About Above Topic Here

Custom Search

HTTP + REST Vs. AMQP + RPC

Links to this post
  • REST, RPC - architecture patterns, AMQP - wire-level and HTTP - application protocol which run on top of TCP/IP
  • AMQP is a specific protocol when HTTP - general-purpose protocol, thus, HTTP has damn high overhead comparing to AMQP
  • AMQP nature is asynchronous where HTTP nature is synchronous
  • Both REST and RPC use data serialization, which format is up to you and it depends of infrastructure. If you are using python everywhere I think you can use python native serialization - pickle which should be faster than JSON or any other formats.
  • Both HTTP+REST and AMQP+RPC can run in heterogeneous and/or distributed environment
So if you are choosing what to use: 
HTTP+REST or AMQP+RPC, the answer is really subject of infrastructure complexity and resource usage. Without any specific requirements both solution will work fine, but i would rather make some abstraction to be able switch between them transparently.
You told that your team familiar with HTTP but not with AMQP. If development time is an important time you got an answer.
If you want to build HA infrastructure with minimal complexity I guess AMQP protocol is what you want.
I had an experience with both of them and advantages of RESTful services are:
  • they well-mapped on web interface
  • people are familiar with them
  • easy to debug (due to general purpose of HTTP)
  • easy provide API to third-party services.
Advantages of AMQP-based solution:
  • damn fast
  • flexible
  • easy to maintain
  • easy to scale
  • cost-effective (in resources usage meaning)
Note, that you can provide RESTful API to third-party services on top of your AMQP-based API while REST is not a protocol but rather paradigm, but you should think about it building your AQMP RPC api. I have done it in this way to provide API to external third-party services and provide access to API on those part of infrastructure which run on old codebase or where it is not possible to add AMQP support.
If I am right your question is about how to better organize communication between different parts of your software, not how to provide an API to end-users.
If you have a high-load project RabbitMQ is damn good piece of software and you can easily add any number of workers which run on different machines. Also it has mirroring and clustering out of the box. And one more thing, RabbitMQ is build on top of Erlang OTP, which is high-reliable,stable platform ... (bla-bla-bla), it is good not only for marketing but for engineers too. I had an issue with RabbitMQ only once when nginx logs took all disc space on the same partition where RabbitMQ run.

If Runnable interface is better than Thread class, then why we are using Thread class?

Links to this post
If Runnable interface is better than Thread class, than why we are using Thread class? What is the need for Thread class?

  • When you extends Thread class, after that you can’t extend any other class which you needed. (As you know, Java does not allow multiple inheritance.)
  • If your class is Implementing the Runnable interface then you only override the run() .So this instance creates a separate Thread and every individual Thread runs separately but not as a single heavy Thread in your program. Another thing, Since Java does not support multiple inheritance, if you implement the Runnable you'll avoid problems of multiple extending, so if you implement Runnable interface you can extend any class that you are required other than Thread class.
However, the main difference is.
  • When you extends Thread class, each of your thread creates unique object and associate with it.
  • When you implements Runnable, it shares the same object to multiple threads.
 

DOM Parser Vs. SAX Parser

Links to this post
Many developers sometimes confuse which is better to parse the XML document. Ofcourse myself also got doubt which parser I can use for this situation.  Since I have read about DOM and SAX very long back. Just refreshing it again

DOM (Document Object Model) Parser:
  • Tree model parser(Object based) (Tree of nodes).
  • DOM loads the file into the memory and then parse the file.
  • Has memory constraints since it loads the whole XML file before parsing.
  • DOM is read and write (can insert or delete the node).
  • If the XML content is small then prefer DOM parser.
  • Backward and forward search is possible for searching the tags and evaluation of the information inside the tags. So this gives the ease of navigation.
  • Slower at run time.

How To Solve "Error: Could not find or load main class org.codehaus.classworlds.Launcher while building Maven 3.0.4"

Links to this post
I was trying to solve this error in my Ubuntu. Since I need to build Hue /Spark Application and when run the "make apps" or "mvn --version" command on terminal, I was getting "

Error: Could not find or load main class org.codehaus.classworlds.Launcher while building Maven 3.0.4
This error ate all my day almost. Finally found a solution on one website. Just you need to uninstall old maven versions or existing maven. and

sudo apt-get purge maven maven2 maven3
sudo apt-add-repository ppa:andrei-pozolotin/maven3
sudo apt-get update
sudo apt-get install maven3
 Thanks a lot to those guys for a great help.

Solution For Error: " Current configuration of the parser doesn't allow a maxOccurs attribute value to be set greater than the value 5,000."

Links to this post
Currently I am working on a project where I need to transform Excel sheet data to an XML format in compliance with XSD given by my client.

When I am trying to parse the XSD using JAXB I got this error when doing mvn clean install.
Error: ""Current configuration of the parser doesn't allow a maxOccurs attribute value to be set greater than the value 5,000."

I found many solutions and route cause for this issue. You can find some information on Oracle site the route cause for the issue. It is because of the feature enabled for secure XML processing. This feature was enable in JAXP 1.3 which instructs parsers, transformers to behave in a secure fashion. You can find more infor here: https://jaxp.java.net/1.4/JAXP-Compatibility.html#JAXP_security.

For me 2 solutions worked out:

Solution 1:
With code change or implemenetation:
//Create SchemaFactory using XSD file
SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING,false);
Schema schema = factory.newSchema(xsdSource);


Solution 2:
Related Posts with Thumbnails
Custom Search