INVOKE COMPONENT DEMO IN MULE
The Invoke component invokes a method of an object
defined in a Spring bean. You can provide an array of
argument expressions to map the message to the
method arguments. Mule determines which method to
use via the method name, along with the number of
argument expressions provided.
Configuring the Java Class
• Use the Invoke component when you have an existing
method defined in custom Java code that you wish to use
in processing a message.
• Create a new Mule project. Click File > New > Mule
Project and name the project demo.
• Create a new Java class. In Package Explorer, right-
click src/main/java and click New > Class.
Http configuration and global element
Create mule flow like below
Invoke component configuration
Create a class src/main/java
Name the class InvokeDemo.
Create java class like below
Class here
• package invokedemo;
• public class InvokeDemo {
• public String starCall(String name) {
• return String.format("Hello %s!", name);
• }
• public String endCall(String name) {
• return String.format("Goodbye %s!", name);
• }
• }
CreateYour Spring Bean
To reference your Java, Mule requires a Spring bean to declare the class path.
Click on global element and create Bean like below
Run As Mule application
• And type this url on browser, we can get the following
result
• http://localhost:8081/call?name=krishna
• Hello krishna!

Invoke component demo in mule

  • 1.
    INVOKE COMPONENT DEMOIN MULE The Invoke component invokes a method of an object defined in a Spring bean. You can provide an array of argument expressions to map the message to the method arguments. Mule determines which method to use via the method name, along with the number of argument expressions provided.
  • 2.
    Configuring the JavaClass • Use the Invoke component when you have an existing method defined in custom Java code that you wish to use in processing a message. • Create a new Mule project. Click File > New > Mule Project and name the project demo. • Create a new Java class. In Package Explorer, right- click src/main/java and click New > Class.
  • 3.
    Http configuration andglobal element
  • 4.
    Create mule flowlike below
  • 5.
  • 6.
    Create a classsrc/main/java
  • 7.
    Name the classInvokeDemo.
  • 8.
  • 9.
    Class here • packageinvokedemo; • public class InvokeDemo { • public String starCall(String name) { • return String.format("Hello %s!", name); • } • public String endCall(String name) { • return String.format("Goodbye %s!", name); • } • }
  • 10.
    CreateYour Spring Bean Toreference your Java, Mule requires a Spring bean to declare the class path. Click on global element and create Bean like below
  • 11.
    Run As Muleapplication • And type this url on browser, we can get the following result • http://localhost:8081/call?name=krishna • Hello krishna!