Skip to content

Mule: support for db:insert component #140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sanagaraj-pivotal opened this issue May 31, 2022 · 0 comments
Closed

Mule: support for db:insert component #140

sanagaraj-pivotal opened this issue May 31, 2022 · 0 comments
Labels

Comments

@sanagaraj-pivotal
Copy link
Contributor

sanagaraj-pivotal commented May 31, 2022

labels: ["in: mule-3.9"]

What needs to be done

Support DB: Insert Component

Sample input and outputs

input
Mule XML

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:db="http://www.mulesoft.org/schema/mule/db" 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/db http://www.mulesoft.org/schema/mule/db/current/mule-db.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd">
    <flow name="dbFlow">
        <http:listener config-ref="HTTP_Listener_Configuration" path="/" doc:name="HTTP"/>
        <logger level="INFO" doc:name="Logger"/>
        <db:insert config-ref="Oracle_Configuration" doc:name="Database">
            <db:parameterized-query><![CDATA[INSERT INTO STUDENTS (NAME, AGE, CITY) VALUES (#[payload.name], #[payload.age], #[payload.city])]]></db:parameterized-query>
        </db:insert>    </flow>
</mule>

java DSL:

package com.example.javadsl;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.integration.dsl.IntegrationFlow;
import org.springframework.integration.dsl.IntegrationFlows;
import org.springframework.integration.handler.LoggingHandler;
import org.springframework.integration.http.dsl.Http;
import org.springframework.util.LinkedMultiValueMap;

@Configuration
public class FlowConfigurations {
    @Bean
    IntegrationFlow dbFlow() {
        return IntegrationFlows.from(Http.inboundChannelAdapter("/")).handle((p, h) -> p)
                .log(LoggingHandler.Level.INFO)
                // TODO: payload type might not be always LinkedMultiValueMap please change it to appropriate type 
                // TODO: mule expression language is not converted to java, do it manually. example: #[payload] etc 
                .<LinkedMultiValueMap<String, String>>handle((p, h) -> {
                    jdbcTemplate.execute("INSERT INTO STUDENTS (NAME, AGE, CITY) VALUES (#[payload.name], #[payload.age], #[payload.city])");
                    return p;
                })
                .get();
    }
}
fabapp2 pushed a commit that referenced this issue Jun 7, 2022
@fabapp2 fabapp2 closed this as not planned Won't fix, can't repro, duplicate, stale Aug 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants