0

What I want to do seems simple, but all of the info I'm finding looks like overkill.

I have a message with a Hash for payload. It can have any number of fields.

All I want to do is make 1 additional entry in the hash.

(I'm trying to copy one hash entry to another name via MEL. I'd even be happy to rename the entry. Actually all I'm really trying to do is change the case of key from "Foobar" to "foobar")

The "Set Payload" replaces the entire payload, not what I want.

The "Message Enricher" wants to call other processors, etc, not what I need.

"Data Mapper" was the other item I looked at, it looks like you can go from Map -> Map, but I don't understand how to tell it "copy this 1 field (or rename it), but leave everything else as-is."

Mark Bennett
  • 1,446
  • 2
  • 19
  • 37

1 Answers1

1

If you want to work with the payload and add values to it without replacing the entire payload, you could use the expression-component - http://www.mulesoft.org/documentation/display/current/Expression+Component+Reference.

You can then use any MEL/MVEL or Java syntax to modify your map. A simple example:

 <expression-component>
    payload.put('foobar', 'abc');
    payload.remove('Foobar');
 </expression-component>
Ryan Carter
  • 11,441
  • 2
  • 20
  • 27
  • Thank you so much! For other readers/searchers, the final expression was: payload.put( 'id', payload.get('Id') ); What I was trying to do was map records retrieved from SalesForce via SOQL into Solr 4.x using schemaless. But even schemaless still wants "id" to be present, and wants it as lowercase. You *could* tweak schema.xml prior to bringing the core up for the first time, but then you'd have a very atypical setup; best to just rename Id -> id – Mark Bennett Apr 22 '14 at 22:39