Showing posts with label J2EE. Show all posts
Showing posts with label J2EE. Show all posts

Thursday 22 August 2013

Top Most Sun Certification - Is it Worth ?


I wrote things below few years back - 
" I have three Java certificates: SCJP, SCWCD, and SCBCD. 
Apart from this I have a testing certificate CTFL from ISTQB.
I started my career in marketing, then sales boy, then Outbound Call center, then Inbound call Center, and then I joined a technical Inbound Customer Care process. Then I worked in HR deptt. of a s/w company, and then finally joined a s/w firm as a tester. I did testing certificate, and as soon as I completed certification I got a offer of java programming. I was comp. science graduate and I loved programming, So I accepted the offer, and a java programmer was born.
Within the first six months of my Java programming experience I did SCJP.  It was worth. I learned a lot from this exam, and applied lot of things in my live project. Still after more than two years that knowledge helps me whenever i am writing any java code. That certificate also helps me in clearing any interview. I would SCJP is worth, no matter how much experience you have, no matter how old you are. Take exam, clear it, remember it, and enjoy it.
I worked in Web Development for two  years. Using Servlet, JSP, HTML, Tomcat, web.xml, etc. When i started Web Development I came to know about SCWCD, and found it interesting. I gave exam, and cleared it. I became master of servelet and jsp. But then there is much more than this in Web development. Application server, Web Server, XML, etc. Even if we only talk about development part then only knowledge of servlet and jsp is like a beginner. If u don’t know struts, spring, hibernate, etc. you are nowhere in Web development. I think rather than investing time in clearing SCWCD, that time should be invested in learning different frameworks like struts, spring, and hibernate. Knowledge of different frameworks helps you understand architecture, designs and increases your vision. Expertise in writing servelet and jsp code is not of much help. It gives you foundation but that foundation can be build even after small exp. in web development. I mean to say that few months exp in servlet and jsp is better than SCWCD. 
Now lets talk about SCBCD. Is your company using EJB. This is the  first question you should ask before taking this exam. Working knowledge is more essential in case of development. In programming and designing, theoretical knowledge works, but in case of development practical exp only works, no certificate helps. SCBCD is like SCWCD, means if you have hands on exp on EJB that is better. Still, SCBCD exam is very much different than SCWCD. SCBCD exam involves architecture of EJB, and esp if you are taking exam on EJB 3.0 then you would learn whole persistence concept. If you have exp on EJB, then you should give SCBCD. Do You know how and why EJB changed with time? Do You know what are architecture differences between EJB 1.0, 2.0, and 3.0? Do You know what is factory design pattern and what is the best example of it? Do you know what is annotation and what is persistence? Do you have understanding of transaction management? Do you know ESQL? Do you knoe session, stateful session, stateless session? Do you know Entity? Do you know message driven bean? and there many more questions and if you dont know the answer then you lack SCBCD. If you have this certificate you know answers of all these questions. SCBCD is worth if you wish to know more about EJB, if you are working on EJB, or you are planning to work on ejb. But If are simply not interested in EJB then SCBCD is of no use. 
The SCEA certification, however, is a completely different story. I think SCEA is the most attractive certification for developers who are seriously thinking about becoming a software architect. Also till now I have not cleared it. I really dont know how I would feel after getting this certificate. 
It's been my experience that most employers will overlook your certifications unless your resume shows that you have hands-on experience working with a particular technology. 
Most IT pros take certification exams more for self-learning than for their employer."


March, 2012 - 

But Now I have more exp., and my views have changed a bit. -
First of all I must say, certifications are a personal choice, and your own choice to add few more lines to resume. But rarely they impress the recruiter. Because i often take interviews of guys having SCJP or SCWCD, and they dont know basic concepts, or any thing about designing. Below I would like to discuss each java certification and alternative -

SCJP - Intially SCJP only covered basic java and its old, and it is only good for guys having exp of a max of 2 years. I would never be impressed by someone with 4 years of exp. and SCJP, and he doesn't know complex Multithreading java programming. There are some really complex and complicated things which are not covered in SCJP, and thye can really impress any one. They are Executer framework, new collection and map classes, NIO, socket, etc.And all these are now covered in Oracle Certified Professional Java SE 7 Programmer.. I believe give time to Executer framework, and NIO, they would boost your career.
                                                   If you want to Java programming certification, you should only go for Oracle Certified Professional Java SE 7 Programmer, and esp. Java SE 7 Programmer II

SCWCD - Its if good for knowledge of Servlet annd JSP, but it doesn't covers some of the most common frameworks like Struts, Spring, JSF, and Portlets, which are very widely used, and at least one of them is used in any big project. Still I would say, if you are into web development, and you have time, then you should read "Head First Servlet and JSP". This certification can also help if you are new to Web Development. I would never expect a person with 5 years of exp and SCWCD. Oracle Certified Expert, Java EE 6 Web Component Developer added some new topics, but I must emphasis that it is only good for entry level web developers.

SCBCD - Its for EJB. If you dont use EJB, never do it. If you use EJB do it. they are alternatives of EJB, like Spring. If you are using Spring, then skip EJB, many places EJB is not used. SCBCD covers EJB and JPA. As such EJB is not much, apart from some transaction settings, MDB, and session beans. And a few month exp. is good enough. JPA is not so widely used. Because at many places we are already using Hibernate or Toplink.
Oracle divided this certificate into two parts, so double money(:)), And made it separate for EJB and JPA, this is not good. A exp. over EJB and JPA or any ORM framework is good. JPA certification covers lot of topics, which we really dont want in real, but I would suggest reading some good book and understanding the EntityManager in JPA.

SCDJWS - This is bit confusing. Most of the times, we just call web services, or create web services,and that also using some tools. And they are pretty easy, one time you would do it, next time you dont need any one's help. Its a small task. You might face some issues, but they are also not covered in SCDJWS. Also, these day in all big architectures, there is separate Integration team, or service layer team, and they are using some Integration products like WMB, WPS, or TIBCO.

SCEA - Oracle stopped me thinking of this certification, because they made it mandatory to attend a training session to clear this, and I don't want to spend 2000 USD to attend a training to clear this certification. Because at the end, I dont want to limit my self to J2EE components only, and many and most big architectures are not only use J2EE, one must have knowledge of several other frameworks, and products to become and architect. 

Wednesday 21 August 2013

Top Most JMS Prevent Message Loss


Its a common question that comes in mind while dealing with JMS.
How to guarantee, there is no message loss?
Also how to secure message delivery, or guarantee message delivery.
Some of the considerations are below:
Persistent Message( in case of Queue and Topics):
A message can be persistent or non-persistent.
Acc. to JMS specification, when a message is marked as persistent, the JMS provider must “take extra care to insure the message is not lost in transit due to a JMS provider failure”.
If the message is persistent, message is stored in the data structure representing the Queue(it can be table in database or file, etc. ), otherwise message is stored in memory.
When message is sent over Queue, If a consumer is connected the message will be dispatched to it. If there are no consumers connected the message will remain saved on disk until a consumer connects, whereupon it will be dispatched. If message is non persistent message is saved in memory.  Which means if the Queue Broker or Queue Manager is restarted, the message would be lost.
Durable Subscription(In case of Topics):
A subscription on a topic can either be durable or non-durable. The term durable applies to the subscription, not the topic itself or the messages sent to it. And it applies only to subscriptions on topics, not subscriptions on queues.
If the subscription is open(active), both non-durable and durable behave in same way.
Diff. comes when the subscription is closed. Only durable Client would receives missed messages, when subscription is again open/active.                                                                        In case of topics, there can be different combinations of persistent/non-persistent  messages and durable/non-durable subscription.
If subscription is durable, then message would be saved if the subscriber is inactive, otherwise not.
If message is persistent, it would be saved on disk otherwise in memory.
So, same message would be saved for durable subscribers, and wont be saved for non durable subscriber.
In case of topics there can be diff scenarios:
Multi Consumer Queue Multi Consumer Queue is a concept some times confused with Topic.  Multi Consumer Queue, is a case when multiple consumers register with a Queue. Message Broker routes the incoming messages to different consumers. Its all the case of load balancing, where one batch of messages is sent to One consumer, and next batch batch is sent to next consumer in line, and similarly batch of messages is sent to different consumer, but same message is not sent to multiple consumers.  Messages are routed to active consumers in order they registered with the broker. Idea behind is the message production rate is much higher, and there is a need of load balancing on the message consumer side. We have a special scenarios to consider, which might relate to message loss. When message production rate is slow, broker might dispatch messages in uneven manner, and some consumers may never receive any message. There should be a backup consumer, if the active consumer fails. And to avoid whole batch of messages.
Message is an entity, and once client delivers the message to Message Broker inside Provider, its role is finished. Message are passed to consumer using the store and forward paradigm. To avoid loosing message in case of Provider failure OR consumer failure, message should be persistent message.   Message can be in many states –                                                                                                    
 It might be prepared by Client and not yet delivered to Broker.                                         
Message is routed to Broker by the Message Producer.  
Message is at Broker and waiting for Consumer to consume it.   
Message has been delivered from Broker to Consumer.                
When we make message Persistent or when we make Durable Subscription, we guarantee that message wont be lost from Broker. But message can be in a different state also, OR message is carrying some data or information, which should not be lost. If message is delivered from Broker, it must reach Consumer, it should not be lost in network, and if in case it is lost, there should be redelivery. 
Guaranteed Delivery –  When we make message persistent, we guarantee that message wont be lost from broker. In case of Topics, we take one extra care that we make durable subscriptions.  We have to take care that Message is not lost on network, or if it is lost in network, we must know and redeliver. Message Acknowledgment is key to guaranteed messaging and ensures that is message is lost from network while travelling from producer to consumer, it would be redelivered.
Message Acknowledgment - There are several types of Acknowledgement, and acknowledgement is set on session. Message Acknowledgment has different meaning for Broker and Consumer. Acknowledgment means consumer acknowledges that message is received. Acknowledgement is sent from broker, and also from consumer to broker.
Brokers Acknowledgement( Broker to producer) - Broker received message, stored in memory or data store(in case of persistet message), and accepts responsibility of delivering it to consumer.
Consumer Acknowledgement(Consumer to broker) – Acknowledgment is sent according to the Acknowledgement Mode. In case of AUTO, the session automatically acknowledges the client’s receipt of message. In CLIENT, client has to explicitly send acknowledgement by calling message’s acknowledge method. In DUPS_OK, acknowledgment is sent after consuming particular number of messages( lazy acknowledgement). Message can also be received in TRANSACTIONAL_MODE, where message is received in JTA transaction, and acknowledgement is sent only if transaction commits. If broker doesn’t receives an acknowledgement, it would attempt to redeliver the message, with setting a flag JMSRedelivered on message.
There can be a scenario, where consumer consumes a message, and sends ack., but ack. fails and lost in network, and broker would assume that message is lost and not consumed by consumer, and it would try to redeliver, this can lead to duplicate message for consumer. Consumers should always check for JMSRedelivered flag for identifying the duplicate messages.
Remember, Message Re delivery not guaranteed for more than once.
In a complex architecture, several consecutive operations can be combined under single transaction. We can use the same session to receive a message from a queue and send a message to a topic in the same transaction, if required, programatically. We cn make the session transactional, and perform multiple operations into one atomic unit of work if required. Please find below were it was required to use JMS local transaction for guaranteeing delivery.                                                                                                                 
Scenario – Transfer messages from one queue to another.                                                           Assumption – Two Queues – Queue1 and Queue2, we are going to write a Java program to transfer messages.                                                                                                                            
Remember, Receiving a message form Queue1 and Sending message to Queue2 are two different transactions.                                                                                                
Transaction(T1) – Receive message form Queue 1                                                                         Transaction(T2) – Send message to Queue2.                                                                                  
We need to perform both transactions in XA fashion, means if any one fails, it should be rolledback. Means for any particular message, if any transaction(T1 or T2) fails, it should be send back to Queue1. T1 and T1 should be combined into one transaction. We can use XA resources, but here we are doing it manually(to observe more closely). -
JMSMessageReciver – program to receive message from JMS Queue.                                       MQMessageSender – program to message over MQ.



Top Most Struts1 vs. Struts2 – Difference between Struts1 and Struts2


What is the difference between Struts1 and Struts2?
I believe its very important to understand the difference, even if you are not working on Struts.
Struts2 architecture, design, and flow is probably the best among all web application frameworks today.
You might work for few years and then design an excellent framework, and most probably it would be Struts, or if much better than it would be Struts2.
I am going to continue explore the Struts and Struts2 within few posts.
but starting with some very basic difference between Struts1 and Struts2. Because those who are familiar with Struts1, must know these basic difference, which is big difference in architecture and framework.
Web.xml configuration changes.                                                                   
 Struts1.                                       ActionServlet was the concrete controller for an application.The Controller was responsible for intercepting and translating the User Input into Actions to be performed by the model.                  
 Struts2                                       FilterDispatcher executes action by consulting the ActionMapper and determining if the requested URI should invoke action. If mapper indicates proper action is invoked.      Filter also serves common static content.                           
  Configuration file Changes:                                                               
  Struts1                                                There was struts-config.xml.Configuration file is listed as initialization parameter to the action servlet in web.xml.  Parameter can be extended to specify multiple config initialization parameter.                                                               
 Struts2                                                     We have struts.xml.There is no initialization parameter for struts.xml. struts.xml needs to be in the class path. Struts.xml has file inclusion facility.                                                 
Namespace separation between Struts Action                                                                
Struts1                                                                   .do                                                                
Struts2                                                                .action.
A difference in the action, also means that Strusts1 and Struts2 can both co extst within the same application.  Which also means actions are the good point to strat the migration from Struts1 to Struts2.
Now, those who have worked over Struts, and those who are aware of the Action classes in Struts, for them there is a big diff. between Struts1 action and Struts2 action:

Struts1
All Actions have to extend the Action class. Single Action instance is created. So, all actions have to thread safe. Action has to be thread safe, so all objects are passed as parameter.The name of the first method that is invoked for the processing of action, must be execute(), however DispatchAction class can be used to re-route the action to different method within the same action.Return of the execute() method is ActionForward, generated using the methods of the ActionMapping class.                                                                         
Struts2
Action class doesn’t need to extend any class or interface.An action instance is created for each request. Its not shared and its discarded after the request has been completed.Its not mandatory to have the method name as execute(). Any method with proper signature can be invoked through configuration.No objects as parameters are passed to the method. Objects are available to the method using Dependency Injection.Return object of the method is String. Helper interface Action is available for String constants like: “success”, “error”, etc.
The difference in the Action classes also leads to one confusion, of how is the HttpServletRequest, request parameters, Mappings, etc. available to the Action class in the Struts2.
A sample Action class in Struts1 was something like:
public class RemoveEntryAction extends Action {
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
Service service = new Service();
String id = request.getParameter(“id”);
service.delete(Integer.parseInt(id));
return (mapping.findForward(“success”));
}
}
As we can see that id is fetched from the request. Service is a Service class or it can be a facade.
RemoveEntry is one action, Similarly we would have multiple Action classes for different actions.
Actions like making new entry, updating entries, finding entries, etc.
And all the action classes related the Entry would be similar, in the sense, all would retrieve id from the HttpServletRequest, instantiate Service, and call some method of the Service class.
This is how things were in Struts1.
In Struts2, since a new object would be created for each request, we can have class level variables, we can have some setter methods, and above all we can write all the actions within the same class.
So, we can have a class level variable like Service( for Service class), and id( for id retrieved from HttpServletRequest), we can have setter methods for these class level variables.
Assume, we want to write the Action class like this:
public class EntryAction {
private int id;
private Entry entry;
private Service service = new Service();
private HttpServletRequest request;
public void setServletRequest(HttpServletRequest httpServletRequest) {
this.request = httpServletRequest;
}
public void setId(int id) { this.id = id; }
public void prepare() throws Exception {
if( id==0 ) { entry = new Entry(); }
else { entry = service.findById(id); }
}
public Object getModel() { return entry; }
public String save() { service.create(entry); return SUCCESS; }
public String update() {
service.update(entry);
request.setAttribute(“entry”,entry);
return SUCCESS;
}
public String remove() {
service.delete(id); return SUCCESS;
}
public String execute() {
request.setAttribute(“entry”,entry);
return SUCCESS; }
}
But the whole idea would be defeated, and we wont be achieving anything if we are going to call the setters.
When new instance should be created for each request, then variables should be set automatically, possibly by the container. And this is how it should be. And this is how it is done.
And this is where Dependency Injection comes in.
To use dependency injection, we need to implement several interfaces.
In fact, what all features we need, we need to implement corresponding interfaces.
To make our Action class to be HttpServletRequest aware, we need to implement and Interface “ServletRequestAware”.
Next, if we have something like init, or postContsruct thing, we can have a prepare() method.
prepare() method would be executed before the execute(or any action method).
We need to implement “Prepeable” interface for that.
We need to apply changes to the model object, and for that we need to implement “ModelDriven”.
And implement getModel() method.
Instance variable in the Action classes is matched with request parameter, and if there is any match, then instance variable is set automatically. So, if the HttpServletRequest contains a parameter named “id”, and Action class has a variable names id, then when the Action class would be instantiated, its id variable would be populated with value of the id in request parameter. Now, remember this is a optional feature, and its not happens by default. Dependency needs to be injected.
We must inform the container that we need this feature. And there should be an interceptor, who is going to do this work.“ParametersInterceptor” is going to do this work
public class EntryAction implements ModelDriven, Preparable, ServletRequestAware {
}


Top Most Prevent Message Loss in Message Driven Bean


Message Driven Bean(MDB) is a stateless, transaction aware J2EE component for consuming messages asynchronously. MDB’s are configured to listen any queue, and pick messages and handle them. If some exception is generated,  by default it wont be handled, and thrown to container. Container decides what to do in such case, some container in case of System Exception destroy the MDB instance, GlassFish on Runtime Exception would close the connection.
When exception is generated, either the MDB can consume the exception and take necessary action, acc. to exception(this would be the case in Business Exceptions). But sometimes exception might be related to System, which we can consider as System Exception, and we need to wait for some time and retry the message handling. Inside Message Driven Bean we can configure the retry mechanism. So, when exception would be generated, there would be retry. We can consume the Application Exceptions( or Checked Exceptions, or sometimes called as Expected Exceptions), and in case of System Exceptions(unchecked Exceptions) we need a retry.
Retry can be configured using property “MaxDeliveryCnt” of ActivationConfig. We can also set the time interval between each retry, by setting property“endpointFailureRetryInterval”.  Any message, which has reached the max. retry count, is considered as “Poison Message”.  Poison message would be discarded by the JMS provider.  But handling of poison message would depend on JMS provider.  What we can do is configure a Exception Queue, where all the poison message would end.  For using the Exception Queue, we need to set some properties like: we set“UseExceptionQueue” as true, And set the Queue Name in“ExceptionQueueName”, And optionally we can set the property“IncludeBodiesInExceptionQueue” as true, If we want to include the message body, when it reaches the Error Queue.
With above settings, there would be redelivery with any transaction attribute( Remember we can set either “Required” or “Not_Supported” on onMessage()).

LinkWithin

Related Posts Plugin for WordPress, Blogger...

Labels

Core Java programming core java interview question Core Java Faq's Servlets coding database jsp-servlet spring Java linux unix interview questions java investment bank Web Services Interview investment bank mysql Senior java developer interviews best practices java collection tutorial RMI SQL Eclipse FIX protocol tutorial tibco J2EE groovy java questions SCJP grails java 5 tutorial jdbc beginner error and exception Design Patterns Java Programming Tutorials fundamentals general object oriented programming xml Java Programs Hibernate Examples Flex JAMon Java xml tutorial logging Jsp Struts 2.0 Sybase and SQL Server debugging java interviews performance FIX Protocol interview questions JUnit testing WebSphere date and time tutorial experienced java IO tutorial java concurrency thread Ejb Freshers Papers IT Management Java Exapmle Java Script SQL and database tutorial examples Scwcd ant tutorials concurrency example and tutorial future state homework java changes java threading tricky Agile Business of IT Development JSTL Java JSON tutorial Java multithreading Tutorials PM Scrum data structure and algorithm java puzzles java tips testing tips windows 8 5 way to create Singleton Object Architect Interview Questions and Answers Architecture Architecure Bluetooth server as swing application that searches bluetooth device in 10 meter circle and show all devices. You can send file to any bluetooth device. C Programming CIO Callable Statement in Java Circular dependency of Objects in Java Comparable Example in Collection Custom annotation in Java Developer Interview Divide and rule example in java Drupal Example of Singleton Pattern FIX protocol ForkJoin Example in Java 7 Get data from dynamic table with Java Script Git HTML and JavaScript Health Hello World TCP Client Server Networking Program Hibernate Basics Hibernate Interview Question Answer J2EE Interview Question And Answers J2ME GUI Program JEE Interview QA JMS interview question Java J2EE Hibernate Spring Struts Interview Question Java System Property Java Threads Manager Portlets Provident Fund Read data from any file in same location and give the required result. Reading Properties File in Java Redpoint Rest WebService Client Rest Webservice Test SAL join with ven diagram SCP UNIX COMMAND SSL Singleton Pattern in Java Spring Bean Initialization methods and their order Spring Interview Questions Struts Struts 2.0 Basics Struts 2.0 Design Pattern Submit Html Form With Java Script On The Fly Unix executable For Java Program XOM DOM SAX XP books computers core java; core java; object oriented programming data structure; java investment bank; design pattern dtd duplicate rows in table get browser name with jquery grails podcast inner class java beginners tutorial java cache java networking tutorial java spring java util; java collections; java questions java.java1.5 linked list mailto function with all browser oracle database oracle duplicate rows orm schema social spring mvc questions struts transaction tricks tweet windows xslt