I need a basic Mule flow in order to select rows from one database, transform the payload and call a procedure in another database. I don't want to use DataMapper component, I would like to use Java Transformer instead.
My XML flow:
<set-variable variableName="currentOrder" value="#[payload.increment_id]" doc:name="Variable"/>
<db:select config-ref="MySQL_Configuration" doc:name="GET ORDER">
<db:parameterized-query><![CDATA[select id from sales where id=#[currentOrder]]]></db:parameterized-query>
</db:select>
<custom-transformer class="com.mycompany.transformers.TargerProc" doc:name="Java"/>
<db:stored-procedure config-ref="Oracle_Configuration" doc:name="PROC1">
<db:parameterized-query><![CDATA[call proc1(:P1,:P2)]]></db:parameterized-query>
<db:in-param name="P1" type="NUMERIC" value="#[payload.id]"/>
<db:out-param name="P2" type="NUMERIC" value=""/>
</db:stored-procedure>
First problem:
Message payload is of type: CaseInsensitiveHashMap
Could someone shed some light on this? I think it is really simple to achieve this.
Thanks in advance!
Try this <db:parameterized-query>{ call proc1(:P1,:P2) }</db:parameterized-query> :-
<set-variable variableName="currentOrder" value="#[payload.increment_id]" doc:name="Variable"/>
<db:select config-ref="MySQL_Configuration" doc:name="GET ORDER">
<db:parameterized-query><![CDATA[select id from sales where id=#[currentOrder]]]></db:parameterized-query>
</db:select>
<custom-transformer class="com.mycompany.transformers.TargerProc" doc:name="Java"/>
<db:stored-procedure config-ref="Oracle_Configuration" doc:name="PROC1">
<db:parameterized-query>{ call proc1(:P1,:P2) }</db:parameterized-query>
<db:in-param name="P1" type="NUMERIC" value="#[payload.id]"/>
<db:out-param name="P2" type="NUMERIC" value=""/>
</db:stored-procedure>
Related
I've got a problem with using method with parameters in Camel XML DSL.
What I've done is something like this:
I've created below bean before my camelContext
<bean id="properties" class="java.util.Properties"/>
The thing I would like to do is using method 'put' from HashTable, which extends Properties.
When I call a method without parameter it's working perfectly fine.
<method ref="properties" method="NAME OF METHOD THAT HAS NO PARAMETERS">
or
<bean ref="properties" method="SAME AS ABOVE"/>
Method that I'm trying to use:
public synchronized V put(K key, V value)
But when I'm trying to use something like the code below I would like to assign some parameters
I've tried a lot of possibilities, maybe it's impossible or my knowledge of syntax is poor:
<method ref="properties" method="put" argument="key_el" arugment="val_el"/>
<method ref="properties" method="put" value="key_el" value="val_el"/>
<method ref="properties" method="put?keyEl&valEl"/>
<method ref="properties" method="put">
<argument id="key" value="someKey" type="java.lang.String"/>
<argument id="value" value="someValue" type="java.lang.String"/>
</method>
There's plenty more that I've tired, some of them are just not worth of showing. I read from people apache and camel documentation, that there's possibility to make it somehow but there was no example of doing that in XML DSL.
Thanks in advance for any hints and help.
You can call beans method with arguments using method="put('key', 'value')". You can also use simple syntax there if you need values from the Exchange like body, headers or exchange properties `method="put('bodyValue', ${body})"``
This approach also works with simple language. Say if you have object stored in to message header you can call it's methods using ${headers.helloBean.hello('Tim')}
<bean id="ExampleProperties" class="java.util.Properties" />
<camelContext xmlns="http://camel.apache.org/schema/spring">
<route id="testRoute">
<from uri="direct:testRoute" />
<bean ref="ExampleProperties" method="put('bodyValue', ${body})" />
<setBody>
<simple>${bean:ExampleProperties?method=get('bodyValue')}</simple>
</setBody>
<log message="Body value: ${body}" />
</route>
</camelContext>
Be careful when storing values to beans instead of using body, headers or exchange properties as beans persist between exchanges.
I have a requirement to change a field from double to Double in hybris typeSystem and was wondering if it actually creates a new database field or just changes the type in app layer.
Thanks in advance.
After the items.xml change and system update the data base field remained the same type. All reads and write are from the same column. So, the answer to my question is no, the column type does not change in database. Only the application layer (model) has changed the field from double to Double.
You have the mapping in core-advanced-deployment.xml.
The mapping depends on DB :
<type-mapping type="java.lang.Double" persistence-type="decimal(30,8)" />
<type-mapping type="double" persistence-type="decimal(30,8) DEFAULT 0" />
or:
<type-mapping type="java.lang.Double" persistence-type="double" />
<type-mapping type="double" persistence-type="double default 0" />
or:
<type-mapping type="java.lang.Double" persistence-type="float" />
<type-mapping type="double" persistence-type="float default 0" />
So you see that it's currently map that's why you can do that and you don't see change in the DB.
Note that changing a type is strongly discouraged because you can switch to uncompatble type. For instance if you have a column of String you can't migrate it to Number for example because a string is not always parseable in a number.
I create this repository:
<gsa-template>
<item-descriptor name="indirizzo" >
<table name="INDIRIZZO" type="primary" id-column-name="ID_INDIRIZZO">
<property name="via" data-type="string" column-name="VIA" />
<property name="civico" data-type="int" column-name="CIVICO" />
</table>
</item-descriptor>
<item-descriptor name="utente" >
<table name="UTENTE" type="primary" id-column-name="ID_UTENTE">
<property name="nome" data-type="string" column-name="NOME" />
<property name="cognome" data-type="string" column-name="COGNOME" />
<property name="indirizzi" data-type="list" component-item-type="indirizzo" />
</table>
</item-descriptor>
In the Java class I want to add a new user with a multiple address. Then I want to use the Java API repository. I tried this:
MutableRepositoryItem item_utente = getMutableRepository().createItem(
UTENTE);
MutableRepositoryItem item_indirizzo = getMutableRepository().createItem(
INDIRIZZO);
item_indirizzo.setPropertyValue(VIA, v1);
item_indirizzo.setPropertyValue(CIVICO, civ1);
getMutableRepository().addItem(item_indirizzo);
item_indirizzo.setPropertyValue(VIA, v2);
item_indirizzo.setPropertyValue(CIVICO, civ2);
getMutableRepository().addItem(item_indirizzo);
item_utente.setPropertyValue(NOME, n);
item_utente.setPropertyValue(COGNOME, c);
item_utente.setPropertyValue(INDIRIZZI, item_indirizzo);
getMutableRepository().addItem(item_utente);
but it does not work, I SUPPOSE because I did not create an actual java list.
I want to insert in my DB an user with respective 2 or more addresses.
Some different idea or do I fix my code?
If your datatype is list, you can add items using an xml just like you do for primitive data types with comma separated values as below:
<add-item item-descriptor="utente" id="test1">
<set-property name="nome" value="testNome"/>
<set-property name="cognome" value="testCognome"/>
<set-property name="indirizzi" value="test2,test3,test4"/>
</add-tem>
Take look at below page for more details.
http://docs.oracle.com/cd/E24152_01/Platform.10-1/ATGRepositoryGuide/html/s1302setproperty01.html
create the List of Repository item .
List<RepositoryItem> item_indirizzo_List=new ArrayList<RepositoryItem>();
add item to the list. And then add like below
item_utente.setPropertyValue(INDIRIZZI, item_indirizzo_List);
May be this will help you.
Hi all I'm new in Mule so please go easy on me. First of all I will show you example on SOAP UI:
Here is WSDL FILE: wsdl file
Its pretty easy. I want to make exacly the same mule flow (no input data etc - payload set in code). The problem is that I simple even can't start. I read tutorial:
http://www.mulesoft.org/documentation/display/current/XML-only+SOAP+Web+Service+Example
But still I can't do dataMappings like here. Any idea what I'm doing wrong my whole flow isn't big ... now its look like this:
<flow doc:name="PostRequest" name="PostRequest">
<http:inbound-endpoint exchange-pattern="request-response" host="localhost" port="8081" path="getPostRequest" doc:name="HTTP" />
<cxf:jaxws-client operation="PostRequest" doc:name="SOAP"
enableMuleSoapHeaders="true" clientClass="pl.execon.integration.axpppk.ws.client.XISGateway"
port="XISGatewaySoap" />
<http:outbound-endpoint address="http://localhost:8889/Service/XISGateway.asmx" />
<object-to-string-transformer doc:name="Object to String" />
</flow>
I want to use PostRequest ... Any advices ? Tutorials that can help ? Problem is that I need to make this envelope modification:
<soap:Body>
<m:PostRequest>
<m:_requestCode>Test</m:_requestCode>
<m:GetGasCustTable>
<m:XMLDocumentTime>2014-07-21T12:24:50</m:XMLDocumentTime>
<m:CustAccount>00043280</m:CustAccount>
</m:GetGasCustTable>
</m:PostRequest>
</soap:Body>
And I Simply don't know how
If want to use post and map a webservice just use pattern this is a working code for post method:
<pattern:web-service-proxy name="webserviseName">
<inbound-endpoint address="http://localhost:8081/localUWant" exchange-pattern="request-response"/>
<outbound-endpoint address="http://localhost:8889/Service/XISGateway.asmx" exchange-pattern="request-response"/>
</pattern:web-service-proxy>
As simple as that.
this is the documentation: http://www.mulesoft.org/documentation/display/current/Using+Mule+Configuration+Patterns
I have a problem where one mule component transform the payload object into some other value. Ex: Suppose my payload contain student object.
Initial value of Student name=a;
My first mule component change student name to x;
Student s=new Student();
s.setName("x");
My second mule component receive name as X from payload. But I want original value as 'a'.
I tried checking original payload of mule but that value is also changed..
<flow .....
<component> </component> // 1st component
<component></component> //2nd component
</flow>
I want same payload(original) (Student object with name a) in both the component..how can I do that?
I have checked original payload and that has been transformed..
Thanks
You can use <all> to send same payload to different components like
<flow .....
<all>
<component> </component> // 1st component
<component></component> //2nd component
</all>
</flow>
or, a different way to approach same thing is to store the original payload in a variable and then replace the payload with the previous one like:
<set-variable variableName="originalPayload" value="#[message.payload]" />
and then,
<set-payload value="#[flowVars.originalPayload]"/>
Mule also use scatter gather component, which sends the payload to multiple endpoints in parallel. This component has been introduced from Mule 3.5.0 ..
example :
<scatter-gather doc:name="Scatter-Gather" timeout="6000">
<flow-ref name="flightBroker1" />
<flow-ref name="flightBroker2" />
<flow-ref name="flightBroker3" />
</scatter-gather>
Here is the reference :- https://developer.mulesoft.com/docs/display/current/Scatter-Gather