BAEL-1254 Getting Started With Mule ESB (#3153)
This commit is contained in:
parent
67c9b1e86f
commit
ba566a81cb
|
@ -0,0 +1 @@
|
|||
# Add any directories, files, or patterns you don't want to be tracked by version control
|
|
@ -0,0 +1 @@
|
|||
DEFAULT_PARTITION
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<mule-project xmlns="http://www.mulesoft.com/tooling/project" runtimeId="org.mule.tooling.server.3.9.0.ee" schemaVersion="5.3.0.0">
|
||||
<name>muleesb</name>
|
||||
<description></description>
|
||||
</mule-project>
|
|
@ -0,0 +1,214 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.mycompany</groupId>
|
||||
<artifactId>muleesb</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<packaging>mule</packaging>
|
||||
<name>Mule muleesb Application</name>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
|
||||
<mule.version>3.8.1</mule.version>
|
||||
<mule.tools.version>1.2</mule.tools.version>
|
||||
<munit.version>1.3.6</munit.version>
|
||||
<mule.munit.support.version>3.9.0</mule.munit.support.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.mule.tools.maven</groupId>
|
||||
<artifactId>mule-app-maven-plugin</artifactId>
|
||||
<version>${mule.tools.version}</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<copyToAppsDirectory>true</copyToAppsDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.mule.tools</groupId>
|
||||
<artifactId>muleesb-maven-plugin</artifactId>
|
||||
<version>1.0</version>
|
||||
<configuration>
|
||||
<muleVersion>3.7.0</muleVersion>
|
||||
<applications>/home/abir/AnypointStudio/workspace/variablescopetest</applications>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>deploy</id>
|
||||
<goals>
|
||||
<goal>start</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>1.7</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-resource</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>add-resource</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src/main/app/</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>mappings/</directory>
|
||||
</resource>
|
||||
<resource>
|
||||
<directory>src/main/api/</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>com.mulesoft.munit.tools</groupId>
|
||||
<artifactId>munit-maven-plugin</artifactId>
|
||||
<version>${munit.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>test</id>
|
||||
<phase>test</phase>
|
||||
<goals>
|
||||
<goal>test</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<coverage>
|
||||
<runCoverage>true</runCoverage>
|
||||
<formats>
|
||||
<format>html</format>
|
||||
</formats>
|
||||
</coverage>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>src/test/munit</directory>
|
||||
</testResource>
|
||||
<testResource>
|
||||
<directory>src/test/resources</directory>
|
||||
</testResource>
|
||||
</testResources>
|
||||
</build>
|
||||
|
||||
<!-- Mule Dependencies -->
|
||||
<dependencies>
|
||||
<!-- Xml configuration -->
|
||||
<dependency>
|
||||
<groupId>org.mule.modules</groupId>
|
||||
<artifactId>mule-module-spring-config</artifactId>
|
||||
<version>${mule.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Mule Transports -->
|
||||
<dependency>
|
||||
<groupId>org.mule.transports</groupId>
|
||||
<artifactId>mule-transport-file</artifactId>
|
||||
<version>${mule.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mule.transports</groupId>
|
||||
<artifactId>mule-transport-http</artifactId>
|
||||
<version>${mule.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mule.transports</groupId>
|
||||
<artifactId>mule-transport-jdbc</artifactId>
|
||||
<version>${mule.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mule.transports</groupId>
|
||||
<artifactId>mule-transport-jms</artifactId>
|
||||
<version>${mule.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mule.transports</groupId>
|
||||
<artifactId>mule-transport-vm</artifactId>
|
||||
<version>${mule.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- Mule Modules -->
|
||||
<dependency>
|
||||
<groupId>org.mule.modules</groupId>
|
||||
<artifactId>mule-module-scripting</artifactId>
|
||||
<version>${mule.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mule.modules</groupId>
|
||||
<artifactId>mule-module-xml</artifactId>
|
||||
<version>${mule.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- for testing -->
|
||||
<dependency>
|
||||
<groupId>org.mule.tests</groupId>
|
||||
<artifactId>mule-tests-functional</artifactId>
|
||||
<version>${mule.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.mule.modules</groupId>
|
||||
<artifactId>mule-module-apikit</artifactId>
|
||||
<version>${mule.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mulesoft.munit</groupId>
|
||||
<artifactId>mule-munit-support</artifactId>
|
||||
<version>${mule.munit.support.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.mulesoft.munit</groupId>
|
||||
<artifactId>munit-runner</artifactId>
|
||||
<version>${munit.version}</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>Central</id>
|
||||
<name>Central</name>
|
||||
<url>http://repo1.maven.org/maven2/</url>
|
||||
<layout>default</layout>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>mulesoft-releases</id>
|
||||
<name>MuleSoft Releases Repository</name>
|
||||
<url>http://repository.mulesoft.org/releases/</url>
|
||||
<layout>default</layout>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>mulesoft-release</id>
|
||||
<name>mulesoft release repository</name>
|
||||
<layout>default</layout>
|
||||
<url>http://repository.mulesoft.org/releases/</url>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</project>
|
|
@ -0,0 +1,6 @@
|
|||
#** GENERATED CONTENT ** Mule Application Deployment Descriptor
|
||||
#Mon Nov 06 15:54:37 BDT 2017
|
||||
redeployment.enabled=true
|
||||
encoding=UTF-8
|
||||
domain=default
|
||||
config.resources=variablescopetest.xml
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<mule xmlns:vm="http://www.mulesoft.org/schema/mule/vm" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
|
||||
xmlns:spring="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
|
||||
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
|
||||
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
|
||||
http://www.mulesoft.org/schema/mule/vm http://www.mulesoft.org/schema/mule/vm/current/mule-vm.xsd">
|
||||
<http:listener-config name="HTTP_Listener_Configuration" host="localhost" port="8081" doc:name="HTTP Listener Configuration"/>
|
||||
<flow name="Flow">
|
||||
<http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP" allowedMethods="POST"/>
|
||||
<logger message="Original paylaod: #[payload]" level="INFO" doc:name="Logger"/>
|
||||
<custom-transformer class="com.baeldung.transformer.InitializationTransformer" doc:name="Java"/>
|
||||
<logger message="Payload After Initialization: #[payload]" level="INFO" doc:name="Logger"/>
|
||||
<set-variable variableName="f1" value="#['Flow Variable 1']" doc:name="F1"/>
|
||||
<set-session-variable variableName="s1" value="#['Session variable 1']" doc:name="S1"/>
|
||||
|
||||
<vm:outbound-endpoint exchange-pattern="request-response" path="test" doc:name="VM"/>
|
||||
</flow>
|
||||
<flow name="Flow1">
|
||||
<vm:inbound-endpoint exchange-pattern="request-response" path="test" doc:name="VM"/>
|
||||
<custom-transformer encoding="ISO-8859-2" class="com.baeldung.transformer.InvokingMessageComponent" doc:name="Java"/>
|
||||
<logger message="Payload after Java Component : #[payload]" level="INFO" doc:name="Logger"/>
|
||||
<set-variable variableName="f2" value="#['Flow Variable 2']" doc:name="F2"/>
|
||||
<set-session-variable variableName="s2" value="#['Session Variable 2']" doc:name="S2"/>
|
||||
<flow-ref name="Flow2" doc:name="Flow2"/>
|
||||
|
||||
<logger message="Payload: Returned form flow 2: #[payload] . Variables: Flow var and Session vars : S1-#[sessionVars.s1], S2-#[sessionVars.s2] ,F1-#[flowVars.f1], F2-#[flowVars.f2],F3-#[flowVars.f3]" level="INFO" doc:name="Logger"/>
|
||||
</flow>
|
||||
<flow name="Flow2">
|
||||
<component class="com.baeldung.transformer.FromFlow2Component" doc:name="Java"/>
|
||||
<logger message="In Flow 2: Flow Variables :: #[flowVars.f1],#[flowVars.f2] and Session Variabless: #[sessionVars.s1] ,#[sessionVars.s2]" level="INFO" doc:name="Logger"/>
|
||||
<set-variable variableName="f3" value="#['Flow Variable 3 ']" doc:name="F3"/>
|
||||
</flow>
|
||||
</mule>
|
|
@ -0,0 +1,18 @@
|
|||
package com.baeldung.transformer;
|
||||
|
||||
import org.mule.api.MuleEventContext;
|
||||
import org.mule.api.MuleMessage;
|
||||
import org.mule.api.lifecycle.Callable;
|
||||
|
||||
public class FromFlow2Component implements Callable {
|
||||
|
||||
@Override
|
||||
public Object onCall(MuleEventContext eventContext) throws Exception {
|
||||
|
||||
MuleMessage message = eventContext.getMessage();
|
||||
message.setPayload("Converted in flow 2");
|
||||
|
||||
return message;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.baeldung.transformer;
|
||||
|
||||
import org.mule.api.MuleMessage;
|
||||
import org.mule.api.transformer.TransformerException;
|
||||
import org.mule.api.transport.PropertyScope;
|
||||
import org.mule.transformer.AbstractMessageTransformer;
|
||||
|
||||
public class InitializationTransformer extends AbstractMessageTransformer {
|
||||
|
||||
@Override
|
||||
public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
String payload = null;
|
||||
|
||||
try {
|
||||
payload = message.getPayloadAsString();
|
||||
}catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
System.out.println("Logged Payload: "+payload);
|
||||
message.setPayload("Payload from Initialization");
|
||||
message.setProperty("outboundKey", "outboundpropertyvalue",PropertyScope.OUTBOUND);
|
||||
|
||||
|
||||
return message;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.baeldung.transformer;
|
||||
|
||||
import org.mule.api.MuleMessage;
|
||||
import org.mule.api.transformer.TransformerException;
|
||||
import org.mule.transformer.AbstractMessageTransformer;
|
||||
|
||||
public class InvokingMessageComponent extends AbstractMessageTransformer {
|
||||
|
||||
@Override
|
||||
public Object transformMessage(MuleMessage message, String outputEncoding) throws TransformerException {
|
||||
// TODO Auto-generated method stub
|
||||
String InboundProp = (String) message.getInboundProperty("outboundKey");
|
||||
System.out.println("InboundProp:" + InboundProp);
|
||||
return InboundProp;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Configuration>
|
||||
<Appenders>
|
||||
<RollingFile name="file" fileName="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}variablescopetest.log"
|
||||
filePattern="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}variablescopetest-%i.log">
|
||||
<PatternLayout pattern="%d [%t] %-5p %c - %m%n" />
|
||||
<SizeBasedTriggeringPolicy size="10 MB" />
|
||||
<DefaultRolloverStrategy max="10"/>
|
||||
</RollingFile>
|
||||
</Appenders>
|
||||
<Loggers>
|
||||
<!-- CXF is used heavily by Mule for web services -->
|
||||
<AsyncLogger name="org.apache.cxf" level="WARN"/>
|
||||
|
||||
<!-- Apache Commons tend to make a lot of noise which can clutter the log-->
|
||||
<AsyncLogger name="org.apache" level="WARN"/>
|
||||
|
||||
<!-- Reduce startup noise -->
|
||||
<AsyncLogger name="org.springframework.beans.factory" level="WARN"/>
|
||||
|
||||
<!-- Mule classes -->
|
||||
<AsyncLogger name="org.mule" level="INFO"/>
|
||||
<AsyncLogger name="com.mulesoft" level="INFO"/>
|
||||
|
||||
<!-- Reduce DM verbosity -->
|
||||
<AsyncLogger name="org.jetel" level="WARN"/>
|
||||
<AsyncLogger name="Tracking" level="WARN"/>
|
||||
|
||||
<AsyncRoot level="INFO">
|
||||
<AppenderRef ref="file" />
|
||||
</AsyncRoot>
|
||||
</Loggers>
|
||||
</Configuration>
|
|
@ -0,0 +1,40 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<mule xmlns:mock="http://www.mulesoft.org/schema/mule/mock" xmlns="http://www.mulesoft.org/schema/mule/core"
|
||||
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
|
||||
xmlns:munit="http://www.mulesoft.org/schema/mule/munit" xmlns:spring="http://www.springframework.org/schema/beans"
|
||||
xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:test="http://www.mulesoft.org/schema/mule/test"
|
||||
xsi:schemaLocation="http://www.mulesoft.org/schema/mule/mock http://www.mulesoft.org/schema/mule/mock/current/mule-mock.xsd
|
||||
http://www.mulesoft.org/schema/mule/munit http://www.mulesoft.org/schema/mule/munit/current/mule-munit.xsd
|
||||
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
|
||||
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
|
||||
http://www.mulesoft.org/schema/mule/test http://www.mulesoft.org/schema/mule/test/current/mule-test.xsd">
|
||||
<munit:config name="munit" doc:name="MUnit configuration" />
|
||||
|
||||
<spring:beans>
|
||||
<spring:import resource="classpath:variablescopetest.xml" />
|
||||
</spring:beans>
|
||||
|
||||
<munit:test name="variablescopetest-test-suite-FlowTest"
|
||||
description="Test">
|
||||
<mock:when messageProcessor="vm:outbound-endpoint" doc:name="VM">
|
||||
<mock:with-attributes>
|
||||
<mock:with-attribute name="path" whereValue="test"/>
|
||||
</mock:with-attributes>
|
||||
<mock:then-return payload="#['Converted in flow 2']"/>
|
||||
</mock:when>
|
||||
|
||||
<flow-ref name="Flow" doc:name="Flow-ref to Flow" />
|
||||
<munit:assert-on-equals message="Flow variable doesn't have the actual value"
|
||||
expectedValue="#['Flow Variable 1']" actualValue="#[flowVars.f1]"
|
||||
doc:name="Assert Equals" />
|
||||
</munit:test>
|
||||
<munit:test name="variablescopetest-test-suite-Flow1Test"
|
||||
description="Test">
|
||||
<flow-ref name="Flow1" doc:name="Flow-ref to Flow1" />
|
||||
</munit:test>
|
||||
<munit:test name="variablescopetest-test-suite-Flow2Test" description="Test">
|
||||
<flow-ref name="Flow2" doc:name="Flow-ref to Flow2"/>
|
||||
</munit:test>
|
||||
</mule>
|
|
@ -0,0 +1,35 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<Configuration>
|
||||
<Appenders>
|
||||
<Console name="Console" target="SYSTEM_OUT">
|
||||
<PatternLayout pattern="%-5p %d [%t] %c: %m%n"/>
|
||||
</Console>
|
||||
</Appenders>
|
||||
|
||||
<Loggers>
|
||||
|
||||
<!-- CXF is used heavily by Mule for web services -->
|
||||
<AsyncLogger name="org.apache.cxf" level="WARN"/>
|
||||
|
||||
<!-- Apache Commons tend to make a lot of noise which can clutter the log-->
|
||||
<AsyncLogger name="org.apache" level="WARN"/>
|
||||
|
||||
<!-- Reduce startup noise -->
|
||||
<AsyncLogger name="org.springframework.beans.factory" level="WARN"/>
|
||||
|
||||
<!-- Mule classes -->
|
||||
<AsyncLogger name="org.mule" level="INFO"/>
|
||||
<AsyncLogger name="com.mulesoft" level="INFO"/>
|
||||
|
||||
<!-- Reduce DM verbosity -->
|
||||
<AsyncLogger name="org.jetel" level="WARN"/>
|
||||
<AsyncLogger name="Tracking" level="WARN"/>
|
||||
|
||||
<!--AsyncLogger name="httpclient.wire" level="ALL" /-->
|
||||
|
||||
<AsyncRoot level="INFO">
|
||||
<AppenderRef ref="Console"/>
|
||||
</AsyncRoot>
|
||||
</Loggers>
|
||||
|
||||
</Configuration>
|
Loading…
Reference in New Issue