[JBoss jBPM] - Serializing Session in jbpm???
by ashishc
Hi All,
I am running into another issue with Serializing jms session object in jbpm..
I am using jms/tibco to store and retrieve the messages from a queue and in the workflow what I am doing as a first step is create a session and then at the end of the workflow ..ack the message and end that session.
Now since tibco jms session is not serializable jbpm is not able to store that object in its dbâ¦
So I created a session store and returned the id which I storeâ¦.But when the execution transitions from one step to another, the static variable is cleared outâ¦
Here is the code what I am talking aboutâ¦.
Step 1: to create sessionâ¦
public class QueueSessionHandler implements ActionHandler {
|
| public void execute(ExecutionContext context) throws Exception {
|
| context.getContextInstance().setVariable(CONSTANTS.SESSION_OBJECT_VAR, SessionStore.storeSession(CreateSession()));
Here is the SessionStore Class:
import java.io.Serializable;
| import java.util.HashMap;
| import java.util.Map;
|
| import org.apache.commons.logging.Log;
| import org.apache.commons.logging.LogFactory;
|
| import javax.jms.Session;
|
| public class SessionStore {
|
| private static Map<String,Session> StoreMap = null;
| private static int m_SeqNumber = 1;
|
| static {
| StoreMap = new HashMap<String,Session>();
| }
|
| public static String storeSession(Session s)
| {
| String token = "" + m_SeqNumber++;
|
| StoreMap.put(token, s);
| return token;
| }
|
| public static Session getSession(String token)
| {
| Session s = StoreMap.get(token);
| return s;
| }
|
| public static void destroySession(String token)
| {
| StoreMap.remove(token);
| }
| }
Step 2 of the workflow:
public void execute(ExecutionContext context) throws Exception {
| context.getContextInstance().setVariable("actionName", actionName);
| context.getContextInstance().setVariable("queueName", queueName);
|
| String token = (String)context.getContextInstance().getVariable(CONSTANTS.SESSION_OBJECT_VAR);
| Session prevSession = SessionStore.getSession(token);
| log.info("Session token is " + token);
| if(prevSession != null)
| {
| context.getContextInstance().setVariable(CONSTANTS.INCOMING_MSG_READ_VAR, ReadMessage(prevSession, queueName));
| log.info("Returning after reading message from incoming queue");
| }
| else {
| context.getContextInstance().setVariable(CONSTANTS.INCOMING_MSG_READ_VAR, "");
| log.info("Session is null so not reading message...returning blank");
| }
In Step 2 of the WF I expect when I call SessionStore.getSession it should have the same StoreMap and return me the session which I stored in thereâ¦.but actually the StoreMap is empty/null or recreatedâ¦.that is what I am not understandingâ¦.
Can you please advise on how should i be doing that....
Thanks
ashish
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4166759#4166759
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4166759
17 years, 9 months
[JBossWS] - Re: Looking to pass complex types in web service...
by dakk
Thanks for your help! Norm
The class is:
========
import java.util.Date;
/**
*
* @author dakk
*/
public class DataRecord implements java.io.Serializable {
public String fileName;
public byte[] photo; //as an array of base64-encoded bytes
public Float salary;
public Float d2;
public Float d3;
public Float d4;
public Date date;
public Integer empID;
public Float d5;
public DataRecord() {}
public String toString() {
return "Data Record Filename="+this.fileName;
}
}
Here is the run:
===================================
init:
deps-jar:
compile-single:
run-single:
Contacting webservice at http://localhost:8080/myservlet/MyServletInterface?wsdl
Exception in thread "main" deserialization error: unexpected XML reader state. expected: END but found: START: date
at com.sun.xml.rpc.encoding.literal.LiteralResponseSerializer.deserialize(LiteralResponseSerializer.java:331)
at com.sun.xml.rpc.client.dii.CallInvokerImpl._readFirstBodyElement(CallInvokerImpl.java:350)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:228)
at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:103)
at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:486)
at com.sun.xml.rpc.client.dii.CallInvocationHandler.doCall(CallInvocationHandler.java:121)
at com.sun.xml.rpc.client.dii.CallInvocationHandler.invoke(CallInvocationHandler.java:85)
at $Proxy0.getDataRecord(Unknown Source)
at MyClient.main(MyClient.java:48)
CAUSE:
unexpected XML reader state. expected: END but found: START: date
at com.sun.xml.rpc.streaming.XMLReaderUtil.verifyReaderState(XMLReaderUtil.java:51)
at com.sun.xml.rpc.encoding.literal.LiteralResponseSerializer.internalDeserialize(LiteralResponseSerializer.java:373)
at com.sun.xml.rpc.encoding.literal.LiteralResponseSerializer.deserialize(LiteralResponseSerializer.java:327)
at com.sun.xml.rpc.client.dii.CallInvokerImpl._readFirstBodyElement(CallInvokerImpl.java:350)
at com.sun.xml.rpc.client.StreamingSender._send(StreamingSender.java:228)
at com.sun.xml.rpc.client.dii.CallInvokerImpl.doInvoke(CallInvokerImpl.java:103)
at com.sun.xml.rpc.client.dii.BasicCall.invoke(BasicCall.java:486)
at com.sun.xml.rpc.client.dii.CallInvocationHandler.doCall(CallInvocationHandler.java:121)
at com.sun.xml.rpc.client.dii.CallInvocationHandler.invoke(CallInvocationHandler.java:85)
at $Proxy0.getDataRecord(Unknown Source)
at MyClient.main(MyClient.java:48)
Java Result: 1
BUILD SUCCESSFUL (total time: 17 seconds)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4166755#4166755
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4166755
17 years, 9 months
[JBoss Cache: Core Edition] - Hibernate/Writes but does not loads
by pozzo
Hi,
We are trying to use Hibernate with JBoss Cache 1.4 (JBoss 4.2.2).
We annotated our beans as follow:
@Entity
| @Table(name="TSC_ATIVO", schema=SchemaNames.ATIVOS)
| @org.hibernate.annotations.Cache(usage=CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
| public class BaseSecurity implements Serializable
With configured ThreeCache in the MBean and in the persistence.xml file.
After making a test that reads a entity, we could check on the JMX Console that the entity was saved on the cache as expected.
BUT when we try to load the entity, we always see the SQL code going on on the console and it does not read from the cache.
I already set the cache log level to trace, but could not figure out why it is not reading from the cache.
Somebody have some idea on how to debug this problem? We thought that it would be very automatic.
Thanks
Luciano
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4166752#4166752
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4166752
17 years, 9 months
[JBoss Messaging] - Re: How do I empty a JBoss queue?
by asaur
I have the same situation, meaning sometimes I'd like to remove some messages that are under delivery.
The problem is that, in my environment, we are forced to sometimes boot one of our machines (clients) in production without stopping Jboss (which is acting like a message server). This seems to be a big problem, because when I start the client again and it connects with a new connection, the older messages aren't consumed and are lost in the "delivery queue" forever. Worst of all, the NEW messages (in this case I couldn't care less for the old messages, since the client crashed) that should be delivered immediately now that the client is back, are stuck somewhat and takes a lot of seconds (sometimes a minute) to be delivered.
So I'd like to delete all the old messages and the only way to do that is stopping the messaging server (Jboss) and starting it again, as I deployed a war that does the cleanup in all queues I have.
Perhaps I'm doing something really stupid (sorry, I'm new to JMS) and this problem could be solved using another type of persistence, one that automatically deletes the messages whenever a client (or the server, for that matter) goes down.
Any help will be welcomed.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4166748#4166748
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4166748
17 years, 9 months