pass query to execute to a jdbc component - spring-integration

How can I have a jdbc channel adapter of gateway to execute a query that is passed through input message or its properties. Not sure if there a way to use query this way. So instead of below
<int-jdbc:outbound..
query="select * from ...."
...
I would like to have something like
<int-jdbc:outbound...
query="payload.sqlQuery"
..>
Thank you for your help.
We have a flow where the adapter need to run various queries as specified by request so i can not put the query there.

No, it isn't possible by adapters. They aren't designed for such a low-level protocol linking. It breaks a bit messaging principles.
If you really need so generic behavior of the Integration endpoint, consider to use JdbcTemplate directly from some POJO and refer it to the <service-activator>.

Related

Service Fabric IServiceRemotingRequestMessageBody Iterate Parameters

Edited left name of a custom type instead of the direct service fabric interface.
I am trying to write an interceptor capable of interrogating the parameters being passed to a remoting service. I can intercept the IServiceRemotingRequestMessage once it gets to the service and am able extract the parameters, but ONLY if I know the position and name of the parameter at the time.
[Pseudo]
var someParam = IServiceRemotingRequestMessageBody.GetParameter(0, "request", serviceRequestInfo.RequestMessage.GetBody().GetType());
What I need is a way to simply iterate the parameters and work with them directly (currently just serialize them to a string so I can log some of the info being passed). However, the IServiceRemotingRequestMessageBody only exposes a GetParameter method that must be passed the index and the name...
I can maybe do some reflection work given the method name and the service contract but I'm hoping there is a much more straightforward way to get this directly.
Thanks for any tips,
Will
There may be an easier way using the default serialization, but the way I solved it, currently, is to replace the Service Fabric serialization providers with JSON Serialization. Then, my interceptors can work with the JSON data as necessary.
I'll assume there is a way to do something similar with the default serialization but, if so, it's not clearly documented how to work with it. If someone proposes an option I would gladly give it a try.

Pass parameters from C# function app to another Javascript function app in Azure

I need to set up an application in Azure and make communicate 2 functions (one written in C# and one written in JavaScript).
The C# fragment consists in analyzing a XML feed, get the data and save in objects then finally send them to the other JavaScript function by parameter.
I did read that we could establish communication between both functions using HTTP calls but is it possible to do it with parameters ?
If not, would have any suggestions in order to achieve something like this properly? I'm getting started with Azure and i don't have enough visibility to know what is recommened in such a situation
Thank you for your advices
Yes, this is absolutely possible. How you do this is up to you. If you look at the default HTTP trigger templates, you can see that they take parameters (for example, as query string parameters). You can find more examples in the HTTP and webhook recipes documentation.
You can use other trigger types for cross-function communication as well. Take a look at this documentation for related best practices: https://learn.microsoft.com/en-us/azure/azure-functions/functions-best-practices#cross-function-communication

spring integration multiple stored procedure enricher pattern

I am new to spring integration. I have very specific requirement.
I have two Database to fetch.
Created two SP.
I have to get the data calling their respective stored procedure and create a JAXB object to make webservice call.
I am able to call one SP but not able to call 2nd SP. I think I can use enricher pattern but dont know how to configure.
Please help.
Well, trying to answer to your so broad question I only may suggest:
Configure <int-jdbc:stored-proc-outbound-gateway> to call first SP
Configure <int:enricher> with a request-channel for sub-flow to call the second SP similar way like a previous one
with this <int:enricher> you will be able to store additional info in some your Customer model property (which is payload) or headers
And so on until WS call.
Everything rest you can find in the Spring Integration Reference Manual and samples project.
UPDATE
I still need help.
Since it looks like you still don't understand Spring Integration principles properly, I'd suggest you to have one <service-activator> and call both stored procedures in custom code using Spring JDBC directly.
Eventually with an experience you will be able to refactor it really to separate components with the <enricher> on board.
OTOH your scenario recalls me Scatter-Gather pattern.

Database polling using spring integration

I am new to the Spring integration. Previously I developed an application using Weblogic Integration where I poll a database table for any new rows. If there is one, I obtain that data, modify it and send it to a different database. I have seen several examples on Spring integration where it integrates web pages, emails etc. I want to set up a poll for a table and get the message to the gateway from where I can handle it. Any help or advice is appreciated.
This example is the basic Db poller..
<int-jdbc:inbound-channel-adapter query="select * from item where status=2"
channel="target" data-source="dataSource"
update="update item set status=10 where id in (:id)" />
For channel 'target', you can put your service-activator to handle message.. You may also need a row-mapper..
Tell me more about your problem if you need more advice.,
See the inbound-channel-adapter in the reference documentation and/or the jdbc sample.
The sample doesn't show the use of the adapter, but it might help you with a general understanding of Spring Integration. Another useful resource is the test cases... integration tests and polling* parser tests.

Using OData to execute a remote Domain Service method

As far as I got it so far, OData is more meant to consume data, i.e. in a read-only manner. I want to ask whether it's intended to use OData to invoke remote functions, for example a Domain Service's method.
When looking at the OData 4.0 spec, chapter 4.3 "Addressing Entities", there are indeed terminologies like actionCall, entityFunctionCall etc. But this so far is of course also only meant for "serving", I assume.
I'd like to do something like http://example.org/service/BankAccountDomainService/ApproveBankAccount(abcde-123456)... Does that make sense?
If I understand you correctlu, you want to invoke an unbound action, which is called "Action Import" since your action "ApproveBankAccount" does not bounded to any type....
According to the Odata Protocol, the folloding URL should be "POST": the "Account" should be included in Payload.
URL: http://example.org/service/BankAccountDomainService/ApproveBankAccount()
Payload: { abcde-123456 }
Aternatively, you can also design bounded action "Approve" on entity type "BankAccount", the posted URL should be:
http://example.org/service/BankAccountDomainService/BankAccount(abcde-12345)/NameSpace.Approve()
OData is a standardized protocol for creating and consuming data APIs. OData builds on core protocols like HTTP and commonly accepted methodologies like REST. The result is a uniform way to expose full-featured data APIs.
Except providing functions and actions bound to entities, OData also provides service level functions and actions.
Please reference this URL for the sample:
https://aspnet.codeplex.com/SourceControl/latest#Samples/WebApi/ODataActionsSample/
But it is based on OData v3, and there will soon be samples for OData v4.

Resources