Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7882917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:23:55+00:00 2026-06-03T04:23:55+00:00

With Mule scripting, I am able to access a Mule Message in Groovy, JavaScript

  • 0

With Mule scripting, I am able to access a Mule Message in Groovy, JavaScript and Jython via a message variable. With JRuby I cannot:

undefined local variable or method `message' for main:Object (NameError)

Neither the Mule docs or the Internets have anything to say on this. How can I access the message from Ruby?

Code

<scripting:transformer name="SetData" doc:name="Set Data">
    <scripting:script engine="jruby">
        <scripting:text><![CDATA[File.open('/tmp/foo', 'w') { |f| f.puts message.payload }]]></scripting:text>
    </scripting:script>
</scripting:transformer>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T04:23:56+00:00Added an answer on June 3, 2026 at 4:23 am

    Mule bound variables end up in the global scope, so you need to refer them with $name.

    In your case:

    <scripting:transformer name="SetData" doc:name="Set Data">
        <scripting:script engine="jruby">
            <scripting:text><![CDATA[
               File.open('/tmp/foo', 'w') { |f| f.puts $message.payload }
            ]]></scripting:text>
        </scripting:script>
    </scripting:transformer>
    

    Note that if you only need the message payload, you’d rather use $payload instead of $message.payload.

    Also your transformer looks more like a component IMO: it acts on the data (writes to file) instead of transforming it. It doesn’t even have a clear return value (you sure don’t want to process the return of File.open in Mule. So a scripting:component would be more in order here.

    Finally, if all you need to do is write to file, you can use a File outbound endpoint from Mule that does just that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Mule 3.2.1, I want to pass a Mule Message or Mule Event to
I have a jruby/rails app using: jruby 1.4.0 Rails 2.3.5 ActiveMQ 5.3.0 Mule ESB
I would like to be able to create some directories after Mule has started,
I am using a java class as a mule endpoint that writes a message
Mule has many endpoints, components, etc. for example like http:rest-service-component. How do I know
We're securing Mule services using the Spring Security Framework, and some of the services
I have an outgoing http endpoint in Mule 3.2.1. As a response to my
I'm trying to get the FROM email address in Mule ESB. I'm getting the
I am new to mule. Are there any way to call CXF based web
I am attempting to create an inbound Mule endpoint that will receive Syslog messages

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.