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#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...