-
1. Re: JOBSS Messaging POC
jmesnil Apr 23, 2008 9:41 AM (in response to ssjboss)you should have a look at the topic example in JBoss Messaging.
jeff -
2. Re: JOBSS Messaging POC
jmesnil Apr 23, 2008 9:42 AM (in response to ssjboss)err... I meant the *queue* example...
-
3. Re: JOBSS Messaging POC
ssjboss Apr 24, 2008 5:23 AM (in response to ssjboss)
Thanks for reply jiffy.
Now I am able to execute queue example in local system,
My big issue is how can i run listener in remote system, so that if I send a message from my local system remote listener (some another system) must listen to that messages.
Can you please tell me what are the xml files I need to change? ( Here I am confusing.)
For jar files I will fallow 4.4 section of user guide.
4.4. Accessing JBoss Messaging from a remote client
---------
SS -
4. Re: JOBSS Messaging POC
jmesnil Apr 24, 2008 5:39 AM (in response to ssjboss)"ssjboss" wrote:
Thanks for reply jiffy.
Now I am able to execute queue example in local system,
My big issue is how can i run listener in remote system, so that if I send a message from my local system remote listener (some another system) must listen to that messages.
On the client-side, you have to adapt jndi.properties so that the java.naming.provider.url property corresponds to the url of your server. -
5. Re: JOBSS Messaging POC
ssjboss Apr 24, 2008 8:54 AM (in response to ssjboss)i changed jndi props as
### JBossNS properties java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory java.naming.provider.url=jnp://10.12.170.180:1099 java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
From another end(system) how can i see the messages in another system ?
my q listener code is
import java.io.*; import java.util.*; import java.util.Date; import javax.transaction.*; import javax.naming.*; import javax.jms.*; import java.util.Properties; import javax.jms.JMSException; import javax.jms.TextMessage; import javax.jms.Topic; import javax.jms.TopicConnection; import javax.jms.TopicConnectionFactory; import javax.jms.TopicPublisher; import javax.jms.TopicSession; import javax.naming.Context; import javax.naming.InitialContext; import javax.naming.NamingException; import javax.jms.Queue; public class QBrowser { QueueConnectionFactory qconFact; QueueConnection qcon; QueueSession qsession; /* in place of receiver we are using qbrowser here.*/ private QueueBrowser qbrowser; private Queue queue; public void init(Context ctx, String queueName) throws NamingException, JMSException { /* get the connection and create the connection object*/ qconFact=(QueueConnectionFactory) ctx.lookup("MyExampleConnectionFactory"); qcon=qconFact.createQueueConnection(); /* using connection create a non transactional session */ qsession = qcon.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); /* look up for the destination ie queue */ queue = (Queue) ctx.lookup(queueName); // we are using qbrowser here qbrowser = qsession.createBrowser(queue); qcon.start(); } public void displayQueue() throws JMSException { Enumeration e = qbrowser.getEnumeration(); // gets list of messages. Message m = null; if (! e.hasMoreElements()) { System.out.println("There are no messages on this queue."); } else { int ii =0; while (e.hasMoreElements()) { ii++; m = (Message) e.nextElement();// display header System.out.println("Message ID " + m.getJMSMessageID() + " delivered " + new Date(m.getJMSTimestamp()) + " to " + m.getJMSDestination()); System.out.println("\tMessage type " + m.getJMSType() + "Number >>>>" +ii); if (m instanceof TextMessage) { System.out.println("\t TextMessage \"" + ((TextMessage)m).getText() + "\""); } }ii=0; } } public void close() throws JMSException { qbrowser.close(); qsession.close(); qcon.close(); } public static void main(String[] args) throws Exception { //InitialContext ic = getInitialContext(); Properties props = new Properties(); props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory"); props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming"); props.setProperty("java.naming.provider.url", "jnp://localhost:1099"); Context ic = new InitialContext(props); QBrowser qb = new QBrowser(); System.out.println(" Trying to initialize the QBrowser"); qb.init(ic, "queue/testQueue"); qb.displayQueue(); qb.close(); } }
i given all jars acc to user guide.( i did't not found any trove.jar in this path $JBOSS_HOME/server/<SERVER_NAME>/lib/trove.jar)
Please tell me what i am missing.
------
SS -
6. Re: JOBSS Messaging POC
ssjboss Apr 24, 2008 9:02 AM (in response to ssjboss)i am getting q is not having any messages
-
7. Re: JOBSS Messaging POC
jmesnil Apr 24, 2008 9:06 AM (in response to ssjboss)"ssjboss" wrote:
//InitialContext ic = getInitialContext(); Properties props = new Properties(); props.setProperty("java.naming.factory.initial","org.jnp.interfaces.NamingContextFactory"); props.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming"); props.setProperty("java.naming.provider.url", "jnp://localhost:1099");
you still points to localhost. -
8. Re: JOBSS Messaging POC
ssjboss Apr 24, 2008 11:33 AM (in response to ssjboss)
Let me clear
First I sent msg to q from FIRST system 10.17.120.146 (for example) to SECOND System ( 10.17.120.180 ).
By changing jndi props I just ran the ant file by going to jboss messaging queue example, so now msg are in queue which is in 10.17.120.180.
Now i went to SECOND system (10.17.120.180) and I ran the listener (I configured this in eclipse and took all necessary jar files except trove.jar) by giving localhost , is there any issue with this ?
If i give FIRST system ip address i.e (10.17.120.146) I am getting connection error.
(I created my connection factory and queue in both systems for this example.)
Please suggest me in this. -
9. Re: JOBSS Messaging POC
ssjboss Apr 24, 2008 11:39 AM (in response to ssjboss)Here Listener means my QBrower.java
-
10. Re: JOBSS Messaging POC
ssjboss Apr 25, 2008 1:30 AM (in response to ssjboss)F:\jms\jboss messaging\jboss-messaging-1.4.0.SP3\examples\queue>ant
Buildfile: build.xml
identify:
[echo] ####################################################################
#######
[echo] # Running the QUEUE example
#
[echo] ####################################################################
#######
[echo] The queue: testQueue
[echo] The client jar: ../..//jboss-messaging-client.jar
sanity-check:
init:
compile:
[javac] Compiling 1 source file to F:\jms\jboss messaging\jboss-messaging-1.
4.0.SP3\examples\queue\output\classes
run:
[java] Queue /queue/testQueue exists
[java] The message was successfully sent to the testQueue queue
[java] Received message: Hello!
[java] The example connected to JBoss Messaging version 1.4.0.SP3 (1.4)
[java]
[java]
[java] #####################
[java] ### SUCCESS! ###
[java] #####################
BUILD SUCCESSFUL
Total time: 4 seconds
F:\jms\jboss messaging\jboss-messaging-1.4.0.SP3\examples\queue>ant
Buildfile: build.xml
identify:
[echo] ####################################################################
#######
[echo] # Running the QUEUE example
#
[echo] ####################################################################
#######
[echo] The queue: testQueue
[echo] The client jar: ../..//jboss-messaging-client.jar
sanity-check:
init:
compile:
run:
[java] javax.naming.CommunicationException: Could not obtain connection to
any of these urls: 10.12.170.180:1099 and discovery failed with error: javax.nam
ing.CommunicationException: Receive timed out [Root exception is java.net.Socket
TimeoutException: Receive timed out] [Root exception is javax.naming.Communicati
onException: Failed to connect to server 10.12.170.180:1099 [Root exception is j
avax.naming.ServiceUnavailableException: Failed to connect to server 10.12.170.1
80:1099 [Root exception is java.net.ConnectException: Connection refused: connec
t]]]
[java] at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:
1562)
[java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:63
4)
[java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:62
7)
[java] at javax.naming.InitialContext.lookup(InitialContext.java:351)
[java] at org.jboss.example.jms.common.Util.doesDestinationExist(Util.j
ava:55)
[java] at org.jboss.example.jms.common.ExampleSupport.setup(ExampleSupp
ort.java:214)
[java] at org.jboss.example.jms.common.ExampleSupport.setup(ExampleSupp
ort.java:194)
[java] at org.jboss.example.jms.common.ExampleSupport.run(ExampleSuppor
t.java:146)
[java] at org.jboss.example.jms.queue.QueueExample.main(QueueExample.ja
va:135)
[java] Caused by: javax.naming.CommunicationException: Failed to connect to
server 10.12.170.180:1099 [Root exception is javax.naming.ServiceUnavailableExc
eption: Failed to connect to server 10.12.170.180:1099 [Root exception is java.n
et.ConnectException: Connection refused: connect]]
[java] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java
:274)
[java] at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java:
1533)
[java] ... 8 more
[java] Caused by: javax.naming.ServiceUnavailableException: Failed to conne
ct to server 10.12.170.180:1099 [Root exception is java.net.ConnectException: Co
nnection refused: connect]
[java] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java
:248)
[java] ... 9 more
[java] Caused by: java.net.ConnectException: Connection refused: connect
[java] at java.net.PlainSocketImpl.socketConnect(Native Method)
[java] at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
[java] at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.jav
a:195)
[java] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
[java] at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364)
[java] at java.net.Socket.connect(Socket.java:507)
[java] at java.net.Socket.connect(Socket.java:457)
[java] at java.net.Socket.(Socket.java:365)
[java] at java.net.Socket.(Socket.java:265)
[java] at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocke
tFactory.java:84)
[java] at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocke
tFactory.java:77)
[java] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java
:244)
[java] ... 9 more
[java]
[java] #####################
[java] ### FAILURE! ###
[java] #####################
BUILD FAILED
F:\jms\jboss messaging\jboss-messaging-1.4.0.SP3\examples\queue\build.xml:81: Ja
va returned: 1
Total time: 8 seconds
i am getting above error, please help me
--------
-SS -
11. Re: JOBSS Messaging POC
ssjboss Apr 25, 2008 1:30 AM (in response to ssjboss)F:\jms\jboss messaging\jboss-messaging-1.4.0.SP3\examples\queue>ant Buildfile: build.xml identify: [echo] #################################################################### ####### [echo] # Running the QUEUE example # [echo] #################################################################### ####### [echo] The queue: testQueue [echo] The client jar: ../..//jboss-messaging-client.jar sanity-check: init: compile: [javac] Compiling 1 source file to F:\jms\jboss messaging\jboss-messaging-1. 4.0.SP3\examples\queue\output\classes run: [java] Queue /queue/testQueue exists [java] The message was successfully sent to the testQueue queue [java] Received message: Hello! [java] The example connected to JBoss Messaging version 1.4.0.SP3 (1.4) [java] [java] [java] ##################### [java] ### SUCCESS! ### [java] ##################### BUILD SUCCESSFUL Total time: 4 seconds F:\jms\jboss messaging\jboss-messaging-1.4.0.SP3\examples\queue>ant Buildfile: build.xml identify: [echo] #################################################################### ####### [echo] # Running the QUEUE example # [echo] #################################################################### ####### [echo] The queue: testQueue [echo] The client jar: ../..//jboss-messaging-client.jar sanity-check: init: compile: run: [java] javax.naming.CommunicationException: Could not obtain connection to any of these urls: 10.12.170.180:1099 and discovery failed with error: javax.nam ing.CommunicationException: Receive timed out [Root exception is java.net.Socket TimeoutException: Receive timed out] [Root exception is javax.naming.Communicati onException: Failed to connect to server 10.12.170.180:1099 [Root exception is j avax.naming.ServiceUnavailableException: Failed to connect to server 10.12.170.1 80:1099 [Root exception is java.net.ConnectException: Connection refused: connec t]]] [java] at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java: 1562) [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:63 4) [java] at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:62 7) [java] at javax.naming.InitialContext.lookup(InitialContext.java:351) [java] at org.jboss.example.jms.common.Util.doesDestinationExist(Util.j ava:55) [java] at org.jboss.example.jms.common.ExampleSupport.setup(ExampleSupp ort.java:214) [java] at org.jboss.example.jms.common.ExampleSupport.setup(ExampleSupp ort.java:194) [java] at org.jboss.example.jms.common.ExampleSupport.run(ExampleSuppor t.java:146) [java] at org.jboss.example.jms.queue.QueueExample.main(QueueExample.ja va:135) [java] Caused by: javax.naming.CommunicationException: Failed to connect to server 10.12.170.180:1099 [Root exception is javax.naming.ServiceUnavailableExc eption: Failed to connect to server 10.12.170.180:1099 [Root exception is java.n et.ConnectException: Connection refused: connect]] [java] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java :274) [java] at org.jnp.interfaces.NamingContext.checkRef(NamingContext.java: 1533) [java] ... 8 more [java] Caused by: javax.naming.ServiceUnavailableException: Failed to conne ct to server 10.12.170.180:1099 [Root exception is java.net.ConnectException: Co nnection refused: connect] [java] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java :248) [java] ... 9 more [java] Caused by: java.net.ConnectException: Connection refused: connect [java] at java.net.PlainSocketImpl.socketConnect(Native Method) [java] at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333) [java] at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.jav a:195) [java] at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182) [java] at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364) [java] at java.net.Socket.connect(Socket.java:507) [java] at java.net.Socket.connect(Socket.java:457) [java] at java.net.Socket.<init>(Socket.java:365) [java] at java.net.Socket.<init>(Socket.java:265) [java] at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocke tFactory.java:84) [java] at org.jnp.interfaces.TimedSocketFactory.createSocket(TimedSocke tFactory.java:77) [java] at org.jnp.interfaces.NamingContext.getServer(NamingContext.java :244) [java] ... 9 more [java] [java] ##################### [java] ### FAILURE! ### [java] ##################### BUILD FAILED F:\jms\jboss messaging\jboss-messaging-1.4.0.SP3\examples\queue\build.xml:81: Ja va returned: 1 Total time: 8 seconds i am getting above error, please help me -------- -SS
-
12. Re: JOBSS Messaging POC
ssjboss Apr 25, 2008 2:10 AM (in response to ssjboss)here i just changed one line jndi props file
i.e
java.naming.provider.url=jnp://localhost:1099
with
java.naming.provider.url=jnp://10.12.170.154:1099 (this is my system id address...) -
13. Re: JOBSS Messaging POC
timfox Apr 25, 2008 2:33 AM (in response to ssjboss)Please do as Jeff has suggested, also please stop spamming this list with annoying messages about basic JNDI.
If you do not understand how to use JNDI I would suggest buying good JNDI book or doing one of the surely many tutorials on line.
After that, if JBoss JNDI is not working for you, try posting in the JNDI forum. -
14. Re: JOBSS Messaging POC
peterj Apr 25, 2008 11:34 AM (in response to ssjboss)Just a thought: did you start jbossas with the the -b option? If not, what you are doing will not work because jbossas binds to localhost by default, which means that it will not receive any network traffic directed to 10.12.170.154.