[jboss-user] [JBoss jBPM] - Have a node wait for JMS message - Problem

anb@beyondfibre.tv do-not-reply at jboss.com
Fri Apr 18 05:20:57 EDT 2008


Hello everyone,

I have a node in my process that I want to wait on a jms message. I'm using the following code:

package ch.siesa.beyondfibre.jbpm.customer.delete;
  | 
  | import javax.jms.*;
  | import javax.naming.*;
  | 
  | import org.jbpm.graph.def.ActionHandler;
  | import org.jbpm.graph.exe.ExecutionContext;
  | 
  | public class WaitAction implements ActionHandler, MessageListener{
  | 
  | 	private static final long serialVersionUID = 1L;
  | 	
  | 	Context 				jndiContext 			= null;
  | 	ExecutionContext 		executionContext 		= null;
  |     TopicConnectionFactory  topicConnectionFactory	= null;
  |     TopicConnection         topicConnection 		= null;
  |     TopicSession            topicSession 			= null;
  |     Topic                   topic 					= null;
  |     TopicSubscriber         topicSubscriber 		= null;
  | 	
  | 	public void execute(ExecutionContext ctx) throws Exception {
  | 		System.out.println("Subscribing node to JMS topic...");
  | 		this.executionContext = ctx;
  | 		jndiContext = new InitialContext();
  | 		topicConnectionFactory = (TopicConnectionFactory)jndiContext.lookup("TopicConnectionFactory");
  | 		topic = (Topic) jndiContext.lookup("topic/testTopic");
  | 		topicConnection = topicConnectionFactory.createTopicConnection();
  | 		topicSession = topicConnection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
  | 		topicSubscriber = topicSession.createSubscriber(topic);
  | 		topicSubscriber.setMessageListener(this);
  | 		topicConnection.start();
  | 		System.out.println("Subscription ok, waiting !");
  | 	}
  | 
  | 	public void onMessage(Message message) {
  | 		executionContext.leaveNode("success");	
  | 	}
  | 	
  | 
  | }
  | 

It is however throwing an exception:

11:09:44,983 ERROR [GraphElement] action threw exception: This method is not applicable inside the application server. See the J2EE spec, e.g. J2EE1.4 Section 6.6
javax.jms.IllegalStateException: This method is not applicable inside the application server. See the J2EE spec, e.g. J2EE1.4 Section 6.6

I have two questions :
- Is there a workaround this exception ?
- Isn't there a simpler way to have a node wait for a message ?

Thanking you all in advance :)

Regards

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4145098#4145098

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4145098



More information about the jboss-user mailing list