Author Archive for ashesh

JMS - Ensuring Reliability | Part - 2


Continuing from Part 1 which talked about Message Acknowledgment and means of ensuring basic reliability with JMS, here we talk about Persistence, Expiration, Priority and Temporary Queues/Topics.

What are the two delivery modes for messages to specify their Persistence? And, how do you specify them?
The two delivery modes are fields of the DeliveryMode interface and are as follows.

  1. The PERSISTENT delivery mode, which is the default, instructs the JMS provider to take extra care to ensure that a message is not lost in transit in case of a JMS provider failure. A message sent with this delivery mode is logged to stable storage when it is sent.
  2. The NON_PERSISTENT delivery mode does not require the JMS provider to store the message or otherwise guarantee that it is not lost if the provider fails.

Continue reading ‘JMS - Ensuring Reliability | Part - 2′

JMS - Ensuring Reliability | Part - 1


Until a JMS message has been acknowledged, it is not considered to be successfully consumed. The successful consumption of a message ordinarily takes place in three stages.
1. The client receives the message.
2. The client processes the message.
3. The message is acknowledged. Acknowledgment is initiated either by the JMS provider or by the client, depending on the session acknowledgment mode.

What are the basic mechanisms for impacting the reliability of message delivery?
  • ACKNOWLEDGMENT- by specifying various levels of control over message acknowledgment
  • PERSISTENCE - by specifying that messages are persistent, that they must not be lost in the event of a provider failure
  • PRIORITY - by setting various priority levels for messages, which can affect the order in which the messages are delivered
  • EXPIRATION - by specifying an expiration time for messages, so that they will not be delivered if they are obsolete
  • TEMPORARY DESTINATION - by creating temporary destinations that last only for the duration of the connection in which they are created

Continue reading ‘JMS - Ensuring Reliability | Part - 1′

JMS Introduction


Messaging enables distributed communication that is loosely coupled. A component sends a message to a destination, and the recipient can retrieve the message from the destination. However, the sender and the receiver do not have to be available at the same time in order to communicate. In fact, the sender does not need to know anything about the receiver; nor does the receiver need to know anything about the sender. The sender and the receiver need to know only what message format and what destination to use. In this respect, messaging differs from tightly coupled technologies, such as Remote Method Invocation (RMI), which require an application to know a remote application’s methods.

A JMS application is composed of the following parts.

  • A JMS provider is a messaging system that implements the JMS interfaces and provides administrative and control features. An implementation of the JEE platform usually includes a JMS provider.
  • JMS clients are the programs written in the Java that produce and consume messages.
  • JMS Destinations are Queue for a point-to-point messaging and Topic for pub/sub messaging.
  • Messages are the objects that communicate information between JMS clients and destinations.
  • Administered objects are pre-configured JMS objects created by a server administrator for the use of messaging clients. The two kinds of administered objects are destinations and connection factories

Continue reading ‘JMS Introduction’

JMS - Message Driven Bean


A Message Driven Bean or MDB is a JMS message consumer that usually implements some message processing and/or routing logic. The bean registers interest (via deployment descriptor) in a Queue or Topic of its choice, implements MessageListener and MessageDrivenBean interface, and awaits arrival of asynchronous messages.

Does an MDB have a home or a component interface?
Messages are delivered asynchronously to a bean by the messaging service provider (e.g. IBM MQ) or an application server (e.g. JbossMQ). The bean cannot be invoked by a client and hence does not require a home or a component interface.An MDB does not have any client-visible identity or a conversational state - all the instances of the bean are treated equivalent for servicing receipt of a message. Typically, a server creates a pool of MDB instances and keep them in method-ready state. On arrival of a message, one of the instances is assigned to the client. After the onMessage() method execution, the bean is returned to the pool of available beans. The J2EE (now JEE) container essentially controls the lifecycle of such a bean. The component pooling of MDB results in more scalable applications.

Continue reading ‘JMS - Message Driven Bean’

Assignment - XML, Java


Problem

You have to create an XML file denoting a mall with shops having products. Create a program to find the best deal on a product in the given mall. Shops carry different products at different prices.

Write your code in Java. Programs should run from command line. There is no need to develop any GUI components, unless you think we will be impressed by it!

Continue reading ‘Assignment - XML, Java’

Clipmarks saves our lives


A very useful tool for compulsive surfers and bloggers. Instead of storing link, store what’s relevant on those links, share them, post em on your blogs, or mash em up with data marts. Continue reading ‘Clipmarks saves our lives’

Examples of our Technical Assignments


Problem

You have been given a method int r5() which returns a number from 1 to 5. The return values are based on the following rules:

  1. The method returns a random number based on a random seed value (e.g. wind speed at random location at a random time)
  2. Each number from 1 to 5 has an equal probability of being returned

Derive a random method int r7() from r5() which returns a number from 1 to 7 and confirms to the rules above. Continue reading ‘Examples of our Technical Assignments’