Refer spring batch job parameters within internal map - spring

I'm trying to refer to a spring batch job parameter within inner map (that i created).
No luck until now ,
The error message that i get is :
EL1043E:(pos 20): Unexpected token. Expected 'identifier' but was 'lcurly({)'
The expression that I'm trying to evaluate is :
#{fragmentsMap[#{jobParameters['message.source']}]}
The Map is :
<util:map id="fragmentsMap">
<entry key="dfg" value="ABC" /></util:map>
The Item Reader that I'm trying to config is :
<bean id="eventItemReader" class="org.springframework.batch.item.xml.StaxEventItemReader" scope="step"
p:fragmentRootElementName="#{fragmentsMap[#{jobParameters['message.source']}]}"
p:resource="file:/#{jobParameters['message.input']}"
p:unmarshaller-ref= "itemUnmarshaller"/>
I would appreciate any advice.

Related

Generate Spring-integration daily statistics report

Have a spring integration application where files are routed from a folder to S3 buckets using s3-outbound-channel-adapter. If the file processed successfully, then file will be moved to corresponding target-bucket. if any error , file move to error bucket via error channel.
Have to generate a daily statistics report in a text file containing below details.
Total no of files processed:
Total success :
Total Error:
Would like to know how to get no of files processed successfully/error. Is there any way to achieve this requirement.
Any suggestion or example would be helpful.
Gone through the DefaultMessageChannelMetrics and Micrometer Integration in documentation. Not sure it will help my requirement.
Have separate gateway and adapter to process success and error files.
Success :
<int-aws:s3-outbound-gateway id="s3FileMover"
request-channel="filesOutS3GateWay"
reply-channel="filesOutS3ChainChannel"
transfer-manager="transferManager"
bucket-expression = "headers.TARGET_PATH"
key-expression="headers.file_name"
command="UPLOAD">
<int-aws:request-handler-advice-chain>
<ref bean="retryAdvice" />
</int-aws:request-handler-advice-chain>
</int-aws:s3-outbound-gateway>
Error :
<int-aws:s3-outbound-channel-adapter id="filesErrorS3Mover"
channel="filesErrorS3MoverChannel"
transfer-manager="transferManager"
bucket="${aws.s3.error.bucket}"
key-expression="headers.TARGET + '/' + headers.file_name"
upload-metadata-provider = "fileMetaDataProvider"
command="UPLOAD">
<int-aws:request-handler-advice-chain>
<bean class="org.springframework.integration.handler.advice.ExpressionEvaluatingRequestHandlerAdvice">
<property name="onSuccessExpressionString" value="payload.delete()"/>
</bean>
</int-aws:request-handler-advice-chain>
You can query and reset the MessageChannelMetrics directly on the message channels directly.
getSendCount();
reset();
All standard message channels implement that interface so just inject the channel as that...
#Autowired
private MessageChannelMetrics filesOutS3GateWay;
private int getCount() {
return this.filesOutS3GateWay.getSendCount();
}

Mule: Invoking an Oracle stored procedure which returns a table of custom type

I am using Mule CE 3.6.1. I have the following Database connector configuration calling an Oracle stored procedure.
<db:stored-procedure config-ref="Oracle_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[call get_phone_email(:userId, :tPhoneRecord)]]></db:parameterized-query>
<db:in-param name="userId" type="NUMERIC" value="#[payload]" />
<db:out-param name="tPhoneRecord" type="ARRAY" />
</db:stored-procedure>
Parameter tPhoneRecord is defined as IS TABLE OF phone_email%ROWTYPE (i.e. table of records) in the stored procedure. I have tried specifying the parameter type ARRAY but get the error:
Message : Invalid argument(s) in call (java.sql.SQLException). Message payload is of type Object[]
Code : MULE_ERROR--2
I have also tried using other out-param types or not specifying a type without success.
Please let me know what out-param type I should use for an Oracle table of records, or if I should do this in Java instead. Many thanks in advance.
You can use the below solution for out parameter.
<db:oracle-config name="Oracle_Configuration" url="jdbc:oracle:thin:#54.175.245.218:1581:xe" user="user" password="4321" >
</db:oracle-config>
<db:data-type name="INtypename" id="12"/>
<!-- VARCHAR id=12 -->
<db:data-type name="OUTtypename" id="2002"/>
<!-- STRUCT id=2002 -->
</db:data-types>
...
<db:stored-procedure config-ref="Generic_Database_Configuration" doc:name="Database">
<db:parameterized-query><![CDATA[CALL storedprocfnc(:INtypename,:OUTtypename);]]></db:parameterized-query>
<db:in-param name="INtypename" value="#[payload]"/>
<db:out-param name="OUTtypename" />
</db:stored-procedure>

WSO2 Filter Proxy Boolean Expression evaluator issue

in my proxy i'm using a filter mediator. My target is to activate a sequence if some conditions on some properties are verified:
codice = 0
idElementoCross is different from null or empty string or if it exists
tipoElementoCross is different from null or empty string or if it exists
i wrote this condition:
<sequence>
<property name="codice" expression="//codice"></property>
<property name="idElementoCross" expression="//idElementoCross"></property>
<property name="tipoElementoCross" expression="//tipoElementoCross"></property>
<filter xpath="boolean(fn:get-property('codice')=0 and fn:get-property('tipoRisposta')='worker' and fn:get-property('tipoElementoCross')!='null' and fn:get-property('idElementoCross')!='null' and fn:get-property('tipoElementoCross')!='' and fn:get-property('idElementoCross')!='' and fn:get-property('tipoElementoCross') and fn:get-property('idElementoCross'))">
<then> ...
but in my log i see that esb enter the sequence even if idElementoCross and tipoElementoCross are empty.
Im using WSO2 ESB 4.8.1.
What am i missing?
This is because when there is no value, //tipoElementoCross return the node and not the text value :
send <tipoElementoCross></tipoElementoCross>
//tipoElementoCross = <tipoElementoCross></tipoElementoCross>
//tipoElementoCross/text() =

Glade error: <id> is not accessible

This is my first question on stackoverflow.
I searched over the web to no avail, and I really can't figure out what's wrong, so here we go.
I am trying to add a dialog window to Marionnet. The window information is mostly contained in the glade file, with some bits modified from code. lablgtk is the framework that allows gtk2 (and thus glade-generated files) to be used with the ocaml language.
The application is successfully compiled, however it generates this runtime error at launch:
(marionnet.byte:5384): libglade-CRITICAL **: glade_xml_build_interface: assertion `wid != NULL' failed
Fatal error: exception Failure("Glade error: GtkDialog:dialog_RELATIVIZATION is not accessible.")
Raised at file "pervasives.ml", line 22, characters 22-33
Called from file "gui.ml", line 617, characters 9-85
Called from file "gui/gui_menubar_MARIONNET.ml", line 356, characters 17-49
Called from unknown location
Called from unknown location
The error suggests that the class constructor doesn't exist or something like that, but I checked multiple times and I didn't spot any typo in the identifiers I used. What am I missing here? What does the exception actually mean?
To prove that there are no typos or missing identifiers, I'll show you the file contents.
The file gui.ml is generated by lablgladecc2, which reads the contents of gui.xml (the glade file). This is an extract from gui.xml:
<widget class="GtkDialog" id="dialog_RELATIVIZATION">
<property name="visible">True</property>
<property name="title" translatable="yes">Relativization</property>
<property name="resizable">False</property>
<property name="modal">True</property>
<property name="destroy_with_parent">True</property>
<property name="icon">marionnet-launcher.png</property>
<property name="type_hint">dialog</property>
<child internal-child="vbox">
[...]
So the id "dialog_RELATIVIZATION" is there. Indeed, the generated gui.ml file has the correct class and method:
[...]
class dialog_RELATIVIZATION ?(file="gui.glade.patched") ?domain ?autoconnect(*=true*) () =
let xmldata = Glade.create ~file ~root:"dialog_RELATIVIZATION" ?domain () in
object (self)
inherit Glade.xml ?autoconnect xmldata
val toplevel =
new GWindow.dialog_any (GtkWindow.Dialog.cast
(Glade.get_widget_msg ~name:"dialog_RELATIVIZATION" ~info:"GtkDialog" xmldata))
method toplevel = toplevel
val dialog_RELATIVIZATION =
new GWindow.dialog_any (GtkWindow.Dialog.cast
(Glade.get_widget_msg ~name:"dialog_RELATIVIZATION" ~info:"GtkDialog" xmldata))
method dialog_RELATIVIZATION = dialog_RELATIVIZATION
[...]
This is the code where I try to access the window:
let rel_dialog = new Gui.dialog_RELATIVIZATION () in
rel_dialog#toplevel#set_title (s_ "Relativization");
rel_dialog#label_frequency#set_label (s_ "Frequency");
rel_dialog#label_convergence#set_label (s_ "Convergence");
rel_dialog#checkb_existing_machines#set_label (s_ "Apply to existing machines");
Google didn't help me, and I did not find good documentation about lablgtk. Does anyone know what the exception means and what the cause could be?

camel-mybatis - issues with calling Oracle Stored procedure with multiple resultsets

I am using camel-mybatis (version 2.12) component in Fuse 6.1 environment to invoke an oracle SP with 2 resultsets. The request is a HashMap and once mybatis maps the resultsets to java beans, the List is again saved in the original HashMap itself.
Here is the snippet of SqlMap:
<select
id="searchUsers"
parameterType="java.util.HashMap"
statementType="CALLABLE">
{call ORACLE.SP_NAME_1(
#{userId,mode=IN,jdbcType=VARCHAR},
#{maxResultsCount,mode=IN,jdbcType=DECIMAL},
#{view,mode=IN,jdbcType=VARCHAR},
#{statusInfo,mode=OUT,jdbcType=CURSOR,resultMap=statusInfoRowMap},
#{memberInfo,mode=OUT,jdbcType=CURSOR,resultMap=claimInfoRowMap})}
And here is how I invoke the mybatis component:
<setBody>
<groovy>
[
userId:'ID-1234',
maxResultsCount:20,
view:'MEMBER',
]
</groovy>
</setBody>
<to uri="mybatis:searchUsers?statementType=SelectOne" />
Since there are no result object (all the results are stored in the original requested HashMap itself), MyBatisProducer is setting null to exchange OUT message. The original body which contains the results from stored procedure is lost.
The Question is: is this the expected behaviour? mybatis component already stores the result in exchange header, so why to update the body as well?
The workaround I had to do was - to store the original body to a header, invoke mybatis and reset body from the header (which has the stored procedure result now) :
<setBody>
<groovy>
[
userId:'ID1234',
maxResultsCount:20,
view:'MEMBER'
]
</groovy>
</setBody>
<setHeader headerName="originalRequest">
<simple>${body}</simple>
</setHeader>
<to uri="mybatis:searchUsers?statementType=SelectOne" />
<setBody>
<simple>${in.headers.originalRequest}</simple>
</setBody>
<log message="status: ${body[statusInfo]}" />
Any help would be appreciated.. Thanks.
Ah well spotted. Log a JIRA ticket so we can improve this and avoid setting the body to null, when you use a stored procedure.
There is a link to the issue tracker here
http://camel.apache.org/support

Resources