English 中文(简体)
post message to a remote JMS provider
原标题:

I want to be able to send messages to a remote JBoss server (JBoss MQ).

I can do it for a local one but i m stuck when trying with a remote one.

can anyone explain to me how to do it ? are there any specific steps to take ?

[what i ve tried so far]

I need to send a message to a remote server s queue (running "JBoss MQ") so that it can process the message and act on it.

    Properties properties = new Properties();
    properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
    properties.put(Context.URL_PKG_PREFIXES, "org.jnp.interfaces");
    properties.put(Context.PROVIDER_URL, "jnp://192.168.131.129:1299");
    InitialContext jndiContext = new InitialContext(properties);

    //[2] Look up connection factory and queue.
    ConnectionFactory connectionFactory = (ConnectionFactory)jndiContext.lookup("UIL2XAConnectionFactory");
    Queue queue = (Queue)jndiContext.lookup("Queue/DataTransferQueue");

but I get an exception when running the above code : (even though, I can ping the remote server).

javax.naming.CommunicationException: Could not obtain connection to any of these urls: 192.168.1.131.129:1299 and 
discovery failed with error: javax.naming.CommunicationException: 
Receive timed out [Root exception is java.net.SocketTimeoutException: Receive timed out] 
[Root exception is javax.naming.CommunicationException: Failed to connect to server 192.168.1.131.129:1299 

Is there anything special to do to connect to a remote queue ?

最佳回答

OK, so after trying a lot, I finally found out what the problem was :

I didn t start JBoss on the remote server in a way it could accept remote connections. by default, JBoss starts allowing only local connections.

so, I restarted it with this argument : -b 0.0.0.0 and it works fine now.

Thanks for your help and support.

问题回答

Have you verified that you can connect to that remote host and port, i.e. telnet 192.168.131.129 1299? You might have a firewall that s blocking some traffic but allowing pings.





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签