Generate Spring-integration daily statistics report - spring

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();
}

Related

Unable to get DeliverToCompID (Tag128) value on acceptor application in QuickFix/J

I am trying to make the DeliverToCompID (tag128) mandatory on NewOrderSingle Message. I am able to send the message from Banzai with tag128 present, but still getting this --> 58=Required tag missing371=128 error message.
I have declared the DeliverToCompID (tag128) value in the config file
[session]
SocketConnectPort=9878
DeliverToCompID=FIXIMULATOR3
SenderCompID=BANZAI
TargetCompID=FIXIMULATOR
and in Banzai Application I am fetching the value from the config and setting it in the message.
String tag128 = settings.getString(sessionID,"DeliverToCompID");
System.out.println("tag 128 "+tag128);
message.getHeader().setField(new DeliverToCompID(tag128));
and I am sending a NewOrderSingle Message, and TAG 128 is present in the logs of both the banzai(sender) and fiximulator(acceptor) application.
BANZAI LOG <20221111-05:28:39, FIX.4.2:BANZAI->FIXIMULATOR, outgoing> (8=FIX.4.29=15435=D34=749=BANZAI52=20221111-05:28:39.66056=FIXIMULATOR128=FIXIMULATOR311=166814451964721=138=256340=154=155=AAA59=060=20221111-05:28:39.65810=238)
FIXIMULATOR LOG <20221111-05:28:39, FIX.4.2:FIXIMULATOR->BANZAI, incoming> (8=FIX.4.29=15435=D34=749=BANZAI52=20221111-05:28:39.66056=FIXIMULATOR128=FIXIMULATOR311=166814451964721=138=256340=154=155=AAA59=060=20221111-05:28:39.65810=238)
But I am getting this :: <20221111-05:28:39, FIX.4.2:FIXIMULATOR->BANZAI, event> (Message 7 Rejected: Required tag missing:128)
<20221111-05:28:39, FIX.4.2:FIXIMULATOR->BANZAI, outgoing> (8=FIX.4.29=12635=334=749=FIXIMULATOR52=20221111-05:28:39.66456=BANZAI115=FIXIMULATOR345=758=Required tag missing371=128372=D373=110=084)
I have used custom FIX42.xml file
<message name="NewOrderSingle" msgtype="D" msgcat="app">
<field name="DeliverToCompID" required="Y"/>
and in the FIXIMLATOR config I have made
ValidateIncomingMessage=Y
DataDictionary=config/FIX42.xml
UseDataDictionary=Y

Gateway and aggregator - CorrelationStrategy error

I have to access an external service using spring integration. The process is (1) I had to pass an id to get basic information (2) using basic info from step 1, I need to access to more services and merge the information into a singlr object.
integration-graph:
input: Channel1 outputs to : Channel1Out
I have recipient list router that puts message to the 2 channels Channel2 and Channel3.
Channel2 and Channel3's output channels use a xml xpath-transformer
and output to Channel 4
<int:aggregator id="aggregatorChannel"
correlation-strategy-expression="headers['jms_messageId']"
release-strategy-expression="size() == 2" method="mergeVO"
input-channel="channel4" output-channel="dest-channel">
<bean class="n.b.lbr.eai.vo.PojoAggregator"></bean>
</int:aggregator>
This is giving error.
java.lang.IllegalStateException: Null correlation not allowed. Maybe the CorrelationStrategy is failing?
at org.springframework.util.Assert.state(Assert.java:70) ~[spring-core-4.3.8.RELEASE.jar:4.3.8.RELEASE]
at org.springframework.integration.aggregator.AbstractCorrelatingMessageHandler.handleMessageInternal(AbstractCorrelatingMessageHandler.java:385) ~[spring-integration-core-4.3.9.RELEASE.jar:4.3.9.RELEASE]
I did see some posts on this topic, but I do not understand how to solve the below error
{
"timestamp": 1533137160301,
"status": 500,
"error": "Internal Server Error",
"exception": "java.lang.IllegalStateException",
"message": "Null correlation not allowed. Maybe the CorrelationStrategy is failing?",
"path": "/w/b/search/11223"
}
please suggest, if this is a design issue or how to solve this problem
EDIT1:
Is the below valid scatter gather?
<bean id="messageStore" class="org.springframework.integration.store.SimpleMessageStore"/>
<int:scatter-gather id="scatterGather2" input-channel="drBInputChannel" gather-channel="gatherChannel" gather-timeout="5000">
<int:scatterer id="myScatterer" apply-sequence="true">
<int:recipient channel="bserviceInputChannel"/>
<int:recipient channel="aserviceInputChannel"/>
</int:scatterer>
<int:gatherer id="myGatherer"
**??**
message-store="messageStore"
correlation-strategy=**??**
release-strategy-expression="size() == 2"
>
<bean class="nd.wbr.eai.vo.PojoAggregator"></bean>
</int:gatherer>
</int:scatter-gather>
I need help to convert to xml and use in the above
#Bean
public MessageHandler gatherer() {
return new AggregatingMessageHandler(
***new ExpressionEvaluatingMessageGroupProcessor("^[payload gt 5] ?:-1D"),***
new SimpleMessageStore(),
***new HeaderAttributeCorrelationStrategy(
IntegrationMessageHeaderAccessor.CORRELATION_ID),***
new ExpressionEvaluatingReleaseStrategy("size() == 2"));
}
The "java.lang.IllegalStateException: Null correlation not allowed. Maybe the CorrelationStrategy is failing?" exception means that your correlation-strategy-expression="headers['jms_messageId']" doesn't produce anything meaningful. To be precise there is just no jms_messageId header in the message.
Not sure why you did such a choice for the correlation key, but there is definitely not going to be such a headers when you perform HTTP request. You may emulate it though, but it might be better to choose some other correlation strategy.
On the other hand, looking to your original task description, I would say that you need to take a look into the Scatter-Gather pattern and stop to worry about correlation key altogether!

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?

Refer spring batch job parameters within internal map

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.

Resources