Problem while sending messages to Queue/B
mlsreekanth Mar 11, 2004 5:10 AMHi all,
I have deployed a workflow engine into JBOSS with jetty. This Workflow engine uses the default queues like Queue/A, Queue/B...etc.
Now, i want to send messages to the queues where MDBs are listening to these queues which may invoke Workflow engine. When, i send messages to these queues in LAN, it is working fine,
When, i send messages through the internet it was giving connection refused error.
JBOSS is running WIN2K Server.
It was behind a NAT router and router is using firewall. We configured the ports 8080,1099, 8090-8093 in the router.
When i triewd to access the workflow engine from outside with external ip, like http://ext_ip:8080/workflow/
it is working fine.
Now, i am sending messages using the following code,
/*
* MsgSender.java
*
* Created on February 23, 2004, 5:46 PM
*/
/**
*
* @author Administrator
*/
import javax.jms.*;
import javax.naming.*;
import org.apache.log4j.*;
import java.util.*;
public class MsgSender {
private String destinationJndiName = "queue/B";
private String connectionFactoryJndiName = "UILConnectionFactory";
private String urlPkgPrefixes = "org.jboss.naming:org.jnp.interfaces";
/** Creates a new instance of MsgSender */
public MsgSender() {
}
public static void main(String args[]) {
MsgSender msgSender = new MsgSender();
msgSender.sendMessage(null);
}
public void sendMessage(HashMap msg){
QueueConnection queueConnection = null;
QueueSession queueSession = null;
QueueSender queueSender = null;
try {
try {
Context jndiContext = null;
// jndiContext = new InitialContext();
//JNDIParm.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes );
java.util.Hashtable JNDIParm = new java.util.Hashtable();
JNDIParm.put(Context.PROVIDER_URL, "jnp://ext_ip:1099/");
JNDIParm.put(Context.URL_PKG_PREFIXES, urlPkgPrefixes );
JNDIParm.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
jndiContext = new InitialContext(JNDIParm);
System.out.println(jndiContext+"JNDI Properties "+jndiContext.getEnvironment()+" Provider URL is "+jndiContext.PROVIDER_URL);
//destinationJndiName = getDestinationJndiName(destinationJndiName);
// InitialContext jndiContext = new InitialContext();
System.out.println("Jndi context name "+jndiContext.getNameInNamespace());
QueueConnectionFactory queueConnectionFactory = (QueueConnectionFactory) jndiContext.lookup(connectionFactoryJndiName);
queueConnection = queueConnectionFactory.createQueueConnection();
queueSession = queueConnection.createQueueSession( false, Session.AUTO_ACKNOWLEDGE );
System.out.println("After creatinbg the queue session");
Queue queue = (Queue) jndiContext.lookup(destinationJndiName);
queueSender = queueSession.createSender(queue);
queueConnection.start();
ObjectMessage message;
// TextMessage textMessage = queueSession.createTextMessage();
//textMessage.setText("Hello world" );
message = queueSession.createObjectMessage();
message.setObject(msg);
//log.debug( "sending the message... ");
queueSender.send(message);
//log.debug( "message sent. ");
System.out.println( message.getJMSMessageID());
//interactionContext.log( "message '" + textMessage.getJMSMessageID() + "' was sent to queue '" + destinationJndiName + "'" );
} finally {
if ( queueSender != null ) queueSender.close();
if ( queueSession != null ) queueSession.close();
if ( queueConnection != null ) queueConnection.close();
}
} catch (Exception e) {
e.printStackTrace();
//e.prerror("error in performing jms tasks :", e);
}
}
}
But, it is giving the following error stating that the internal ip is not responding.
this is the actual stack trace
javax.naming.CommunicationException [Root exception is java.rmi.ConnectException: Connection refused to host: 192.168.123.2;
nested exception is:
java.net.ConnectException: Connection timed out: connect]
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:611)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:471)
at javax.naming.InitialContext.lookup(InitialContext.java:347)
at MsgSender.sendMessage(MsgSender.java:78)
at InternationalCaseSend$CaseSenderThread.run(InternationalCaseSend.java:301)
Caused by: java.rmi.ConnectException: Connection refused to host: 192.168.123.2; nested exception is:
java.net.ConnectException: Connection timed out: connect
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:567)
at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:101)
at org.jnp.server.NamingServer_Stub.lookup(Unknown Source)
at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:492)
... 4 more
Caused by: java.net.ConnectException: Connection timed out: connect
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:305)
at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:171)
at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:158)
at java.net.Socket.connect(Socket.java:452)
at java.net.Socket.connect(Socket.java:402)
at java.net.Socket.(Socket.java:309)
at java.net.Socket.(Socket.java:124)
at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:562)
... 9 more
Kindly, help me in this regard.
Thanks in advance.
Srikanth