- testwebservices.zip
- TestWebServices
- classes
- Generated Source
- .jsp
- testwebservices
- jsp cache
- testwebservices
- fingerprint_0002ejsp_jsp.class
- happyaxis_0002ejsp_jsp.class
- package cache
- UnnamedPackage.dep2
- package cache
- testwebservices.dep2
- testwebservices.generated.dep2
- testwebservices
- generated
- ReceiverWebService.class
- ReceiverWebServiceService.class
- ReceiverWebServiceServiceLocator.class
- ReceiverWebServiceServiceTestCase.class
- ReceiverWebServiceSoapBindingStub.class
- JMSChatPublisher.class
- JMSChatSubscriber.class
- ReceiverWebService.class
- ReceiverWebService.wsdl
- Servlet.library
- src
- testwebservices
- TestWebServices.jpx
- TestWebServices.jpx.local
- testwebservices
- AdminInstructions.html
- fingerprint.jsp
- happyaxis.jsp
- index.html
- SOAPMonitorApplet.jar
- WEB-INF
- classes
- testwebservices
- generated
- ReceiverWebService.class
- ReceiverWebServiceService.class
- ReceiverWebServiceServiceLocator.class
- ReceiverWebServiceServiceTestCase.class
- ReceiverWebServiceSoapBindingStub.class
- JMSChatPublisher.class
- JMSChatSubscriber.class
- ReceiverWebService.class
- jboss-web.xml
- lib
- activation.jar
- axis.jar
- axis-ant.jar
- commons-discovery.jar
- commons-logging.jar
- jaxrpc.jar
- junit.jar
- log4j-1.2.8.jar
- mail.jar
- saaj.jar
- unittest.jar
- wsdl4j.jar
- server-config.wsdd
- web.xml
- WebServiceDeploymentModules
- Apache Axis
- webapp
- testwebservices
- JbWebServiceDesigner
- dotnetwebserviceclient.zip
- DotnetWebserviceClient
|
package testwebservices;
import java.util.*;
import javax.jms.*;
import javax.naming.*;
public class JMSChatSubscriber {
private InitialContext getInitialContext() throws NamingException {
Hashtable environment = new Hashtable();
environment.put(Context.INITIAL_CONTEXT_FACTORY,
"org.jboss.naming.HttpNamingContextFactory");
environment.put(Context.URL_PKG_PREFIXES,
"org.jboss.naming:org.jnp.interfaces");
environment.put(Context.PROVIDER_URL,
"http://localhost:8080/invoker/JNDIFactory");
return new InitialContext(environment);
}
private TopicConnectionFactory lookupTopicConnectionFactory(InitialContext
ctx, String factoryName) throws NamingException {
return (TopicConnectionFactory) ctx.lookup(factoryName);
}
private Topic lookupTopic(InitialContext ctx, String strName) throws
NamingException {
return (Topic) ctx.lookup(strName);
}
private TopicConnection createTopicConnection(TopicConnectionFactory
connectionFactory) throws
JMSException {
return connectionFactory.createTopicConnection();
}
private TopicConnection createTopicConnection(TopicConnectionFactory
connectionFactory,
String username,
String password) throws
JMSException {
return connectionFactory.createTopicConnection(username, password);
}
private TopicSession createTopicSession(TopicConnection connection) throws
JMSException {
return connection.createTopicSession(false, Session.AUTO_ACKNOWLEDGE);
}
private TopicSubscriber createTopicSubscriber(TopicSession session,
Topic topic) throws
JMSException {
return session.createSubscriber(topic);
}
private TopicSubscriber createTopicSubscriber(TopicSession session,
String sel, Topic topic) throws
JMSException {
return session.createDurableSubscriber(topic, "Durable Chat", sel, false);
}
public String getSynchronousMessage() {
String msgText = " NO MESSAGE ";
JMSChatSubscriber client = new JMSChatSubscriber();
InitialContext ctx = null;
TopicConnectionFactory factory = null;
Topic topic = null;
TopicConnection connection = null;
TopicSession session = null;
TopicSubscriber subscriber = null;
try {
ctx = client.getInitialContext();
factory = client.lookupTopicConnectionFactory(ctx, connectionFactory);
topic = client.lookupTopic(ctx, topicName);
}
catch (NamingException e) {
e.printStackTrace();
System.exit(1);
}
try {
connection = client.createTopicConnection(factory);
session = client.createTopicSession(connection);
subscriber = client.createTopicSubscriber(session, topic);
connection.start();
Message message = subscriber.receive();
if (message != null) {
try {
if (message instanceof TextMessage) {
msgText = ( (TextMessage) message).getText();
}
else {
msgText = message.toString();
}
// System.out.println(msgText);
return msgText;
}
catch (JMSException jmse) {
jmse.printStackTrace();
}
//return m;
}
}
catch (JMSException e) {
e.printStackTrace();
}
finally {
if (connection != null) {
try {
connection.close();
}
catch (JMSException e) {}
}
}
return msgText;
}
private final static String topicName = "topic/testTopic";
private final static String connectionFactory = "HTTPConnectionFactory";
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.