¿Qué importa que algún capitán me ordene coger la escoba y barrer la cubierta?¿Quién no es un esclavo? Decídmelo.
Ismael, en Moby Dick

Java Message Service

Messaging is a method of communication between software components where a Client can send messages to and receive messages from any other Client. Each client connects to a messaging Agent that provides facilities for creating, sending, receiving and reading messages.

  • Loosely coupled, the destination is all that the sender and receiver have in common.
  • Reliable, a message is delivered once and only once, though lower levels of reliability are available.

Java Message Service (JMS) is a Java API defines a common set of interfaces and associated semantics that allow applications written in the Java programming language to communicate with other messaging implementations.

  • Application clients, Enterprise JavaBeans components and web components can send or synchronously receive a JMS Message.
    • Can be set a message listener that allows JMS messages to be delivered to it asynchronously by being notified when a message is available.
  • Message-driven beans enable asynchronous consumption of messages in the EJB container.
    • Applications typically pools message-driven beans to implement concurrent processing of messages.
  • Message send and receive can participate in Java Transaction API (JTA) transactions, which allow JMS operations and database accesses to take place within a single transaction.
  • By accessing the JMS provider through a resource adapter in a Java EE Connector architecture
    • Vendors can create JMS providers that can be plugged in to multiple application servers.
    • Application servers can support multiple JMS providers.

The current release, defined in the JSR-343, is 2.0 and is part of Java EE 7.

JMS API Architecture

JMS API Architecture

A JMS application is composed of the following parts

  • JMS provider is a messaging system that implements the JMS interfaces and provides administrative and control features.
  • JMS clients are the components that produce and consume messages.
  • Messages are the objects that communicate information between the JMS clients.
  • Administered objects are JMS objects configured for the use of clients.
    • Destinations
    • Connection factories
    • Point to Point
    • Publish / Subscriber

Messaging Style

  •  Point to Point
  • Publish / Subscriber

JMS - Messaging Style - Point to Point

JMS - Messaging Style - Publish_Subscriber

Message Consumption

  • Synchronous.
  • Asynchronous, register a message listener with a consumer.

JMS API Programming Model

JMS API Programming Model

The basic building blocks of a JMS application are

  • Administered objects, which are portable (ordinarily defined in a JNDI namespace and injected into JMS clients).
    • Connection Factories, may be ConnectionFactory, QueueConnectionFactory or TopicConnectionFactory.
    • Destinations, objects (queue or topic) a client uses to specify the target of messages it produces and the source of messages it consumes.
    • The behavior of the application will depend on the kind of destination you use and not on the kind of connection factory you use.
  • JMSContext objects, which combine a Connection and a Session in one object
    • A Connection encapsulates a virtual connection with a JMS provider (could represent an open TCP/IP socket between a client and a provider service daemon).
    • A Session is a single-threated context for producing and consuming messages
      • Provides a transactional context with which to group a set of sends and receives into an atomic unit of work.
  • Message producers (JMSProducer), is a lightweight object (so no need to store it) created by a JMSContext or a session and used for sending messages to a destination.
  • Message consumers (JMSConsumer)
    • Can be switched on and off (start / stop).
    • Set a MessageListener for asynchronous messages.
    • Use a Message Selector (a String that contains an expresion) for filtering the messages received.
  • Messages. Can have
    • Header (required): JMSMessageID, JMSCorrelationID, JMSType (TextMessage, MapMessage, BytesMessage, StreamMessage, ObjectMessage, Message), JMSDestination, JMSReplyTo, JMSDeliveryMode, JMSDeliveryTime, JMSExpiration, JMSPriority, JMSTimestamp, JMSRedelivered.
    • Properties (optional), if additional values are needed for compatibility or for filtering (message selectors).
    • Body (optional), each of the 6 possible Message Types has different Message Bodies.

In addition

  • Queue browsers.
  • JMSException is the root class for all checked exceptions in the JMS API, JMSRuntimeException is for all unchecked.

Documentation

Related concepts

  •  MOM Messaging-Oriented Middleware.

Logger Interceptor

Credits go to Ionut Posea.

@Aspect
@Component
class LoggerInterceptor {
    @Around("within(eu.europa.ec.comp.genis.metadata..*)")
    public Object profileSaveMethod(ProceedingJoinPoint call) throws Throwable {
        StopWatch clock = new StopWatch("Profiling:::::" + call.signature + ":::::Args::::::" + call.args );
        try {
            clock.start(call.toShortString());
            return call.proceed();
        } finally {
            clock.stop();
            println(clock.prettyPrint());
        }
    }
}

Drop all tables from an schema in Oracle

I’ve found a nice solution for dropping all the tables from an existing schema in Oracle, described in this question at stackoverflow. The following script :

SELECT 'drop table '||TABLE_NAME||' cascade constraints;' FROM user_tables;

will display the sentences required for dropping all the tables in the current schema.

How to communicate your Product to your customers

product_marketing

WHAT WHY
Product Features Product Benefits
“Here’s what our product can do” “Here’s what you can do with our product”
“1GB storage on your MP3 player” “1000 songs in your pocket”

Read here:

How to learn any language in six months, by Chris Londsdale

YouTube Preview Image

Information that helps achieve Personal Goals has relevance.

We Master Tools by USING tools, we learn tools fastest when they are relevant.

Principles

  1. Focus on language content that is relevant to you.
  2. Use your New Language as a Tool to Communicate From Day 1.
  3. When you first UNDERSTAND the MESSAGE you will unconsciously ACQUIRE the language.
  4. Physically training, the brain filters what we are not familiar with, if your face hurts you are doing it right.
  5. Psycho-physical state.

Actions

  1. Listen A LOT!
  2. Focus on getting the meaning FIRST, use body language, context…
  3. Start MIXING, 10 verbs x 10 nouns x 10 adjectives = 1000 possible phrases.
  4. Focus on the CORE, high frequency language. IE, in english 1000 words covers 85% of daily conversation, 3000 covers 98%.Start with your TOOLBOX, What is that, I don’t understand, please repeat it… Then simple nouns and verbs and adjective, then glue words as prepositions
  5. Get a Language Parent, somebody to help you understand the message, that will work to understand you, use words you know, doesn’t correct mistakes but confirms understanding by using correct language.
  6. Copy the face
  7. Everything you know is really an image in your brain, so instead of associate “Fire” with “Fuego”, you should create a new path in your brain for the image of fire.
Comenta