Can Applet listen JMS message which sent from application server 2004-12-21 - By ?8?
Back Hi, all: Can Applet listen JMS messages which sent from application server? Applet(let say: WorklistApplet), contains a JMS listenner(see code following) . It works well on weblogic8.1, but couldn't run on websphere. 1), which jars should be included on browser side(for example, wlclient.jar and wljmsclient.jar on weblogic) . 2), can anyone have the same practice?
Any helps will be appreciate! Thanks in advance!
Charles Guo
<APPLET codebase="." archive="worklist.jar,wljmsclient.jar,wlclient.jar" code="com.cit.wf.web.WorklistApplet.class" height="50", width="200">
<PARAM name="StaffId" value="<%=request.getAttribute("StaffId")%> ">
<PARAM name="AcceptTaskState" value="7">
</APPLET>
//WorklistApplet.Java code snippet
public void start() {
try {
Context context = worklistApplet.getInitalContext();
Object objref = context.lookup("javax.jms.TopicConnectionFactory ");
topicConnectionFactory = (TopicConnectionFactory)
PortableRemoteObject.narrow(objref, TopicConnectionFactory .class);
topicConnection = topicConnectionFactory.createTopicConnection();
topicSession = topicConnection.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
topic = (Topic) context.lookup(JNDINames.WORKLIST_NOTIFIY_TOPIC);
if (topicSubsciber != null) {
topicSubsciber.close();
}
topicSubsciber=topicSession.createSubscriber(topic);
topicSubsciber.setMessageListener(this);
topicConnection.start();
System.out.print("listener started success!");
} catch (Exception ex) {
topicSubsciber = null;
ex.printStackTrace();
}
}
public void onMessage(Message message) {
try {
if (!(message instanceof ObjectMessage)) {
return;
}
java.io.Serializable serializable = ((ObjectMessage) message) .getObject();
if (!(serializable instanceof WorkflowEvent)) {
return;
}
System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>get WorkflowEvent");
WorkflowEvent event=(WorkflowEvent)serializable;
Variable var = (Variable)event.getEventParams().get(Constant .WORKFLOW_TASK);
Task task = (Task)var.getValue();
System.out.println("+++++++++++++++++++++++++++++++++++++++++++++");
System.out.print("taskpoid="+task.getPoid());
this.worklistApplet.acceptTask(task);
} catch (JMSException ex) {
ex.printStackTrace();
return;
}
}
|
|