Drools on Spark with Scala - scala

I am starting a project where we have a lot of business rules. I have strongly been considering using the JBoss rules engine, Drools.
My project uses Scala and uses the Spark engine. I am wondering if anyone has experience, or advice, using Drools with Spark/Scala.
If you looked into Drools and decided against it, I would like to know that too.
I have read several blogs on how people integrate Drools with Spark, or Drools with Scala, but I didn't find any good examples explaining Drools on Spark with Scala. I have seen this with a mixture of Scala and Java, but never pure Scala. I am not sure if this is possible.
Update: Clarifying Question
Would you recommend Drools?
How about with Spark/Scala?

If you looked into Drools and decided against it, I would like to know
that too.
I would not advise that. We are forced to use drools in one of our components and all developers in a team find this solution full of cons:
Java 8 support: scala is moving towards java 8 (see this and
this regarding runtime). Drools started to support java 8 only
in 2 years after its release.
IDE support: eclipse only. We were not able to get it done in
Intellij idea.
General purpose: we did come up with the idea, that whatever you
write using drools rules engine could be written in java/scala
easily. You would say that business logic can get too technical?
Possibly, but you would not have to learn some kind of scripting language
to create business rules.

1) Yes, I would recommend Drools. I have no experience with other rule engines, but the projects I have developed using Drools have worked perfectly so far. Truth be told, I have only used the basic functionality of Drools (never used salience explicitly, Agendas, etc). However, the functionality I have used has solved my requirements perfectly.
2) I have used Drools with both Java 7 and Scala 2.11. I haven't found any particular thing I was able to do with Java but not in Scala. My latest project is using Apache Spark with Scala and Drools, and everything fits together nicely.
If you are going to use Scala, then your facts (the objects that model your domain; aka the 'bean') should have public access modifiers on the val or var you are going to access within the rules. If you need static methods or attributes, then use Objects and import them in the rule file.
Hope this helps

Related

Running Drools on GraalVM

We have a service that uses Drools quite heavily. Would like to improve the performance by running it on GraalVM.
Is it possible to run Drools on GraalVM without using Kogito?
Disclaimer: I'm one of the Drools developers
It's definitely possible, as you've already notice, we do indeed support native image compilation with our Quarkus backend, but it'll require you to write you some code, there's no such possibility in the current codebase.
Please note that only the executable model will be supported with the static component injection (the drools-core-static module in Kogito)
Is there a reason why you don't want to use Kogito though? We are really interested. Please join our community channels or the mailing list if you want to share your feedbacks, as SO is not the best platform for it.
Thanks for your support

How to create an interface using scala

I am developing a spark application in eclipse ide with scala language and with maven dependencies.
I would like to know:
Is it possible to create an interface that has a text area and a button with scala language on eclipse?
I know how to manipulate Java GUI. But I have no idea how to manipulate Scala GUI.
I'm still new to this apache Spark environment
Yes, it is possible to do that in Scala but it has no relation to the Apache Spark Environment. The latter is an execution framework, specifically a distributed general-purpose cluster-computing (aka grid computing) framework which is not something you'd use to write UIs on. To create UIs you'd need a UI framework. One option is to look at ScalaFX (http://www.scalafx.org/).
Of course, it can be useful to have a UI to visualize minimally inputs/outputs of your apache-backed computation layer, I suspect that's why you asked the question, but they are not otherwise related. Hope this helps.

It is possible to Integrate Activiti with Drools rule engin

I am working on a project and trying to evaluate Drools vs Activiti.
I know there is jBPM support but my client needs Activiti for managing the business flow and I need to use rule engin for evaluating some cases.
So is it possible to integrate drools and activity. Any pointer would help.
As I mention in the Gitter channel this is totally possible.
I will recommend you to do a small PoC (Proof of Concept) to really understand the details of it. People usually underestimate the complexity of a Rule Engine like Drools. Don't get me wrong, I love Drools, but I recommend you to check the docs and one of their books ;)
Check out the chapter in Tijs Rademaker's book "Activiti in Action". It describes the drools integration for version 5.x of Activiti very completely. The concepts are still valid for Activiti 6 as well.

Database access library to use with spray

I am considering rewriting a large project using Spray. I am unsure what is currently the best choice for accessing an RDBMS. I need to support Oracle and PosgreSQL and, as I am restricted to a free solution, Slick is rather not an option here.
I often use MyBatis in my Java projects, so I consider MyBatis-Scala as a possible solution, but this is just a wrapper for a Java library.
Which native Scala library fits best into Spray?
In my oppinion it is not the matter of "fitting" into Spray, but the matter of good strategic choice.
Please consider options of scala database frameworks. My personal preference is squeryl and sorm. Both of them provide pretty much nice DSL and are written in scala.
Also you can have a look at one more review of available scala frameworks (a bit outdated but well structured to give a basic idea).
Hope it helps.

Drawbacks to using Lift (Scala-based framework) for webservices?

I have been working on a project and as I have just started on the webservice I found Lift has been released, so I am curious if there will be much more complication by using Lift over Jax-WS using JDK6.
I am doing this with the Eclipse IDE, but I don't know if I will get much benefit from the IDE on this project.
Lift is written in Scala, so the simple question is do you know Scala? If you don't know Scala but you do know JAX-WS, then Lift will clearly be way more work to get to a working implementation.
Scala and Lift are cool, but unless you are already comfortable with functional programming approaches, they will make your head hurt for at least 6 months. Since they are relatively new they also suffer from a lack of tooling.
You mention that you are using JAX-WS - can you do that with Lift? If you can't do it natively with Lift, can you easily integrate the standard Java libraries for this?
Depending on whether this is a personal project or work-related, your tolerance for taking technical risk can vary widely.