Labels

.NET Job Questions About Java Absract class Abstract class Abstract Class and Interface Aggregation ajax aop apache ofbiz Apache ofbiz tutrial Association authentication autocad basics batch Binary Tree bootstrap loader in java build Builder design pattern C++ Job Questions caching CallableStatement in java certifications Chain of responsibility Design pattern charts check parentheses in a string Classes classloader in java classloading concept code quality collage level java program Composition concurrency Concurrency Tutorial Converting InputStream to String Core Java core java concept core java interview questions Core Java Interview Questions Core Java Questions core java tutorial CyclicBarrier in Java data structures database Database Job Questions datetime in c# DB Db2 SQL Replication deserialization in java Design Patterns designpatterns Downloads dtd Eclipse ejb example/sample code exception handling in core java file handling injava File I/O vs Memory-Mapped Filter first program in spring flex Garbage Collection Generics concept in java grails groovy and grails Guice Heap hibernate Hibernate Interview Questions how-to IBM DB2 IBM DB2 Tutorial ide immutable Interceptor Interface interview Interview Questions for Advanced JAVA investment bank j2ee java JAVA Code Examples Java 7 java changes java class loading JAVA Classes and Objects Java Classloader concept Java classloading concept java cloning concept java collection Java collection interview questions Java Collections java concurrency Java CountDownLatch java definiton Java design pattern Java EE 5 Java EE 6 Java Exceptions Java file Java Garbage Collection Java generics Java Glossary java hot concept java immutable concept Java Interface Java interview Question java interview question 2012 java interview question answer Java Interview Questions Java Interview Questions and Answers java interview topic java investment bank Java Job Questions java multithreading java multithreading concept java new features Java Packages java proxy object java questions Java Serialization Java serialization concept java serialization interview question java session concept java string Java Swings Questions java synchronization java threading Java Threads Questions java tutorial java util; java collections; java questions java volatile java volatile interview question Java Wrapper Classes java.java1.5 java.lang.ClassCastException JavaNotes javascript JAX-WS jdbc JDBC JDBC Database connection jdk 1.5 features JDK 1.5 new features Concurrent HashMap JMS interview question JMS tutorial job JSESSIONID concept JSESSIONID interview Question JSF jsp JSP Interview Question JSP taglib JSTL with JSP Junit Junit Concept Junit interview question.Best Practices to write JUnit test cases in Java JVM Linux - Unix tutorial Marker Interfaces MD5 encryption and decryption messaging MNC software java interview question musix NCR java interview question Networking Job Questions news Object Serialization Objects ojdbc14.jar OOP Oracle Oracle SQL Query for two timestamp difference orm own JavaScript function call in Apache ofbiz Packages Palm Apps patterns pdf persistence Portal Portlet Spring Integration Prime number test in java programs Rails Reboot remote computers REST Ruby Sample application schema SCJP security Senior java developer interviews servlet3 servlets session tracking singleton design pattern Spring Spring 2.5 Framework spring ebook Spring framework concept spring MVC spring pdf Spring Security Spring Security interview questions SQL SQL performance SQL Query to create xml file Sql Query tuning ssis and ssrs StAX and XML string concept string immutable string in java strings struts Struts2 Struts2 integration synchronization works in java Technical Interview testing tips Tomcat top Tutorial Volatile in deep Volatile working concept web Web Developer Job Questions web services weblogic Weblogic Application Server websphere what is JSESSIONID xml XML parsing in java XML with Java xslt


Saturday 20 July 2013

JMS Interview Questions - Part1


JMS Interview Questions - Part1


1.     What is JMS?
Java Message Service is the new standard for interclient communication. It allows J2EE application components to create, send, receive, and read messages. It enables distributed communication that is loosely coupled, reliable, and asynchronous.

2.     What type messaging is provided by JMS
Both synchronous and asynchronous

3.     How may messaging models do JMS provide for and what are they?
JMS provides for two messaging models, publish-and-subscribe and point-to-point queuing
 
4.     What are the types of messaging? 
        There are two kinds of Messaging. Synchronous messaging involves a client that waits for the server to respond to a message.   
        Asynchronous messaging involves a client that does not wait for a message from the server. An event is used to trigger a message from a
        server.
5.     What is publish/subscribe messaging?
        With publish/subscribe message passing the sending application/client establishes a named topic in the JMS broker/server and publishes
        messages to this queue. The receiving clients register (specifically, subscribe) via the broker to messages by topic; every subscriber to a
        topic receives each message published to that topic. There is a one-to-many relationship between the publishing client and the subscribing
        clients.
6.     Why doesn’t the JMS API provide end-to-end synchronous message delivery and notification of delivery?
        Some messaging systems provide synchronous delivery to destinations as a mechanism for implementing reliable applications. Some systems
        provide clients with various forms of delivery notification so that the clients can detect dropped or ignored messages. This is not the model
        defined by the JMS API. JMS API messaging provides guaranteed delivery via the once-and-only-once delivery semantics of PERSISTENT
        messages. In addition, message consumers can insure reliable processing of messages by using either CLIENT_ACKNOWLEDGE mode or
        transacted sessions. This achieves reliable delivery with minimum synchronization and is the enterprise messaging model most vendors and          developers prefer. The JMS API does not define a schema of systems messages (such as delivery notifications). If an application requires
        acknowledgment of message receipt, it can define an application-level acknowledgment message.
7.     What are the core JMS-related objects required for each JMS-enabled application?
        Each JMS-enabled client must establish the following:
o    A connection object provided by the JMS server (the message broker)
o    Within a connection, one or more sessions, which provide a context for message sending and receiving
o    Within a session, either a queue or topic object representing the destination (the message staging area) within the message broker
o    Within a session, the appropriate sender or publisher or receiver or subscriber object (depending on whether the client is a message producer or consumer and uses a point-to-point or publish/subscribe strategy, respectively). Within a session, a message object (to send or to receive)
9.     What is the Role of the JMS Provider?
        The JMS provider handles security of the messages, data conversion and the client triggering. The JMS provider specifies the level of
        encryption and the security level of the message, the best data type for the non-JMS client.
9.     How does a typical client perform the communication? -
1.      Use JNDI to locate administrative objects.
                        2.   Locate a single ConnectionFactory object.
3.      Locate one or more Destination objects.
4.      Use the ConnectionFactory to create a JMS Connection.
5.      Use the Connection to create one or more Session(s).
6.      Use a Session and the Destinations to create the MessageProducers and MessageConsumers needed.
7.      Perform your communication.

10.   Give an example of using the point-to-point model.
        The point-to-point model is used when the information is specific to a single client. For example, a client can send a message for a print
        out, and the server can send information back to this client after completion of the print job.

JMS Interview Questions - Part2




1)
Does Tomcat support JMS (Java Messaging Service)?
Tomcat is just a servlet container, not an EJB container nor an application server, so it does not contains any JMS basic support.

However, there's nothing stopping you from using another JMS provider

2)Is it possible to send email messages using JMS?
JMS has no inherent support for email operations.

3)How do I communicate between two clients that are on different machines on a network using JMS? I want to use a standalone application for communicating between the machine and I want to pass the message using JMS.
You can make two JMS client applications, say AppA and AppB. Make AppA listen to topic ‘forA’. Make AppB listen to topic ‘forB’.
If AppA sends a message to topic ‘forB’, AppB will receive it. If AppB sends a message to topic ‘forA’, AppA will receive it.
For sample code etc, try downloading SonicMQ (as a JMS server) and go through the samples.



4)Is there any relationship between javax.jms.Message and javax.mail.Message?
There is no direct relationship between javax.mail.Message and javax.jms.Message. If your requirement is to map (correlate) them, here is what you can do:
1.     From JMS domain to JavaMail domain (a javax.jms.Message is received):
1.     A JMS topic/queue can be associated with one or many e-mail id(s).
2.     The JMS Message Header can be mapped to ‘custom’ JavaMail Message Header.
3.     The JMS Message Body can be associated with the JavaMail Message body.
4.     A JavaMail client application should be able to process these ‘custom’ headers and the content of the message body.
 
2.     From JavaMail domain to JMS domain (a javax.mail.Message is received):
1.     An e-mail id can be associated with one or more JMS topics/queues.
2.     The JavaMail Message Header can be mapped to ‘custom’ JMS Message Header.
3.     The JavaMail Message Body can be associated with the JMS Message body.
4.     The JMS client application should be able to process these ‘custom’ headers and the content of the message body.
 
In a simple application that I tried, I removed the ‘custom’ header scenario and just forwarded the contents of the message (text message), which worked without any problems.Try using SonicMQ bridges, which already has something like that.

5)Is it possible to acknowledge individual messages on a queue without affecting previously received, but as yet unacknowledged, messages?
If you acknowledge a message, all previously received messages will also be acknowledged. From the javax.jms.Message Javadoc, the acknowledge method will "Acknowledge this and all previous messages received."
So the answer to your question is no, if what you meant by "affecting" is not-yet acknowledged.
I suggest an alternative. You should look at javax.jms.QueueBrowser to review queued messages. QueueBrowser has getEnumeration, which "Gets an enumeration for browsing the current queue messages in the order they would be received".

6)What encryption options are there for sending messages through JMS?
Encryption is not handled by the JMS specification. It is left to the JMS provider to implement and provide encryption and decryption of messages. These days, Progress Software’s SonicMQ is a leading JMS provider and they have a robust encryption mechanism called Quality of Protection. They also provide an SSL-related feature, which also has build in encryption.






7)How does the Application server handle the JMS Connection?

1.     Application server creates the server session and stores them in a pool.
2.     Connection consumer uses the server session to put messages in the session of the JMS.
3.     Server session is the one that spawns the JMS session.
4.     Applications written by Application programmers creates the message listener.

No comments:

Post a Comment

LinkWithin

Related Posts Plugin for WordPress, Blogger...