Two Integration Servers sharing a single persisted session?
by dunnlow
I'm using Drools 5.5 with Hibernate 4 and Spring 3.1.
I am trying to implement the shared persisted session referenced
(http://www.plugtree.com/making-a-non-persistent-ha-knowledge-session/) but
I can not get it to work. I have two knowledge sessions (two instances of
the drools integration server) and I would like to share the same persisted
session (they both call JPAKnowledgeService.loadStatefulKnowledgeSession()
on the same session id).
The two integration servers (running in Tomcat) are of course deployed
(started) one after the other. They both successfully start and load the
existing knowledge session from the database
(JPAKnowledgeServer.loadStatefulKnowledgeSession) both instances print out
the objects that were stored in the persisted knowledge session.
The session that is started last continues to work fine, but the other
server throws the vague exception below with no other messages when I send a
command to it. If I restart the one that isn't working, that one comes up
and starts working and the other instance returns an Exception from then on.
Same basic issue when I create a new session
(JPAKnowledgeServer.newStatefulKnowledgeSession()).
With TRACE debugging, the only exception I am getting in the server logs is:
*org.apache.cxf.jaxrs.impl.WebApplicationExceptionMapper toResponse
WARNING: WebApplicationException has been caught : Could not commit
session or rollback*
With debug I see that Hibernate is identifying the dirty session, updating
optlock and trying to update the session (see below) but then rolling back
(I am not sure why the upodate to session is rolling back, but nothing in
the logs indicates the rollback even failed). I'm using local transactions
(transaction-type="RESOURCE_LOCAL").
I've tried configuring both
org.springframework.orm.hibernate4.HibernateTransactionManager as well as
org.springframework.orm.jpa.JpaTransactionManager (via spring XML config)
but get the same error with both.
First, is it correct that this /SHOULD/ be possible to do?
Secondly, before I post my full spring/hibernate configuration, does anyone
have any thoughts about what is causing this or ways to troubleshoot?
Thanks in advance for any thoughts,
-J
a summary of the rollback trace:
org.springframework.orm.jpa.ExtendedEntityManagerCreator$ExtendedEntityManagerInvocationHandler.enlistInCurrentTransaction(423)
- Starting resource local transaction on application-managed EntityManager
[org.hibernate.ejb.EntityManagerImpl@cas5ed94]
.
.
org.hibernate.SQL.logStatement(104) - update SessionInfo set
lastModificationDate=?, rulesByteArray=?, startDate=?, OPTLOCK=? where id=?
and OPTLOCK=?
org.hibernate.ejb.AbstractEntityManagerImpl.markAsRollback(1137) - Mark
transaction for rollback
org.hibernate.engine.transaction.spi.AbstractTransactionImpl.rollback(203) -
rolling back
org.hibernate.engine.transaction.internal.jdbc.JdbcTransaction.doRollback(164)
- rolled JDBC Connection
.
.
.
--
View this message in context: http://drools.46999.n3.nabble.com/Two-Integration-Servers-sharing-a-singl...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
Re: [rules-users] sliding window problem
by grules
I think you have to follow the structure of accumulate function. Like
<result pattern> from accumulate( <source pattern>,
init( <init code> ),
action( <action code> ),
reverse( <reverse code> ), (optional)
result( <result expression> ) )
examples are:
when
$order : Order()
$total : Number( doubleValue > 100 )
from accumulate( OrderItem( order == $order, $value : value ),
init( double total = 0; ),
action( total += $value; ),
result( total ) )
then
# apply discount to $order
end
As I understand from your code,
1. Make List for Event class, because accumulate will loop through the elements of List<Event>
2. Init (write action codes, i.e. initialize value so you will find how many time it got looped)
3. Write code inside the block of action(//code here) and
4. Update it in result block i.e. result(//update here);
Being said, follow the structure 1) init, 2) action, 3) result as above..
From: Sandhya Sree [via Drools] [mailto:ml-node+s46999n4028639h52@n3.nabble.com]
Sent: Tuesday, March 11, 2014 1:51 PM
To: Gopu Shrestha
Subject: [rules-users] sliding window problem
i have a class called Event which has the following members { name, source, timestamp } with getters ,setters and constructor. i have a rule file which creates Event objects whenever a file is added / deleted in a particular folder. the rule file is as follows
rule "new file"
when
$p: RuleContext( $old : getOldContext().getContainedFiles(), $new :getNewContext().getContainedFiles())
RuleContext( $old != $new)
accumulate( $s : Object( this not memberOf $old ) from $new, $plus : collectList( $s ) )
events : Object() from $plus;
then
Event event = new Event("new file added",$p.getOldContext().getParent(),new Date());
end
rule " file deleted"
when
$p: RuleContext( $old : getOldContext().getContainedFiles(), $new:getNewContext().getContainedFiles())
RuleContext( $old != $new)
accumulate( $t : Object( this not memberOf $new ) from $old, $mins : collectList( $t ) )
events : Object() from $mins;
then
Event event = new Event("file deleted",$p.getOldContext().getParent(),new Date());
end
(do not confuse with RuleContext and other unknown identifiers.. they r just related with other classes in the project.. these two rules just works fine )..i need to use a sliding time window and create another event if the number of file additions are > 5 over the past 1 minute. my rule file is :
declare Event
@role( event )
end
rule "More than 5 additions"
when
Number(intValue > 5)
from accumulate( $tick : Event ( name == "new file added" ) over window:time( 1m ),
count( $tick ) ) )
then
System.out.println("too many additions");
end
i have enabled stream mode processing too.. but it doesnt seem to work. what could be the problem?
_______________________________________________
rules-users mailing list
[hidden email]</user/SendEmail.jtp?type=node&node=4028639&i=0>
https://lists.jboss.org/mailman/listinfo/rules-users
________________________________
If you reply to this email, your message will be added to the discussion below:
http://drools.46999.n3.nabble.com/rules-users-sliding-window-problem-tp40...
To start a new topic under Drools: User forum, email ml-node+s46999n47000h43(a)n3.nabble.com<mailto:ml-node+s46999n47000h43@n3.nabble.com>
To unsubscribe from Drools, click here<http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=unsubscr...>.
NAML<http://drools.46999.n3.nabble.com/template/NamlServlet.jtp?macro=macro_vi...>
--
View this message in context: http://drools.46999.n3.nabble.com/RE-rules-users-sliding-window-problem-t...
Sent from the Drools: User forum mailing list archive at Nabble.com.
12 years
sliding window problem
by Sandhya Sree
i have a class called Event which has the following members { name, source,
timestamp } with getters ,setters and constructor. i have a rule file which
creates Event objects whenever a file is added / deleted in a particular
folder. the rule file is as follows
rule "new file"
when
$p: RuleContext( $old : getOldContext().getContainedFiles(), $new
:getNewContext().getContainedFiles())
RuleContext( $old != $new)
accumulate( $s : Object( this not memberOf $old ) from $new, $plus :
collectList( $s ) )
events : Object() from $plus;
then
Event event = new Event("new file
added",$p.getOldContext().getParent(),new Date());
end
rule " file deleted"
when
$p: RuleContext( $old : getOldContext().getContainedFiles(),
$new:getNewContext().getContainedFiles())
RuleContext( $old != $new)
accumulate( $t : Object( this not memberOf $new ) from $old, $mins :
collectList( $t ) )
events : Object() from $mins;
then
Event event = new Event("file
deleted",$p.getOldContext().getParent(),new Date());
end
(do not confuse with RuleContext and other unknown identifiers.. they r
just related with other classes in the project.. these two rules just works
fine )..i need to use a sliding time window and create another event if the
number of file additions are > 5 over the past 1 minute. my rule file is :
declare Event
@role( event )
end
rule "More than 5 additions"
when
Number(intValue > 5)
from accumulate( $tick : Event ( name == "new file added" ) over
window:time( 1m ),
count( $tick ) ) )
then
System.out.println("too many additions");
end
i have enabled stream mode processing too.. but it doesnt seem to work.
what could be the problem?
12 years
Large data sets
by Raja Sekhar
Hi
Is it a good approach to apply rules on large data-sets ranging 100,000 to
50 million records Of course it depends upon the logic written in the rule
conditions and consequences.
--
Raja Sekhar Amirapu
------------------------------------------------------
"If any anyone can do it, i can do it. If no one else can do it, i must do
it"
12 years
looping in drools
by Sandhya Sree
hi,
im new to drools..im trying to create a project as follows. i have a class
called Monitor which monitors a folder and creates two lists called
fileOld( which is the list of filenames in that folder at time t1) and
fileNew(which is the list of filenames in that folder at time t2). i have
another class called FileData which contains two members fileOld and
fileNew (list of strings) with getters,setters and constructor. fileOld and
fileNew from Monitor Class are passed to FileData class.
i also have another class called Event which is as follows:
public class Event {
public static String name;
private File source;
private Date timeStamp;
public static List<Event> listOfEvents = new ArrayList<Event>();
public Event(String name, File source, Date timeStamp) {
this.name = name;
this.source = source;
this.timeStamp = timeStamp;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public File getSource() {
return source;
}
public void setSource(File source) {
this.source = source;
}
public Date getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(Date timeStamp) {
this.timeStamp = timeStamp;
}
now i have to compare these two lists(fileOld and fileNew) in a rule file
and if they are not equal i have to create an event object for every file
added and deleted and put it in the List<Event> listOfEvents.
here is my rule file:
rrule "files are equal"
when
FileData( fileOld == fileNew)
then
System.out.println("files are equal");
end
rule "files not equal"
when
FileData($old : fileOld, $new : fileNew, fileOld != fileNew)
then
accumulate( $s : String( this not memberOf $old ) from $new, $plus :
collectList( $s ) )
accumulate( $t : String( this not memberOf $new ) from $old, $mins :
collectList( $t ) )
System.out.println("files added:" + $plus );
System.out.println( "files deleted:" + $mins );
end
how can i loop through each of the file added or deleted and create an
Event Class object for every file added and deleted and finally add all
the created objects to List<Event> listOfEvents..
Thanks.
12 years
(no subject)
by Sandhya Sree
hi ,
i have a class called Event which is as follows:
public class Event {
private String name;
private File source;
private Date timeStamp;
public static List<Event> listOfEvents;
public Event(String name, File source, Date timeStamp) {
this.name = name;
this.source = source;
this.timeStamp = timeStamp;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public File getSource() {
return source;
}
public void setSource(File source) {
this.source = source;
}
public Date getTimeStamp() {
return timeStamp;
}
public void setTimeStamp(Date timeStamp) {
this.timeStamp = timeStamp;
}
public void display()
{
System.out.println(name +" " + "in folder: " + source + " on " + timeStamp
);
}
there are also some other classes associated with my project.. i have a
rules file which computes the size of a folder and creates an object of
Event class. every time this object of Event class is created i wwant to
put it in a List<Event>.. how can i do this..
my rules is as follows:
rule "size"
when
$p: RuleContext($size: getOldContext().getParent().getUsableSpace() >
(30*1024*1024))
then
Event event = new Event("folder almost full",
$p.getOldContext().getParent(), new Date());
event.display();
......here i want to put this event into the List<Event> declared in
Event Class.....
end
thanks,
Sandhya
12 years
Disjunctive normal form
by Mercier Jonathan
Dear,
Little question when we writing a rules.
I would like to know if they are a difference between to write a rule as
disjunctive normal form or not into Phreak graph ?
Thanks
Regards
12 years