logo
down
shadow

Mule - Object to parameters in Database


Mule - Object to parameters in Database

By : karma tsechoe
Date : November 22 2020, 02:59 PM
will be helpful for those in need Use MEL(Mule Expression Langauge) and standard Java method invocation. As Data is you payload, use #[payload.table_name] MEL will automatically use the getter for that field.
code :


Share : facebook icon twitter icon
Object in mule's registry cannot be cast to org.mule.construct.AbstractFlowConstruct on application startup

Object in mule's registry cannot be cast to org.mule.construct.AbstractFlowConstruct on application startup


By : Prashan Kumar
Date : March 29 2020, 07:55 AM
To fix this issue Feels like a bug: after reading the source code, I find no reasonable explanation to why Mule would try to register your custom object in JMX while mistaking it for a Flow!
As a side note, why using a notification listener and the Mule registry when you can just build your object with Spring?
How to read REST service that returns JSON object and store the same into PostgreSQL using Mule ESB, Mule Studio

How to read REST service that returns JSON object and store the same into PostgreSQL using Mule ESB, Mule Studio


By : Tamas Szeredi
Date : March 29 2020, 07:55 AM
this one helps. Since you want to store the whole JSON, there is no need to deserialize it as an object: I suggest you simply transform the HTTP-streamed payload into a java.lang.String and insert it as-is in the DB.
This would done like that:
code :
<jdbc:postgresql-data-source name="PostgreSQL_Data_Source"
    user="username" password="pwd" url="jdbc:postgresql://localhost:5432/TestDB"
    transactionIsolation="UNSPECIFIED" doc:name="PostgreSQL Data Source" />

<jdbc:connector name="PostgreSQL_Connector" dataSource-ref="PostgreSQL_Data_Source"
    validateConnections="true" queryTimeout="-1" pollingFrequency="0"
    doc:name="Database">
    <jdbc:query key="InsertRecord"
        value="INSERT INTO &quot;AnotherJSonTable&quot;(&quot;StoreJsonObject&quot;) VALUES (CAST(#[message.payload] AS json))" />
</jdbc:connector>

<flow name="testRestFlow1" doc:name="testRestFlow1">
    <http:inbound-endpoint exchange-pattern="request-response"
        address="http://localhost:8082/index.html" doc:name="HTTP" />
    <http:rest-service-component httpMethod="GET"
        serviceUrl="http://localhost:35798/RestServiceImpl.svc/json/567" />
    <object-to-string-transformer />
    <jdbc:outbound-endpoint exchange-pattern="one-way"
        queryKey="InsertRecord" queryTimeout="-1" connector-ref="PostgreSQL_Connector"
        doc:name="Database" />
</flow>
Mule - Set properties on spring object call in Mule flow

Mule - Set properties on spring object call in Mule flow


By : moose
Date : March 29 2020, 07:55 AM
around this issue I'm using Mule 3.3.CE , you can try to configure your spring bean outside the flow as follow:
code :
<spring:bean id="component" name="component"
    class="com.threads.test.SpringObject" lazy-init="false">
    <spring:property name="someData" value="Information" />
</spring:bean>

and inside the flow do:

<component>
    <spring-object bean="component" />
</component>
Mule - how to configure an environment-specific external database in Mule Standalone

Mule - how to configure an environment-specific external database in Mule Standalone


By : user7785797
Date : March 29 2020, 07:55 AM
Hope this helps there are several options
1) You can use two different files for each of the jdbc connectors.
Mule ESB 3.6 Object To XML not working correctly after Database Connector

Mule ESB 3.6 Object To XML not working correctly after Database Connector


By : user3621407
Date : March 29 2020, 07:55 AM
help you fix your problem Success!
After a lot of mucking around (and a crash course in learning XML with Java) and taking Eddu's post above, I was able to create a custom transformer.
code :
import java.io.StringWriter;
import java.util.List;
import java.util.Map;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.mule.api.transformer.TransformerException;
import org.mule.transformer.AbstractTransformer;
import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class SQLCustomerToXML extends AbstractTransformer {

    @SuppressWarnings("unchecked")
    @Override
    protected Object doTransform(Object src, String enc)
        throws TransformerException {

    List<Map<String, Object>> list = (List<Map<String, Object>>) src;
    Document doc;

    try {

        DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
        DocumentBuilder docBuilder = docFactory.newDocumentBuilder();

        // root elements
        doc = docBuilder.newDocument();
        Element rootElement = doc.createElement("Customers");
        doc.appendChild(rootElement);

        for (Map<String, Object> map : list) {
            // New Customer Entry
            logger.info("Customer:");
            Element customerElement = doc.createElement("Customer");
            rootElement.appendChild(customerElement);

            // Each entry in Map for Customer
            for (Map.Entry<String, Object> element : map.entrySet()) {
                logger.info("   " + element.getKey() + ":" + element.getValue().toString());
                Element e = doc.createElement(element.getKey());
                e.setTextContent(element.getValue().toString());
                customerElement.appendChild(e);
            }
        }

        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer = transformerFactory.newTransformer();
        DOMSource source = new DOMSource(doc);

        // Write XML to String
        StringWriter writer = new StringWriter();
        StreamResult result = new StreamResult(writer);
        transformer.transform(source, result);

        logger.info("XML : " + writer.toString());

        return writer.toString();

      } catch (ParserConfigurationException pce) {
        pce.printStackTrace();
      } catch (Exception e) {
        e.printStackTrace();
      }

    return null;
    }
}
<custom-transformer returnClass="java.lang.String" encoding="UTF-8" mimeType="text/xml" class="SQLCustomerToXML" doc:name="Java"/> 
<?xml version="1.0" encoding="UTF-8"?>
<Customers>
    <Customer>
        <CustomerNumber>1</CustomerNumber>
        <CustomerSuburb>Mt Eliza</CustomerSuburb>
        <CustomerStateName>Victoria</CustomerStateName>
        <CustomerAddressLine1>Street name</CustomerAddressLine1>
        <CustomerPostcode>3930</CustomerPostcode>
        <CustomerAddressLine2 />
        <CustomerName>Sarge</CustomerName>
    </Customer>
    <Customer>
        <CustomerNumber>2</CustomerNumber>
        <CustomerSuburb>Balwyn</CustomerSuburb>
        <CustomerStateName>Victoria</CustomerStateName>
        <CustomerAddressLine1>Street name</CustomerAddressLine1>
        <CustomerPostcode>3920</CustomerPostcode>
        <CustomerAddressLine2 />
        <CustomerName>Daniel</CustomerName>
    </Customer>
</Customers>
Related Posts Related Posts :
  • Where date is bigger than in Rails 4 and Postgres
  • Understanding an ER Diagram
  • How to use index in foreign table SELECT MAX(id) query in PostgreSQL?
  • Oracle create table Invalid Name / Constraint
  • how to implement one to one relationship if the relation has attributes?
  • VB .net: How to put a value on a checkbox (databese: MS Access)
  • Oracle specific timestamp format 'DD-MON-RR HH.MI.SSXFF AM'
  • Which Neo4j endpoint is in use in these two cases?
  • Sqlite3: Checking if database is FTS enabled?
  • Oracle event processing. How to insert data into database?
  • How to open Windev HFSQL Fic files
  • Possible sharding existing ArangoDB database?
  • How oracle indexes makes lookup fast
  • ZF2 PDO_IBM Driver with Relational Database Name
  • Python django: filtering a table based on a criteria on another table
  • How to partition an oracle table by a date column?
  • Delphi FireDAC with MS Access 2010 database. Why does it convert ACE to Jet?
  • Creating Excel database to track inventory
  • Retrieve documents from cloudant db if they contain a value in an array property
  • Need help creating a dynamic phone number detector?
  • shadow
    Privacy Policy - Terms - Contact Us © animezone.co