Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.Questo contenuto non è disponibile nella lingua selezionata.
3.19. Using an MVEL Expression
- To use an MVEL expression on a rule set, divide the Regex rules and place them in two separate
.properties
files. - Drop these rules into the example
rules
directory. - Put the MVEL expression in a
.csv
file, also in therules
directory.The customer-related Regex rules that go in thecustomer.properties
file look like this:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Insert the product-related Regex rule in the
product.properties
file:Product data rules...
# Product data rules... productId=[0-9]{3}
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Insert the MVEL expression for performing the order item total check into the
order-rules.csv
file.NoteThe easiest way to edit a .csv file is through using a spreadsheet application like LibreOffice Calc or Gnumeric. - Create resource bundle
.properties
files for each of the rule source files.NoteThe names of these files are derived from the names of their corresponding rule files.The message bundle for the rules defined inrules/customer.properties
is located in therules/i18n/customer.properties
file:customerId=ftl:Invalid customer number '${ruleResult.text}' at '${path}'. Customer number must begin with an uppercase character, followed by 5 digits. email=ftl:Invalid email address '${ruleResult.text}' at '${path}'. Email addresses match pattern '${ruleResult.pattern}'.
customerId=ftl:Invalid customer number '${ruleResult.text}' at '${path}'. Customer number must begin with an uppercase character, followed by 5 digits. email=ftl:Invalid email address '${ruleResult.text}' at '${path}'. Email addresses match pattern '${ruleResult.pattern}'.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The message bundle for the rule defined inrules/product.properties
is located in therules/i18n/product.properties
file:Product data rule messages...
# Product data rule messages... productId=ftl:Invalid product ID '${ruleResult.text}' at '${path}'. Product ID must match pattern '${ruleResult.pattern}'.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The message bundle for the rule defined inrules/order-rules.csv
is located in therules/i18n/order-rules.properties
file:Order item rule messages. The "orderDetails" and "orderItem" beans are populated by Smooks bindings
# Order item rule messages. The "orderDetails" and "orderItem" beans are populated by Smooks bindings order_item_total=ftl:Order ${orderDetails.orderId} contains an order item for product ${orderItem.productId} with a quantity of ${orderItem.quantity} and a unit price of ${orderItem.price}. This exceeds the permitted per order item total.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Apply this validation to the rules:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Execute from the example's
Main
class using this code:Copy to Clipboard Copied! Toggle word wrap Toggle overflow