org.jboss.esb.message
Class Message

java.lang.Object
  extended by org.jboss.esb.message.Message
All Implemented Interfaces:
Serializable

public class Message
extends Object
implements Serializable

Message type.

The differences between this Message model and the existing one are small, but I think they are very important from a user perspective. See issues with current message, as I see them.

So we're really just talking about a few tweaks:

  1. It's not Interface based. It's composed of simple Value Objects. No need for Factories etc. Serialization/Deserialization etc are handled orthogonally.
  2. We use "well known" types where possible e.g. Collection types. Apart from the fact that people recognize thse types, it makes the Message easier to work with using expression and scripting languages such as OGNL, Groovy, Jython etc because many of these tools have explicit usability features around Collection types (Map, List, Properties etc).
  3. A single "primary" Object based message body/payload i.e. no setting of the payload based on a name. Binary (byte[]) payloads are supported as Objects. The serialization/deserialization layers can easily detect this.
  4. Addressing information is done using Service Logical names. Low level details (EPRs etc) are hidden under the hood.
  5. All payloads can have associated MIME headers ("Content-Type" etc).

Structure

 Message -|
          |-properties--|
          |             |-<Name Value Pairs>
          |
          |-addressing--|
          |             |-<to, from, replyto etc - Logical names Vs current EPR approach>
          |
          |-body <Primary Payload instance (aka "payload" or "content")>
          |
          |-attachments-|
          |             |-<Map of Payload instances>
          |
          |-fault
 

Message Body - The Primary Payload

A single unnamed (primary) Payload can be attached and retreived from a Message instance via the getBody() and setBody(Payload) methods.

Other payloads can be attached to the message, but only as attachments. This would seem to be in line with the SOAP spec re attachments. This doesn't preclude the primary payload being a collection of items.

We could add a Map of "secondary" message payloads. I think this concept would then be competing with the idea of attachments, leading to confusion. This has happened with the existing Message structure.

Usage

      // Create and populate the message....
      Message message = new Message(myMessageObject);
      message.getAttachments().put("image-01", new Payload(imageBytes, "image/jpeg"));
      ... etc

      // Deliver the message to the target Service...
      ServiceInvoker invoker = new ServiceInvoker("category", "name");
      invoker.deliverAsync(invoker);
      // handle faults etc...
What about message serialization?.

Author:
tom.fennelly@jboss.com
See Also:
Serialized Form

Constructor Summary
Message()
          Construct a message with a blank payload.
Message(Object bodyContent)
          Construct a message with the supplied payload content.
Message(Payload body)
          Construct a message with the supplied payload.
 
Method Summary
 Addressing getAddressing()
          Get Message addressing info.
 Map<String,Payload> getAttachments()
          Message attachments.
 Payload getBody()
          Get the Primary message payload.
 Fault getFault()
          Get Message fault.
 Properties getProperties()
          Message Properties.
 void setBody(Payload body)
          Set the Primary message payload.
 void setFault(Fault fault)
          Set Message fault.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Message

public Message()
Construct a message with a blank payload.


Message

public Message(Payload body)
Construct a message with the supplied payload.

Parameters:
body - The primary message payload.
See Also:
getAttachments()

Message

public Message(Object bodyContent)
Construct a message with the supplied payload content.

This is just a convenient shorthand for:

  Message message = new Message(new Payload(payloadObject));
 

Parameters:
bodyContent - The primary message payload content.
See Also:
getAttachments()
Method Detail

getProperties

public Properties getProperties()
Message Properties.

Simple NVPs.

Returns:
Message properties.

getAddressing

public Addressing getAddressing()
Get Message addressing info.

Returns:
Message addressing.

getBody

public Payload getBody()
Get the Primary message payload.

Returns:
Primary Message payload Object.

setBody

public void setBody(Payload body)
Set the Primary message payload.

Parameters:
body - Primary Message payload Object.

getAttachments

public Map<String,Payload> getAttachments()
Message attachments.

So hopefully this can handle the SOAP Multipart/Attachments usecase.

Returns:
Map of message attachments.

getFault

public Fault getFault()
Get Message fault.

Returns:
The Message Fault, or null if there is none.

setFault

public void setFault(Fault fault)
Set Message fault.

Parameters:
fault - Message Fault, or null if there is none.


Copyright © 2007. All Rights Reserved.