As per the official Camel document, "Expressions and Predicates can then be used to create the various Enterprise Integration Patterns in the DSL or Xml Configuration like the Recipient List.
To support dynamic rules Camel supports pluggable Expression strategies using a variety of different Languages."
Could anyone please elaborate or explain it in plain English?
Expressions are used to return any value from the current message exchange. An example of an expression would be using Xpath to retrieve a node from the XML in the body of a message. When the documentation says pluggable strategies, its essentially saying you can use different approaches / languages, including Groovy, JavaScript, etc. A predicate is a specialized expression used to evaluate a condition on the message exchange. It is similar to the condition you would find in a Java if statement. A predicate always returns a Boolean value.
Here's a code example where a message is coming from ActiveMQ and based on the XPath predicate, the message gets routed to another queue.
from("activemq:queue:ORDER_ITEM_PROCESSING").
choice().
when().xpath("/o:Order/o:OrderType/o:FulfillmentCenter = '" +
com.pluralsight.orderfulfillment.generated.FulfillmentCenter.ABC_FULFILLMENT_CENTER.value()
+ "'", namespace).to("activemq:queue:ABC_FULFILLMENT_REQUEST")
Hope this helps.
Related
When I run query with parameter Param<LocalDateTime>, using directly SQLServer2012Templates everything works fine.
[DEBUG] [||] com.querydsl.sql.AbstractSQLQuery, shows generated query with '?', but as I understand, it is not query sent to the SQL Server.
When the same query is run thru QuerydslR2dbcRepository I get exception:
o.r2dbc.mssql.ExceptionFactory$MssqlBadGrammarException: [102] [S0001] Incorrect syntax near '?'
dependencies:
implementation 'org.springframework.data:spring-data-r2dbc'
implementation 'io.r2dbc:r2dbc-mssql'
implementation 'com.infobip:infobip-spring-data-r2dbc-querydsl-boot-starter:7.0.0'
How to fix this?
The R2DBC spec team explicitly decided against following the JDBC syntax for bind parameter placeholders, see this discussion on the mailing list, which I've raised. This means that all JDBC based libraries either:
Have to support R2DBC explicitly, and implement the vendor specific per-driver syntax themselves
Won't support R2DBC bind variables (inline values are still possible, of course)
From what I discovered (and documented on said mailing list), the syntax is, at least:
-- Oracle and others
SELECT * FROM t WHERE id = :1
SELECT * FROM t WHERE id = :name
-- SQL Server
SELECT * FROM t WHERE id = #name
-- PostgreSQL
SELECT * FROM t WHERE id = $1
Your simplest options are thus:
Send a feature request to QueryDSL
Patch the generated SQL on the QueryDSL level or R2DBC level, or some other level, replacing all standalone ? markers by $n (this will be tricky with a regex, a simple parser that can recognise comments, string literals, etc. is probably required)
Work with R2DBC directly
I am building an application using Mule 4.2.2 version where in I have to retrieve data from Mongo DB. For this I am using the MongoDB connector version 6.3.0. I am using the "Find Documents" as show in the image below, where you can see I have mentioned the query as
{"eventCode": $[vars.eventCode]} where eventCode is the field on which I am querying and eventCode is the variable where I am storing the incoming eventCode.
When I run the mule application I see an error in the logs that says -
org.bson.json.JsonParseException: Invalid JSON input. Position: 15. Character: '#'.
I thought that I could combine literals and mule expressiong using #[], but that doesn't seem to work. Any pointers on how to solve this?
If it is an expression, then you can not use #[...] inside. Just write the expression:
{"eventCode": vars.eventCode}
If it is not an expression -if the fx button clicked?- you might need to enclose the entire expression into #[...].
#[{"eventCode": vars.eventCode}]
I'm looking for some assistance in debugging a REGEXP_REPLACE() statement.
I have been using an online regular expressions editor to build expressions, and then the SF regexp_* functions to implement them. I've attempted to remain consistent with the SF regex implementation, but I'm seeing an inconsistency in the returned results that I'm hoping someone can explain :)
My intent is to replace commas within the text (excluding commas with double-quoted text) with a new delimiter (#^#).
Sample text string:
"Foreign Corporate Name Registration","99999","Valuation Research",,"Active Name",02/09/2020,"02/09/2020","NEVADA","UNITED STATES",,,"123 SOME STREET",,"MILWAUKEE","WI","53202","UNITED STATES","123 SOME STREET",,"MILWAUKEE","WI","53202","UNITED STATES",,,,,,,,,,,,
RegEx command and Substitution (working in regex101.com):
([("].*?["])*?(,)
\1#^#
regex101.com Result:
"Foreign Corporate Name Registration"#^#"99999"#^#"Valuation Research"#^##^#"Active Name"#^#02/09/2020#^#"02/09/2020"#^#"NEVADA"#^#"UNITED STATES"#^##^##^#"123 SOME STREET"#^##^#"MILWAUKEE"#^#"WI"#^#"53202"#^#"UNITED STATES"#^#"123 SOME STREET"#^##^#"MILWAUKEE"#^#"WI"#^#"53202"#^#"UNITED STATES"#^##^##^##^##^##^##^##^##^##^##^##^#
When I try and implement this same logic in SF using REGEXP_REPLACE(), I am using the following statement:
SELECT TOP 500
A.C1
,REGEXP_REPLACE((A."C1"),'([("].*?["])*?(,)','\\1#^#') AS BASE
FROM
"<Warehouse>"."<database>"."<table>" AS A
This statement returns the result for BASE:
"Foreign Corporate Name Registration","99999","Valuation Research",,"Active Name",02/09/2020,"02/09/2020","NEVADA","UNITED STATES",,,"123 SOME STREET",,"MILWAUKEE","WI","53202","UNITED STATES","123 SOME STREET",,"MILWAUKEE","WI","53202","UNITED STATES"#^##^##^##^##^##^##^##^##^##^##^##^#
As you can see when comparing the results, the SF result set is only replacing commas at the tail-end of the text.
Can anyone tell me why the results between regex101.com and SF are returning different results with the same statement? Is my expression non-compliant with the SF implementation of RegEx - and if yes, can you tell me why?
Many many thanks for your time and effort reading this far!
Happy Wednesday,
Casey.
The use of .*? to achieve lazy matching for regexing is limited to PCRE, which Snowflake does not support. To see this, in regex101.com, change your 'flavor" to be anything other than PCRE (PHP); you will see that your ([("].*?["])*?(,) regex no longer achieves what you are expecting.
I believe that this will work for your purposes:
REGEXP_REPLACE(A.C1,'("[^"]*")*,','\\1#^#')
I tried to get value from query or to specify values, as soon as the parameter is multi value i can't see the data when i'm trying to make my subscription.
my request looks like :
select id from employee where canal in(#canal)
what should i do, i'm totally stuck,
when i did research i saw data driven subscription but i don't have access to it apparently, don't know if that help
I'll start by saying sorry this isn't a pleasant answer. You've run into a limitation with the built-in functionality. Thankfully there are workarounds.
The problem is that you can only pass 1 value into the data-driven subscription. So you have use a comma-separated list and get the query/report to parse out the values.
If you have or can create a Split function in your database, that is a good option. This would be a table-valued user defined function and there are some easy to find examples already. Also this function is generally good to have for other use cases anyway. With this your SQL would read:
where canal in Split(#canal)
SSRS works really well with SQL Server, but when you use an ODBC connection, the parameter support is limited. You can use the same multi-value parameter workaround that is required in those cases.
In the Dataset properties > parameters tab, use an expression like this to combine the values into a single comma-separated string surrounded by commas.
="," + Join(Parameters!canal.Value, ",") + ","
The SQL would look like this:
where # like '%,' + canal + ',%'
Basically, this searches row-by-row for values that are contained in the string.
In either case, the query in your data-driven subscription settings will need to return the comma-separated string. Then you can select that column in the report parameters value field. Hope this helps!
I am looking for a solution based on flink, the situation is that I have a trans stream and some rules which can be expressed as SQL, I want to update the stream after query(if matched ruleSql1 set this transEvent respCode = 01; if matched ruleSql2 then set this transEvent respCode = 02; respCode has priority).
The question is:
By flink sql I can get a result, but how to feedback the result to original stream, the output I expected is original stream with different respCode.
I have a lot of rules, how to merge the result.
Flink's operators have streams coming in, and transformed streams coming out. It's not clear exactly what you want -- but whether you want to modify each event to add a field with the response code, or something else, it's easily done. If you are using SQL, simply describe the output you want in the SELECT clause.
You can use split/select to make n copies of your stream, and then apply one of your rules (expressed as a SQL query) to each of these parallel copies. Then you can use union to merge them back together (provided they are all of the same type).
You'll find the documentation on split, select, and union in this section of the docs.
The Flink training site has a sequence of hands-on exercises that you may find helpful in learning how the pieces of the API fit together, though none that use split/select/union.