JMS- Quick Refresher

Extracts from the original Sun J2EE 1.3 JMS documentation

Amplify’d from docs.oracle.com

A connection factory is the object
a client uses to create a connection with a provider. A connection factory
encapsulates a set of connection configuration parameters that has been defined
by an administrator. A pair of connection factories come preconfigured with
the J2EE SDK and are accessible as soon as you start the service. Each connection
factory is an instance of either the QueueConnectionFactory or
the TopicConnectionFactory interface.

j2eeadmin -addJmsFactory jndi_name queue
j2eeadmin -addJmsFactory jndi_name topic
Context ctx = new InitialContext();
QueueConnectionFactory queueConnectionFactory = 
  (QueueConnectionFactory) ctx.lookup("QueueConnectionFactory");
TopicConnectionFactory topicConnectionFactory = 
  (TopicConnectionFactory) ctx.lookup("TopicConnectionFactory");
3.1.1   Connection Factories

3.1.2   Destinations

A destination is the object a client
uses to specify the target of messages it produces and the source of messages
it consumes. In the PTP messaging domain, destinations are called queues,
and you use the following J2EE SDK command to create them:

j2eeadmin -addJmsDestination queue_name queue
Queue myQueue = (Queue) ctx.lookup("MyQueue");
3.2   Connections

A connection encapsulates a virtual connection
with a JMS provider. A connection could represent an open TCP/IP socket between
a client and a provider service daemon. You use a connection to create one
or more sessions.

QueueConnection queueConnection =
  queueConnectionFactory.createQueueConnection();
TopicConnection topicConnection = 
  topicConnectionFactory.createTopicConnection();
A session is a single-threaded context
for producing and consuming messages. You use sessions to create message producers,
message consumers, and messages. Sessions serialize the execution of message
listeners; for details, see Section 3.5.1,
“Message Listeners.”
Sessions, like connections, come in two forms,
implementing either the QueueSession or the TopicSession
interface. For example, if you created a TopicConnection object,
you use it to create a TopicSession:
3.3   Sessions
3.4   Message Producers

A message producer is an object created
by a session and is used for sending messages to a destination. The PTP form
of a message producer implements the QueueSender interface. The
pub/sub form implements the TopicPublisher interface.

QueueSender queueSender = queueSession.createSender(myQueue);
TopicPublisher topicPublisher = topicSession.createPublisher(myTopic);
topicPublisher.publish(message);
3.5.1   Message Listeners
queueConnection.start();
Message m = queueReceiver.receive();
topicConnection.start();
Message m = topicSubscriber.receive(1000); // time out after a second

A message listener is an object that
acts as an asynchronous event handler for messages. This object implements
the MessageListener interface, which contains one method, onMessage.
In the onMessage method, you define the actions to be taken when
a message arrives.

3.5.2   Message Selectors

If your messaging application needs to filter the messages it receives, you can use a JMS API message selector, which allows a message consumer to specify the messages it is interested in. Message selectors assign the work of filtering messages to the JMS provider rather than to the application. For an example of the use of a message selector, see Chapter 8.

3.6   Messages

A JMS message has three parts:

3.6.3   Message Bodies

Table 3.2:    JMS Message Types

TextMessage

MapMessage

BytesMessage

StreamMessage

ObjectMessage

Read more at docs.oracle.com

 

Handy Gmail search techniques

Amplify’d from email.about.com
    • after: – Search for messages sent after a date. The date must be given in YYYY/MM/DD format.
      Example: “after:2005/05/05” finds all messages sent or received after (and not including) May 5, 2005.

 

    • before: – Search for messages sent before a date.
      Example: “before:2005/05/05” finds all messages sent or received on May 4, 2005 and earlier.

 

    • By default, terms are combined with (an invisible) “AND”.
      Example: “shepherd macaroni” finds all messages that contain both “shepherd” and “macaroni”.

 

    • “” – Search for a phrase. Case does not matter.
      Examples: “shepherd’s macaroni” finds all messages containing the phrase “shepherd’s macaroni”; ‘subject:”shepherd’s macaroni’ finds all messages that have “shepherd’s macaroni” in the Subject field.

 

    • OR – Search for messages containing at least one of two terms or expressions.
      Examples: “shepherd or macaroni” finds messages that contain either “shepherd” or “macaroni” or both; “from:heinz or label:toodoo-doll” finds messages that either come from a sender that contains “email.guide” or appear under the label “toodoo doll”.

 

    • – Search for messages that do not contain a term or expression.
      Examples: “-macaroni” finds all messages that do not contain the word “macaroni”; “shepherd -macaroni” finds all messages that contain the word “shepherd” but not “macaroni”; ‘subject:”shepherd’s macaroni” -from:heinz’ finds all messages with “shepherd’s macaroni” in the subject that were not sent from an email address or name containing “heinz”.

 

    • () – Group search terms or expressions.
      Examples: “subject:(shepherd macaroni)” finds messages that have both “shepherd” and “macaroni” somewhere in the Subject line (but not necessarily as a phrase); “from:heinz (subject:(shepherd OR macaroni) OR label:toodoo-doll)” finds all messages from a sender who has “email.guide” in their name that either have “shepherd” or “macaroni” (or both) in the Subject line or appear under the label “toodoo doll”.

 

    • has:attachment – Search for messages that have files attached to them.

 

Read more at email.about.com