[JBoss Messaging Users] - Simple example but failing to get onMessage called
by glynbach
Hi
I wonder if someone could point out what I might be doing wrong here. The JBoss installation is out of the box and running in default mode. The queue seems to be correctly added in the destinations-service.xml (as in I can see it when I do a naming lookup). The producer seems to be sending messages to the queue fine. There aren't any errors subscribing to the queue. But the onMessage isn't getting called.
My code is:
| import java.io.Serializable;
| import java.util.Properties;
|
| import javax.jms.Connection;
| import javax.jms.ConnectionFactory;
| import javax.jms.JMSException;
| import javax.jms.Message;
| import javax.jms.MessageConsumer;
| import javax.jms.MessageListener;
| import javax.jms.MessageProducer;
| import javax.jms.ObjectMessage;
| import javax.jms.Queue;
| import javax.jms.QueueConnection;
| import javax.jms.Session;
| import javax.jms.TextMessage;
| import javax.naming.InitialContext;
| import javax.naming.NamingException;
|
| public class QueueTest {
|
| InitialContext ic = null;
| ConnectionFactory cf = null;
| Queue queue = null;
|
| public static void main(String[] args) {
| new QueueTest();
| }
|
| public QueueTest() {
| try {
| Properties properties = new Properties();
| properties.setProperty("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
| properties.setProperty("java.naming.provider.url", "localhost");
| properties.setProperty("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
| ic = new InitialContext(properties);
|
| cf = (ConnectionFactory)ic.lookup("/ConnectionFactory");
| queue = (Queue)ic.lookup("/queue/FixiOrderQueue");
|
| QueueConsumer consumer = new QueueConsumer();
| consumer.start();
| QueueProducer producer = new QueueProducer();
| producer.start();
|
| } catch (NamingException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| }
| }
|
| private class QueueProducer extends Thread {
|
| Session session = null;
| MessageProducer producer = null;
|
| public QueueProducer() {
| Connection connection;
| try {
| connection = cf.createConnection();
| session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
| producer = session.createProducer(queue);
| } catch (JMSException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| }
| }
|
| public void run() {
| while (true) {
| try {
| Thread.sleep(5000);
| Thread.yield();
| } catch (InterruptedException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| }
| try {
| //ObjectMessage message = session.createObjectMessage();
| //message.setObject(new TestMessage());
| TextMessage message = session.createTextMessage();
| message.setText("Yo");
| producer.send(message);
| System.out.println("Sent message");
| } catch (JMSException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| }
| }
| }
| }
|
| private class QueueConsumer extends Thread implements MessageListener {
|
| public QueueConsumer() {
| try {
| Connection connection = cf.createConnection();
| Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);
| MessageConsumer consumer = session.createConsumer(queue);
| consumer.setMessageListener(this);
| } catch (JMSException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| }
| }
|
| public void run() {
| try {
| Thread.sleep(10);
| Thread.yield();
| } catch (InterruptedException e) {
| // TODO Auto-generated catch block
| e.printStackTrace();
| }
| }
|
| public void onMessage(Message message) {
| System.out.println("Received " + message);
| }
| }
|
| private class TestMessage implements Serializable {
|
| private long systemTimeInMillis;
|
| public TestMessage() {
| systemTimeInMillis = System.currentTimeMillis();
| }
|
| public long getSystemTimeInMillis() {
| return systemTimeInMillis;
| }
|
| public void setSystemTimeInMillis(long systemTimeInMillis) {
| this.systemTimeInMillis = systemTimeInMillis;
| }
|
| }
| }
|
The System.out is below, if anything looks out of place in it please let me know. Thanks for any advice
DEBUG [01 Dec 2009 15:14:39,160] - createSocket, hostAddr: localhost/127.0.0.1, port: 1099, localAddr: null, localPort: 0, timeout: 0
DEBUG [01 Dec 2009 15:14:39,919] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:39,920] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:39,920] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:39,920] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] constructed
DEBUG [01 Dec 2009 15:14:39,920] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:39,921] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:39,921] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:39,922] - Setting ping frequency to: 214748364
DEBUG [01 Dec 2009 15:14:39,923] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] connecting
DEBUG [01 Dec 2009 15:14:39,923] - Creating semaphore with size 50
DEBUG [01 Dec 2009 15:14:39,926] - SocketClientInvoker[1f950198, bisocket://127.0.0.1:4457] connected
DEBUG [01 Dec 2009 15:14:40,537] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting maxPoolSize to 200
DEBUG [01 Dec 2009 15:14:40,537] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:40,537] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:40,537] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:40,538] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] constructed
DEBUG [01 Dec 2009 15:14:40,541] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting maxPoolSize to 200
DEBUG [01 Dec 2009 15:14:40,541] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:40,541] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:40,542] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:40,542] - Setting ping frequency to: 214748364
DEBUG [01 Dec 2009 15:14:40,542] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] connecting
DEBUG [01 Dec 2009 15:14:40,542] - Creating semaphore with size 200
DEBUG [01 Dec 2009 15:14:40,542] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] connected
DEBUG [01 Dec 2009 15:14:40,680] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting maxPoolSize to 1
DEBUG [01 Dec 2009 15:14:40,680] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:40,680] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:40,680] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:40,680] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] constructed
DEBUG [01 Dec 2009 15:14:40,771] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting maxPoolSize to 1
DEBUG [01 Dec 2009 15:14:40,771] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:40,771] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:40,772] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:40,772] - Setting ping frequency to: 214748364
DEBUG [01 Dec 2009 15:14:40,772] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] connecting
DEBUG [01 Dec 2009 15:14:40,772] - Creating semaphore with size 1
DEBUG [01 Dec 2009 15:14:40,772] - SocketClientInvoker[62c2ee15, bisocket://127.0.0.1:4457] connected
DEBUG [01 Dec 2009 15:14:40,807] - starting callback Connector: InvokerLocator [bisocket://192.168.0.7:1743590291/callback?callbackServerHost=192.168.0.7&callbackServerPort=1743590291&callbackServerProtocol=bisocket&clientMaxPoolSize=1&clientSocketClass=org.jboss.jms.client.remoting.ClientSocketWrapper&datatype=jms&guid=5c4o07-4avrks-g2ot8evd-1-g2ot8fm2-8&isCallbackServer=true&onewayThreadPool=org.jboss.jms.server.remoting.DirectThreadPool&serverSocketClass=org.jboss.jms.server.remoting.ServerSocketWrapper]
DEBUG [01 Dec 2009 15:14:40,880] - SocketServerInvoker[192.168.0.7:1743590291] did not find server socket factory configuration as mbean service or classname. Creating default server socket factory.
DEBUG [01 Dec 2009 15:14:40,881] - SocketServerInvoker[192.168.0.7:1743590291] created server socket factory javax.net.DefaultServerSocketFactory@5a199939
DEBUG [01 Dec 2009 15:14:40,881] - SocketServerInvoker[192.168.0.7:1743590291] setting pingFrequency to 214748364
DEBUG [01 Dec 2009 15:14:40,881] - SocketServerInvoker[192.168.0.7:1743590291] setting pingWindowFactor to 10
DEBUG [01 Dec 2009 15:14:40,886] - org.jboss.remoting.transport.Connector@651db6bb started
DEBUG [01 Dec 2009 15:14:40,895] - ServerInvoker (SocketServerInvoker[192.168.0.7:1743590291]) added client callback handler CallbackManager[71bfc4fc] with session id of 5c4o07-4avrks-g2ot8evd-1-g2ot8fdc-4+5c4o07-4avrks-g2ot8evd-1-g2ot8fp3-9 and callback handle object of null.
DEBUG [01 Dec 2009 15:14:40,896] - removed org.jboss.remoting.transport.local.LocalClientInvoker@506835fb from registry
DEBUG [01 Dec 2009 15:14:40,896] - getting secondary locator
DEBUG [01 Dec 2009 15:14:40,904] - secondary locator: InvokerLocator [null://127.0.0.1:4017/?]
DEBUG [01 Dec 2009 15:14:40,904] - creating control connection: InvokerLocator [null://127.0.0.1:4017/?]
DEBUG [01 Dec 2009 15:14:40,907] - SocketServerInvoker[192.168.0.7:1743590291] created control connection (5c4o07-4avrks-g2ot8evd-1-g2ot8fp3-9): Socket[addr=/127.0.0.1,port=4017,localport=50346]
DEBUG [01 Dec 2009 15:14:41,045] - ConnectionValidator[7054f9f1:null, pingPeriod=10000 ms] created
DEBUG [01 Dec 2009 15:14:41,045] - ConnectionValidator[7054f9f1:null, pingPeriod=10000 ms]: pingPeriod: 10000
DEBUG [01 Dec 2009 15:14:41,045] - ConnectionValidator[7054f9f1:null, pingPeriod=10000 ms]: pingTimeout: 5000
DEBUG [01 Dec 2009 15:14:41,046] - ConnectionValidator[7054f9f1:null, pingPeriod=10000 ms]: ping retries: 1
DEBUG [01 Dec 2009 15:14:41,055] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:41,056] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:41,056] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:41,056] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] constructed
DEBUG [01 Dec 2009 15:14:41,056] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] setting client socket wrapper class name to org.jboss.jms.client.remoting.ClientSocketWrapper
DEBUG [01 Dec 2009 15:14:41,056] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] setting shouldCheckConnection to false
DEBUG [01 Dec 2009 15:14:41,056] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] setting timeout to 0
DEBUG [01 Dec 2009 15:14:41,056] - Setting ping frequency to: 214748364
DEBUG [01 Dec 2009 15:14:41,056] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] connecting
DEBUG [01 Dec 2009 15:14:41,057] - SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457] connected
DEBUG [01 Dec 2009 15:14:41,058] - ConnectionValidator[7054f9f1:SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457], pingPeriod=10000 ms] started
DEBUG [01 Dec 2009 15:14:41,573] - SocketClientInvoker[da0225b, bisocket://127.0.0.1:4457] added client with session ID 5c4o07-4avrks-g2ot8evd-1-g2ot8g81-d to the lease pinger
DEBUG [01 Dec 2009 15:14:41,574] - starting callback Connector: InvokerLocator [bisocket://192.168.0.7:1744242764/callback?callbackServerHost=192.168.0.7&callbackServerPort=1744242764&callbackServerProtocol=bisocket&clientMaxPoolSize=1&clientSocketClass=org.jboss.jms.client.remoting.ClientSocketWrapper&datatype=jms&guid=5c4o07-4avrks-g2ot8evd-1-g2ot8g85-f&isCallbackServer=true&onewayThreadPool=org.jboss.jms.server.remoting.DirectThreadPool&serverSocketClass=org.jboss.jms.server.remoting.ServerSocketWrapper]
DEBUG [01 Dec 2009 15:14:41,583] - SocketServerInvoker[192.168.0.7:1744242764] did not find server socket factory configuration as mbean service or classname. Creating default server socket factory.
DEBUG [01 Dec 2009 15:14:41,583] - SocketServerInvoker[192.168.0.7:1744242764] created server socket factory javax.net.DefaultServerSocketFactory@5a199939
DEBUG [01 Dec 2009 15:14:41,584] - SocketServerInvoker[192.168.0.7:1744242764] setting pingFrequency to 214748364
DEBUG [01 Dec 2009 15:14:41,584] - SocketServerInvoker[192.168.0.7:1744242764] setting pingWindowFactor to 10
DEBUG [01 Dec 2009 15:14:41,584] - org.jboss.remoting.transport.Connector@3496212a started
DEBUG [01 Dec 2009 15:14:41,584] - ServerInvoker (SocketServerInvoker[192.168.0.7:1744242764]) added client callback handler CallbackManager[525c7734] with session id of 5c4o07-4avrks-g2ot8evd-1-g2ot8g81-d+5c4o07-4avrks-g2ot8evd-1-g2ot8g8g-g and callback handle object of null.
DEBUG [01 Dec 2009 15:14:41,585] - removed org.jboss.remoting.transport.local.LocalClientInvoker@6c5b675e from registry
DEBUG [01 Dec 2009 15:14:41,585] - getting secondary locator
DEBUG [01 Dec 2009 15:14:41,587] - secondary locator: InvokerLocator [null://127.0.0.1:4017/?]
DEBUG [01 Dec 2009 15:14:41,587] - creating control connection: InvokerLocator [null://127.0.0.1:4017/?]
DEBUG [01 Dec 2009 15:14:41,587] - SocketServerInvoker[192.168.0.7:1744242764] created control connection (5c4o07-4avrks-g2ot8evd-1-g2ot8g8g-g): Socket[addr=/127.0.0.1,port=4017,localport=50347]
DEBUG [01 Dec 2009 15:14:41,599] - ConnectionValidator[ad72200:null, pingPeriod=10000 ms] created
DEBUG [01 Dec 2009 15:14:41,599] - ConnectionValidator[ad72200:null, pingPeriod=10000 ms]: pingPeriod: 10000
DEBUG [01 Dec 2009 15:14:41,599] - ConnectionValidator[ad72200:null, pingPeriod=10000 ms]: pingTimeout: 5000
DEBUG [01 Dec 2009 15:14:41,599] - ConnectionValidator[ad72200:null, pingPeriod=10000 ms]: ping retries: 1
DEBUG [01 Dec 2009 15:14:41,600] - ConnectionValidator[ad72200:SocketClientInvoker[301db5ec, bisocket://127.0.0.1:4457], pingPeriod=10000 ms] started
Sent message
Sent message
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4268322#4268322
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4268322
15 years, 1 month
[JBoss Web Services Users] - Re: Newbie: Empty ArrayList Passed on WS Call
by gwzoller
Here's the rest of the story. I finally stumbled on the right recipe, and here 'tis. I was over-complicating things. Removing almost all the annotations fixed both the list-passing and the WSDL.
Interface:
import java.util.ArrayList;
| import javax.ejb.Remote; // for the EJB
| import javax.jws.WebService; // for the web service
| import com.kepler.ecom.domain.OrderLine;
|
| @Remote
| @WebService
| public interface OrderTakerRemote {
| public String msg(ArrayList<String> say);
| }
Implementation:
import javax.ejb.Stateless;
| import javax.jws.WebService;
| import com.aviall.kepler.ecom.domain.OrderLine;
| import com.aviall.kepler.ecom.services.OrderTakerRemote;
| import java.util.ArrayList;
|
| @WebService
| @Stateless
| public class OrderTaker implements OrderTakerRemote {
| public OrderTaker() {
| }
|
| public String msg(ArrayList<String> say) {
| // Use the list here
| }
| }
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4268317#4268317
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4268317
15 years, 1 month
[Installation, Configuration & Deployment] - InvokerLocator configuration
by tjansto
morning folk,
when doing lookup of a particular bean , i am getting an exception on a client accessing my jboss 5.1 app server of the type:
Root exception is org.jboss.remoting.CannotConnectException: Can not get connection to server. Problem establishing socket connection for InvokerLocator [socket://jboss5x.domain.name:3873/]]
this makes sense, since the jboss5x.domain.name is not accessible to the client. i have previously had a jboss 4.x server configured to use a pooled invoker that did the lookups via an https invoker service. i have made the same configuration changes (i.e:
http-invoker.sar/WEB-INF/jboss-service.xml
standardjboss.xml set to use hunifiedHA invoker
remoting-jboss-beans.xml configured to use the public ip of the vip we set up for the clientConnectAddress, 443 for the clientConnectPort
these are the main config files i seem to have needed to modify to make this work, and as long as my connection client is on the lan where it can make a connection on port 3873 to the box physically, the lookups all work fine. the client is using java.naming.provider.url of https://public.address.vip/invoker/JNDIFactory which is working properly, but once the initial context is retrieved, the bean lookup seems to "fall back" (and i know its doing it because of how i have it configured) to trying to make a socket connection to the app server itself on that port, which is not available outside the firewall. i have gone through the docs on the wiki at http://www.jboss.org/community/wiki/UsingJBossBehindAFirewall and the one about configuring rmi over http (cant remember the exact url),and the pdf remoting guide. things seem ok, but aren't. can anyone provide me some additional areas to look into? i was wondering about changes in the constructor section of the remoting-jboss-beans.xml file, particularly in regards to changing the transport to something other than socket, but i'm not exactly sure of the impact or domino effect of additional configs that would need to be made (don't' care to make them, but i'm just no sure what they are and their dependencies...)
anyways, thanks for the time
tom
View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4268313#4268313
Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4268313
15 years, 1 month