Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Messages > Generic Implementation

Generic Implementation

Framework provides a concrete implementation of the Message interface called GenericMessage. You can create an instance of GenericMessage using one of the two provided constructors—one with payload and the other with payload and header properties. However, you are strongly advised to use a utility class MessageBuilder instead. The following snippet demonstrates this:

// Create payload object
Account a = new Account();

// creating a map with header properties
Map<String, Object> accountProperties
  = new HashMap<String, Object>();

// Set our header properties
accountProperties.put("ACCOUNT_EXPIRY","NEVER");

// Use MessageBuilder class to create a Message
// and set header properties

Message<Account> m = 
  MessageBuilder.withPayload(a)
  .setHeader("ACCOUNT_EXPIRY", "NEVER")
  .build();

  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint