So, you have multiple CSVBeanAgent's (created from a text file somewhere). These are stored in a Map created in Java called "globals".<br><br>Where do you actually set the global in WorkingMemory: See <a href="http://docs.jboss.org/drools/release/5.4.0.Final/drools-expert-docs/html/ch04.html#d0e4482">http://docs.jboss.org/drools/release/5.4.0.Final/drools-expert-docs/html/ch04.html#d0e4482</a>.<br>
<br>Furthermore, the Global will be of type Map not CSVBeanAgent, unless you want a Global for each CSVBeanAgent - but then how do you decide which you need.<br><br>Personally, I'd go back to inserting CSVBeanAgents as Facts and tackle the Java Heap Space issue... there are definitely things you are not telling us.<br>
<br>With kind regards,<br><br>Mike<br><br><div class="gmail_quote">On 26 July 2012 10:37, zeeshan <span dir="ltr"><<a href="mailto:zeeshan.spring@gmail.com" target="_blank">zeeshan.spring@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Mike !<br>
<br>
Earlier I tried it inserting as a Fact in using Statefull Session in my<br>
RuleMain.java but was facing Java Heap Space error.......so I tried<br>
Declaring as a Global in RuleMain.java like this----<br>
<br>
<br>
HashMap<String, Object> globals = new HashMap<String, Object>();<br>
<br>
StatefulSession statefulSession=new<br>
RuleRunner().getStatefulSession(RULES_FILES8,null,null, globals, null);<br>
...<br>
....<br>
<br>
<br>
//local block for Agent<br>
{<br>
System.out.println("agent block>>>>>>>>>>>>>>>>");<br>
String csvPath="C:/Users/new_user/Desktop/CIMS/ABAgent.csv";<br>
try{<br>
File f = new File(csvPath);<br>
InputStream is = new FileInputStream( f );<br>
Reader rdr = new InputStreamReader( is );<br>
LineNumberReader lnrdr = new LineNumberReader( rdr );<br>
<br>
String line;<br>
while( (line = lnrdr.readLine()) != null ){<br>
if( line.charAt(0) == '"' ) continue;<br>
String[] tokens = line.split( ";" );<br>
if( tokens.length != 3 ) continue;<br>
<br>
int agentId = Integer.parseInt( tokens[0] );<br>
int agentNo = Integer.parseInt( tokens[1] );<br>
String agentStatus = tokens[2];<br>
/* System.out.println("1>>"+agentId);<br>
System.out.println("2>>"+agentNo);<br>
System.out.println("3>>"+agentStatus);*/<br>
<br>
CSVBeanAgent csvAg = new CSVBeanAgent();<br>
csvAg.setAgentId(agentId);<br>
csvAg.setAgentNo(agentNo);<br>
csvAg.setAgentStatus(agentStatus);<br>
<br>
//statefulSession.insert(csvAg);<br>
<br>
*globals.put(csvAg.getAgentId()+"", csvAg);*<br>
<br>
}<br>
<br>
}catch (Exception e) {<br>
System.out.println(e);<br>
}<br>
}<br>
<br>
<br>
<br>
<br>
System.out.println("fire all rule>>>>>>>>");<br>
<br>
<br>
statefulSession.fireAllRules();<br>
//statefulSession2.fireAllRules();<br>
<br>
<br>
<br>
log.debug("============ End Firing Rules =========");<br>
<br>
// Close the session<br>
statefulSession.dispose();<br>
}<br>
}<br>
<br>
<br>
<br>
--<br>
View this message in context: <a href="http://drools.46999.n3.nabble.com/Using-global-variable-in-DRL-file-tp4018911p4018915.html" target="_blank">http://drools.46999.n3.nabble.com/Using-global-variable-in-DRL-file-tp4018911p4018915.html</a><br>
<div class="HOEnZb"><div class="h5">Sent from the Drools: User forum mailing list archive at Nabble.com.<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</div></div></blockquote></div><br>