Skip to content

Commit

Permalink
sends excel sheet data
Browse files Browse the repository at this point in the history
  • Loading branch information
ashokap99 committed May 24, 2022
1 parent 7c80025 commit a117168
Show file tree
Hide file tree
Showing 6 changed files with 295 additions and 0 deletions.
48 changes: 48 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# ------------------------------------------------------------------------------ #
# Java defaults (https://github.com/github/gitignore/blob/master/Java.gitignore) #
# ------------------------------------------------------------------------------ #
*.class

# Package Files #
*.jar
*.war
*.ear

# ------------------------------------------------------------------------------------------- #
# Eclipse-specific (https://github.com/github/gitignore/blob/master/Global/Eclipse.gitignore) #
# ------------------------------------------------------------------------------------------- #
*.pydevproject
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.settings/
.loadpath
.project
.classpath

# External tool builders
.externalToolBuilders/

# Locally stored "Eclipse launch configurations"
*.launch

# CDT-specific
.cproject

# PDT-specific
.buildpath

# --------------- #
# Studio-specific #
# --------------- #
target/
.mule/**
.mule/**/*
.DS_Store
velocity.log
3 changes: 3 additions & 0 deletions mule-artifact.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"minMuleVersion": "4.4.0"
}
84 changes: 84 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>com.mycompany</groupId>
<artifactId>syncasnyc</artifactId>
<version>1.0.0-SNAPSHOT</version>
<packaging>mule-application</packaging>

<name>data from excel sheet</name>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>

<app.runtime>4.4.0-20220221</app.runtime>
<mule.maven.plugin.version>3.5.2</mule.maven.plugin.version>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.mule.tools.maven</groupId>
<artifactId>mule-maven-plugin</artifactId>
<version>${mule.maven.plugin.version}</version>
<extensions>true</extensions>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-http-connector</artifactId>
<version>1.6.0</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-sockets-connector</artifactId>
<version>1.2.2</version>
<classifier>mule-plugin</classifier>
</dependency>
<dependency>
<groupId>org.mule.connectors</groupId>
<artifactId>mule-file-connector</artifactId>
<version>1.3.4</version>
<classifier>mule-plugin</classifier>
</dependency>
</dependencies>

<repositories>
<repository>
<id>anypoint-exchange-v2</id>
<name>Anypoint Exchange</name>
<url>https://maven.anypoint.mulesoft.com/api/v2/maven</url>
<layout>default</layout>
</repository>
<repository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<url>https://repository.mulesoft.org/releases/</url>
<layout>default</layout>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>mulesoft-releases</id>
<name>MuleSoft Releases Repository</name>
<layout>default</layout>
<url>https://repository.mulesoft.org/releases/</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>

</project>
95 changes: 95 additions & 0 deletions src/main/mule/syncasnyc.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
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:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="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/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd">
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="8f262c65-e1f1-4178-9351-bcfea2a49570" >
<http:listener-connection host="0.0.0.0" port="8081" />
</http:listener-config>
<file:config name="File_Config" doc:name="File Config" doc:id="a2fc9533-18bf-4a42-b209-d65a5abb5fbe" />
<flow name="excel" doc:id="67870423-7a83-4721-acb5-13c09b0095b8" >
<http:listener doc:name="Listener" doc:id="2e7fefa5-e3a1-4da5-961b-a8be4ee09676" config-ref="HTTP_Listener_config" path="/sendxlx"/>
<set-variable value="#[attributes.queryParams.format]" doc:name="Set Variable" doc:id="f997b6d6-fbb0-498c-9ba0-2ef6fd3c5133" variableName="queryparamformat"/>
<set-variable value="#[attributes.headers.'content-type']" doc:name="Set Variable" doc:id="1eafb803-3e84-4c9a-9628-dffbdfe5294e" variableName="hederformat"/>
<ee:transform doc:name="Transform Message" doc:id="9f058e79-5fe3-45e6-9571-55c0944fae50" >
<ee:message >
</ee:message>
<ee:variables >
<ee:set-variable variableName="requsteddataformat" ><![CDATA[%dw 2.0
output application/json
---
if(isEmpty(vars.queryparamformat)== true )
splitBy(vars.hederformat,'/') [1]
else
vars.queryparamformat
]]></ee:set-variable>
</ee:variables>
</ee:transform>
<file:read doc:id="ef9d9da8-3e52-40c2-88f7-3b69d4ccc1f9" config-ref="File_Config" path="D:\ashok\p\frnds.xlsx" outputMimeType="application/xlsx" doc:name="Read xls data"/>
<choice doc:name="Choice" doc:id="18b5d459-f825-4e56-b9f2-ca00f85519dc" >
<when expression="#[vars.requsteddataformat == 'csv']">
<ee:transform doc:name="csv" doc:id="6064f764-f8d9-4151-a1c8-17103064101c" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/csv
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
</when>
<when expression="#[vars.requsteddataformat == 'xml']">
<ee:transform doc:name="xml" doc:id="47510132-4d3d-40b3-9179-9ff21b841ac8" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
---
{
"btechgroup":
{
"frnds" : payload
}
}]]></ee:set-payload>
</ee:message>
</ee:transform>
</when>
<when expression="#[vars.requsteddataformat == 'json']">
<ee:transform doc:name="json" doc:id="cfc78e3f-c169-401b-b3ca-7c3fa8f2d8f1" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload
]]></ee:set-payload>
</ee:message>
</ee:transform>
</when>
<when expression="#[isEmpty(vars.requsteddataformat)]">
<ee:transform doc:name="json when no format specified" doc:id="2c107162-a698-4460-b1de-e6d291fb65a8" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
</when>
<otherwise >
<ee:transform doc:name="Transform Message" doc:id="11e07fce-cd7e-4cb5-9f8a-cc663c1445bd" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
"message" : "this is default case"
}]]></ee:set-payload>
</ee:message>
</ee:transform>
</otherwise>
</choice>
<logger level="INFO" doc:name="flow ended" doc:id="289f4f91-b57b-4288-bbc4-f0b168fe4b25" message="#[payload]"/>
</flow>
</mule>
34 changes: 34 additions & 0 deletions src/main/resources/log4j2.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<Configuration>

<!--These are some of the loggers you can enable.
There are several more you can find in the documentation.
Besides this log4j configuration, you can also use Java VM environment variables
to enable other logs like network (-Djavax.net.debug=ssl or all) and
Garbage Collector (-XX:+PrintGC). These will be append to the console, so you will
see them in the mule_ee.log file. -->

<Appenders>
<RollingFile name="file" fileName="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}syncasnyc.log"
filePattern="${sys:mule.home}${sys:file.separator}logs${sys:file.separator}syncasnyc-%i.log">
<PatternLayout pattern="%-5p %d [%t] [processor: %X{processorPath}; event: %X{correlationId}] %c: %m%n"/>
<SizeBasedTriggeringPolicy size="10 MB"/>
<DefaultRolloverStrategy max="10"/>
</RollingFile>
</Appenders>

<Loggers>
<!-- Http Logger shows wire traffic on DEBUG -->
<!--AsyncLogger name="org.mule.service.http.impl.service.HttpMessageLogger" level="DEBUG"/-->
<AsyncLogger name="org.mule.service.http" level="WARN"/>
<AsyncLogger name="org.mule.extension.http" level="WARN"/>

<!-- Mule logger -->
<AsyncLogger name="org.mule.runtime.core.internal.processor.LoggerMessageProcessor" level="INFO"/>

<AsyncRoot level="INFO">
<AppenderRef ref="file"/>
</AsyncRoot>
</Loggers>

</Configuration>
31 changes: 31 additions & 0 deletions src/test/resources/log4j2-test.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?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>
<!-- Http Logger shows wire traffic on DEBUG -->
<!--AsyncLogger name="org.mule.service.http.impl.service.HttpMessageLogger" level="DEBUG"/-->
<AsyncLogger name="org.mule.service.http" level="WARN"/>
<AsyncLogger name="org.mule.extension.http" level="WARN"/>

<!-- Reduce startup noise -->
<AsyncLogger name="com.mulesoft.mule.runtime.plugin" level="WARN"/>
<AsyncLogger name="org.mule.maven.client" level="WARN"/>
<AsyncLogger name="org.mule.runtime.core.internal.util" level="WARN"/>
<AsyncLogger name="org.quartz" level="WARN"/>
<AsyncLogger name="org.mule.munit.plugins.coverage.server" level="WARN"/>

<!-- Mule logger -->
<AsyncLogger name="org.mule.runtime.core.internal.processor.LoggerMessageProcessor" level="INFO"/>

<AsyncRoot level="INFO">
<AppenderRef ref="Console"/>
</AsyncRoot>
</Loggers>

</Configuration>

0 comments on commit a117168

Please sign in to comment.