How to produce business rule output that can be examined in the ODM Rule Execution Server Console? - jrules

I am new to ODM 8.5 (the successor to JRules), and I am trying to test some rules in the ODM Rule Execution Server Console. At this point, I'm merely trying to confirm that my rule changes have been deployed to the RES successfully. According to ODM's Testing Ruleset Execution help page, I should be able to examine the Output text box to see "strings that are written to print.out" from the web page under Explorer > RuleApps > RuleApp > Ruleset > Test Ruleset. I've deployed a rule containing the following snippet:
However, after executing the rule, I don't see the output of the println in the Output box. Is println what the documentation refers to when they say "print.out"? I get syntax errors if I try to replace "System.out.println" with "print.out". How can I get simple debug output to appear in the Output box?

The note method will cause output to go to the Output text box of the ODM Rule Execution Server Console, e.g., use:
note("*** This is the rule modification ***");

You can use the Decision warehouse(DW), in RES console.
First you need to activate the tracing in the ruleset properties.
Then after an execution, you can search in DW for execution informations such as, rule executed, data values, etc... Check online documetation details(look for ODM IBM 8.5)
Please note that this may slow down your decisions, so better not use this feature in production systems. Hope this helps.

Related

Agenda Group not working with drools 8.29.FINAL version

We have java rules service microservice & Using drools 7.X version to process the dynamic rules process. business rules (.xlsx) file using the Agenda-groups which is working fine.
After upgrading to drools 8.29.FINAL. kiesession.getAgenda().setAgendaFocus("1") is returning null.
NOTE :
Drools 7.49 is giving me list of agenda's
kieContainer.getKieBase().getKiePackages().parallelStream()
.forEach(obj -> obj.getRules().stream().forEach(innerObj -> {
agendaGroups.add(KieRuleMetaData.builder().agendaGroup(((RuleImpl) innerObj).getAgendaGroup())
.ruleName(innerObj.getName()).build());
}));
After upgrading to 8.29.FINAL - it's notworking
Appreciate if any help
As per the documentation, changed only drools version on pom.xml file.
Without some reproducer, it is difficult to support you effectively; next time kindly consider providing a reproducer (on GitHub for example) and share it here or via mailing-list on drools-usage or kogito-development
To me, this snippet returns as expected the agenda-group(s) defined in the rules, using 8.33.0.Final in this little reproducer here: https://github.com/tarilabs/demo20230212-so75416633/blob/main/src/test/java/org/drools/demo/RuleTest.java#L32-L34
kContainer.getKieBase().getKiePackages().stream().forEach(obj -> obj.getRules().stream().forEach(innerObj -> {
LOG.info("Rules contain this Agenda group: {}", ((RuleImpl) innerObj).getAgendaGroup() );
}));
I've used some simplified logging as you didn't provide details of KieRuleMetaData in your snippet, but as you can see with rules defining
rule "will execute per each Measurement having ID color"
agenda-group "mygroup"
when
...
The snippet above correctly prints:
2023-02-12 10:51:45,868 [main] INFO Rules contain this Agenda group: mygroup
Then, in the test code, as you can see I'm using the agenda-group I wanted by locating it on the agenda and setting it in-focus: https://github.com/tarilabs/demo20230212-so75416633/blob/main/src/test/java/org/drools/demo/RuleTest.java#L58-L69
session.getAgenda().getAgendaGroup("mygroup").setFocus();
session.fireAllRules();
So to me I cannot reproduce any error in using agenda-groups using latest Drools available at the time of writing.
You mention you are using Spreadsheet (.xlsx) for defining the rules, and the agenda group "1" is very suspicious it might be interpreted wrongly as number Vs string.
I hope with my very first snippet above, you are able to re-instate the inspection of all the agenda-groups defined in all rules in all packages, so to verify your agenda-group "1" is really present.
If not, suggesting you try by writing in Excel as "aaa1" instead of the simple digit for one, so to make sure it is correctly saved in the Excel as a string.

oracle-sqldeveloper: where does the output of plugins go to in v21?

A while ago I wrote myself a nice SQL Developer plugin (back then for Oracle SQL Developer v19.x).
I haven't used for a while and meanwhile I migrated to SQL Developer v21.2.1.204.
When I wanted to run my plugin again, there is no output displayed anywhere!? Where does the output generated by a plugin and emitted by dbms_output.put_line(...) end up?
In "Messages - Log" which used to be the tab where the output ended up, the execution only emits a final "PL/SQL procedure successfully completed." but nothing else.
For my colleagues who still run Oracle SQL Developer v19 it still works - all output goes to "Messages - Log".
I also tried "Dbms Output" (View --> Dmbs Outout) but nothing appears there.
Thus my question: Where does the output of an SQL Developer Plugin go to in OSD v21+? Do I need to enable anything beforehand to capture or redirect its output?
Nevermind - problem solved:
while experimenting I had commented the script's preamble
set serveroutput on;
set wrap off;
set linesize 4000;
...
and then - of course - there is no script output returned to SQLDeveloper.
Everything's working now...

Bdd Cucumber issues

I have newly started working on BDD Cucumber. I am using scala for writing test cases. I am trying to use Scenario Outline and passing parameters in step definitions. My code is as follows.
Scenario Outline: Data is parsed and persisted
Given Portal is running
When A data of <type> is received
Then The data of <type> with <Id> should be parsed and persisted
Examples:
| type | Id |
| Personal | 1 |
|Professional | 2 |
Now in my when condition I am trying to get these parameters as follows
When("""^A data of \"([^\"]*)\" is received$""") {
(type: String) =>
//My code
}
Now on running my code I am getting following error everytime.
io.cucumber.junit.UndefinedStepException: The step "A data of Personal is received" is undefined. You can implement it using the snippet(s) below:
When("""A data of Personal is received""") { () =>
// Write code here that turns the phrase above into concrete actions
throw new io.cucumber.scala.PendingException()
}
Though I have my code in when. Also If I don't use Scenario Outline then it works fine but I want to use Scenario Outline for my code.
I am using tags in my feature file to run my test cases. When I run my test cases with command sbt test #tag1, test cases executes fine but when all test cases are finished running on cmd I am getting following error:
[error] Expected ';'
[error] #tag1
I tried putting ";" after tag but still getting same error
What is this issue and how I can resolve it?
I have 4-5 feature files in my application. That means 4-5 tags. As of now the test case which I want to run I give path of feature file and "glue" it with step deinition in my Runner Class. How I can provide all the tags in my Runner class so that my application runs all the test cases one by one when started?
You are missing the double quotes around <type>:
When A data of "<type>" is received
Just some general advice.
When cuking keep things as simple as possible, focus on clarity and simplicity, do not worry about repetition.
Your task would be much simpler if you wrote 2 simple scenarios
Scenario: Personal data
Given Portal is running
When personal data is received
Then personal data should be persisted
Scenario: Professional data
...
Secondly don't use tags to run your features, you don't need tags yet.
You can cuke much more effectively if you avoid scenario outlines, regex's, tags, transforms etc. etc.. The main power in Cucumber is using natural language to express yourself clearly. Focus on that and keep it simple ...

Eclipse plugin Incubator's "Web Templates (Advanced)" plugin (with secured Redmine): Failed to parse RSS feed / invalid xml

Trying to connect some restricted Redmine instance to our Eclipse Mylyn environment it worked in the beginning, but the re-imports did not with some error "Failed to parse RSS feed".
I stumbled across this #246440 Eclipse Mylyn ticket where some workaround was to recreate the Task Repository including the Task List Queries by hand.
But this is not a nice solution.
So I played around a bit more and found the following that solved our import issues:
most likely for your needs: remove the key value (or other security-relevant data) from the exported <task list query>.xml.zip / tasklist.xml since the queries contain some user-dependent authentication API (e.g. if shared with other users)
it should anyways be configured on your related Task Repository for all dependent queries and will be re-imported automatically on later import
make sure that (e.g. through some used formatter, CTRL + F or manual formatting) there are no whitespaces in text-value XML nodes, because thus the queries may stop working after import:
e.g.
<Attribute Key="Regexp">^({Id}\d+);({Type}[^;]*);...$
</Attribute>
should be:
<Attribute Key="Regexp">^({Id}\d+);({Type}[^;]*);...$</Attribute>
go on Task List -> <your imported query> -> right click -> Properties -> Finish so some internal magic "fixes" your query
Another debugging hint: you can always check the retrieved files (and Query Pattern regexp using the Preview button) using the <your query -> Properties -> Advanced Configuration -> Open button, which should put the unparsed query result in e.g. c:\Users\<loginname>\AppData\Local\Temp\mylyn-web-connector4155864524987884464.html.
By the way: (If you are at the above point it may likely be useful for you or your team ...) Using the web connector I found the integration via the API key in combination with the .../issues.csv... format much more useful and configurable than the .../issues.xml... variant.
We used something like this for parsing the CSV (and generated the params, their order etc. via normal filter dialogs): ^({Id}\d+);({Type}[^;]*);({Status}[^;]*);"?({Owner}[^";]*)"?;({Description}[^;]*)$.
Advantages are: easier regexp, concatenatable data for Description via column-ordering and fetching of all data without paging (=> we could skip page, per_page, limit, offset).

Perl parsing a log4j log [duplicate]

We have several applications that use log4j for logging. I need to get a log4j parser working so we can combine multiple log files and run automated analysis on them. I'm not looking to reinvent the wheel, so can someone point me to a decent pre-existing parser? I do have the log4j conversion pattern if that helps.
If not, I'll have to roll our own.
I didn't realize that Log4J ships with an XML appender.
Solution was: specify an XML appender in the logging configuration file, include that output XML file as an entity into a well formed XML file, then parse the XML using your favorite technique.
The other methods had the following limitations:
Apache Chainsaw - not automated enough
jdbc - poor performance in a high performance distributed app
You can use OtrosLogViewer with batch processing. You have to:
Define you log format, you can use Log4j pattern layout parser or Log4j XmlLayout
Create java class that implements LogDataParsedListener. Method public void logDataParsed(LogData data, BatchProcessingContext context) will be called on every parsed log event.
Create jar
Run OtrosLogViewer with specifying your log processing jar, LogDataParsedListener implementation and log files.
What you are looking for is called SawMill, or something like it.
Log4j log files aren't really suitable for parsing, they're too complex and unstructured. There are third party tools that can do it, I believe (e.g. Sawmill).
If you need to perform automated, custom analysis of the logs, you should consider logging to a database, and analysing that. JDBC ships with the JdbcAppender which appends all messages to a database of your choice, but it has performance implications, and it's a bit flaky. There are other, similar, alternatives on the interweb, though (like this one).
You -can- use Log4j's Chainsaw V2 to process the various log files and collect them into one table, and either output those events as xml or use Chainsaw's built-in expression-based filtering, searching & colorizing support to slice & dice the logs.
Steps:
- Start Chainsaw V2
- Create a chainsaw configuration file by copying the example configuration file available from the Welcome tab - define one LogFilePatternReceiver 'plugin' entry for each log file that you want to process
- Start Chainsaw with that configuration
- Each log file will end up as a separate tab in the UI
- Pause the chainsaw-log tab and clear the events from that tab
- Create a new tab which aggregates the events from the various tabs by going to the 'view, crate custom expression logpanel' menu item and enter 'level >= DEBUG' in the box. It will create a new tab containing events from all of the tabs with level >= debug (which is why you cleared the chainsaw-log tab).
You can get an overview of the expression syntax used to filter, colorize and search from the tutorial (available from the Help menu).
If you don't want to use Chainsaw, you can do something similar - start a simple app that doesn't log but loads a log4j.xml config file with the 'plugin' entries you defined for the Chainsaw configuration, but also define a FileAppender with an xmllayout - all of the events received by the 'receivers' will be sent to the single appender.