Skip to content

Instantly share code, notes, and snippets.

View adrianhsieh's full-sized avatar

Adrian Hsieh adrianhsieh

  • Adaptive Connections
View GitHub Profile
@adrianhsieh
adrianhsieh / quartz.inbound.xml
Created July 12, 2012 04:09
quartz inbound endpoint to generate event
<quartz:inbound-endpoint jobName="masterclock" cronExpression="0 0/1 * * * ?" repeatInterval="0" responseTimeout="10000" doc:name="Quartz">
<quartz:event-generator-job/>
</quartz:inbound-endpoint>
@adrianhsieh
adrianhsieh / synccontrolsprocs.sql
Created July 12, 2012 05:42
Simple sync control sprocs
CREATE DEFINER=`iappsandbox`@`%` PROCEDURE `set_sync_control`(uname varchar(255))
BEGIN
UPDATE blogdemo.sync_control SET isrunning=true WHERE username=uname AND isrunning = false;
SELECT ROW_COUNT() AS syncset;
END
CREATE DEFINER=`iappsandbox`@`%` PROCEDURE `release_sync_control`(uname varchar(255))
BEGIN
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:jdbc-ee="http://www.mulesoft.org/schema/mule/ee/jdbc" xmlns:zuora="http://www.mulesoft.org/schema/mule/zuora" xmlns:context="http://www.springframework.org/schema/context" xmlns:quartz="http://www.mulesoft.org/schema/mule/quartz" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:spring="http://www.springframework.org/schema/beans" xmlns:core="http://www.mulesoft.org/schema/mule/core" xmlns:data-mapper="http://www.mulesoft.org/schema/mule/ee/data-mapper" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="EE-3.3.0" xsi:schemaLocation="
http://www.mulesoft.org/schema/mule/ee/jdbc http://www.mulesoft.org/schema/mule/ee/jdbc/current/mule-jdbc-ee.xsd
http://www.mulesoft.org/schema/mule/zuora http://www.mulesoft.org/schema/mule/zuora/1.0/mule-zuora.xsd
http://www.mulesoft.org/schema/mule/quartz http://www.mulesoft.org/sch
@adrianhsieh
adrianhsieh / zmulti-tenant.xml
Created July 12, 2012 07:16
multi-tenant ops call
<zuora:find config-ref="Zuora" zquery="SELECT ID,Amount,InvoiceNumber,DueDate,Comments FROM Invoice WHERE Status='Posted' AND TransferredToAccounting = null AND Amount &gt; 0" username="#[header:outbound:zuser]" password="#[header:outbound:zuser]" doc:name="ZuoraInvoices"/>
@adrianhsieh
adrianhsieh / jdbc_config_bean.xml
Created September 22, 2012 18:24
jdbc config
<spring:bean id="datasource" name="datasource" class="org.enhydra.jdbc.standard.StandardDataSource" destroy-method="shutdown">
<spring:property name="driverName" value="org.apache.derby.jdbc.EmbeddedDriver"/>
<spring:property name="url" value="jdbc:derby:memory:blogdemo"/>
</spring:bean>
@adrianhsieh
adrianhsieh / DBInitialization.java
Created September 22, 2012 19:28
DBInitialization class to initialize in-memory database
package org.mule.blogdemo.init;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.Statement;
import org.springframework.beans.factory.InitializingBean;
public class DBInitialization implements InitializingBean {
public void afterPropertiesSet() throws Exception {
@adrianhsieh
adrianhsieh / dbinitialization.xml
Created September 22, 2012 19:30
Spring bean for in-memory db initialization
<spring:bean id="dbinitialization" name="dbinit" class="org.mule.blogdemo.init.DBInitialization"/>
@adrianhsieh
adrianhsieh / jdbc_connector.xml
Created September 22, 2012 19:49
JDBC Connector Config
<jdbc-ee:connector name="apache-derby" dataSource-ref="datasource" validateConnections="false" queryTimeout="-1" pollingFrequency="0" doc:name="Database">
<jdbc-ee:query key="insertRecord" value="INSERT INTO table1 (Name, External_ID__c, Value__c, Last_Modified) VALUES (#[map-payload:name], #[map-payload:externalid], #[map-payload:value], #[map-payload:lastmodified])"/>
<jdbc-ee:query key="selectRecord" value="SELECT Name, External_ID__c, Value__c FROM table1 ORDER BY Last_Modified"/>
</jdbc-ee:connector>
@adrianhsieh
adrianhsieh / demo_flow.xml
Created September 22, 2012 21:26
Demo how to select records sorted
<flow name="mainFlow" doc:name="mainFlow" processingStrategy="synchronous">
<file:inbound-endpoint path="src/test/resources" moveToDirectory="src/test/archives" responseTimeout="10000" doc:name="Input File"/>
<jdbc-ee:csv-to-maps-transformer ignoreFirstRecord="true" doc:name="CSV to Maps" mappingFile="src/main/resources/mules-csv-format.xml"/>
<foreach doc:name="Foreach">
<logger message="#[payload]" level="INFO" doc:name="csv record" />
<jdbc-ee:outbound-endpoint exchange-pattern="one-way" queryKey="insertRecord" queryTimeout="-1" connector-ref="apache-derby" doc:name="insert-record"/>
</foreach>
<jdbc-ee:outbound-endpoint exchange-pattern="request-response" queryKey="selectRecord" queryTimeout="-1" connector-ref="apache-derby" doc:name="select records"/>
<sfdc:upsert config-ref="salesforce" externalIdFieldName="External_ID__c" type="Demo_Object__c" doc:name="upsert.record.in.salesforce">
<sfdc:objects ref="#[payload]"/>
@adrianhsieh
adrianhsieh / sample_input.csv
Created September 22, 2012 21:31
sample csv input file
name externalid value lastmodified
order1 1 10 2012-09-22 13:40:00.00
order1 1 1 2012-09-22 10:00:00.00
order1 1 5 2012-09-22 11:00:00.00