You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by avin98 <av...@yahoo.com> on 2006/07/10 22:56:20 UTC

Active MQ 3.2.1 QueueSender

When you try to send a message to a queue in ActiveMQ 3.2.2 (bundled along
with geronimo), it doesn't work the first time.

Why is this ??? I faced the same problem with the samples as well, when I
try to send message from a servlet.

Here is the code snippet that does that:

        QueueSession session = null;
        QueueSender sender = null;
        TextMessage message = null;
        String correlationId = null;
        QueueConnection connection = null;
        String connectionFactoryName = "java:comp/env/jms/broker";
        String queueName = "java:comp/env/jms/queue/OutboundQueue";
        try {

            InitialContext naming = new InitialContext();

            // lookup queue connection factory
            QueueConnectionFactory connectionFactory =
(QueueConnectionFactory) naming
                .lookup(connectionFactoryName);

            // create jms connection
            connection = connectionFactory
                .createQueueConnection();

            // System.out.println("Connection is:"+ connection);

            // lookup jms queue
            Queue queue = (Queue) naming.lookup(queueName);

            // create a session.
            session = connection.createQueueSession(false,
                Session.AUTO_ACKNOWLEDGE);

            // create a QueueSender
            sender = session.createSender(queue);
            sender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
            
            // create a message to send to the queue...
            message = session.createTextMessage();
            
            message.setText(dataStream);
 

            // send
            sender.send(message);
            
            // store the messageID as correlationID
            correlationId = message.getJMSMessageID();
            
            

        } catch (Exception je) {
            je.printStackTrace();

        } finally {
            try {
                if (sender != null)
                    sender.close();
                if (session != null)
                    session.close();
                if(connection !=null)
                    connection.close();
             } catch (JMSException je) {
                je.printStackTrace();

            }
        }
 
-- 
View this message in context: http://www.nabble.com/Active-MQ-3.2.1-QueueSender-tf1920777.html#a5259006
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Active MQ 3.2.1 QueueSender

Posted by avin98 <av...@yahoo.com>.
After enabling the TACE logging:

Here is what I get:



10:23:29,069 WARN  [TransportChannelSupport] Caught exception dispatching
message and no ExceptionListener registered: javax.jms.JMSException: Error
reading socket: java.io.EOFException
javax.jms.JMSException: Error reading socket: java.io.EOFException
	at
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:49)
	at
org.activemq.transport.tcp.TcpTransportChannel.doClose(TcpTransportChannel.java:509)
	at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:330)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException
	at java.io.DataInputStream.readByte(Unknown Source)
	at
org.activemq.io.AbstractWireFormat.readPacket(AbstractWireFormat.java:230)
	at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:313)
	... 1 more
10:23:29,069 DEBUG [ActiveMQManagedConnection] Cause: 
javax.jms.JMSException: Error reading socket: java.io.EOFException
	at
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:49)
	at
org.activemq.transport.tcp.TcpTransportChannel.doClose(TcpTransportChannel.java:509)
	at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:330)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException
	at java.io.DataInputStream.readByte(Unknown Source)
	at
org.activemq.io.AbstractWireFormat.readPacket(AbstractWireFormat.java:230)
	at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:313)
	... 1 more
10:23:29,069 WARN  [GeronimoConnectionEventListener] connectionErrorOccurred
called with null
javax.jms.JMSException: Error reading socket: java.io.EOFException
	at
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:49)
	at
org.activemq.transport.tcp.TcpTransportChannel.doClose(TcpTransportChannel.java:509)
	at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:330)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException
	at java.io.DataInputStream.readByte(Unknown Source)
	at
org.activemq.io.AbstractWireFormat.readPacket(AbstractWireFormat.java:230)
	at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:313)
	... 1 more
10:23:29,069 DEBUG [ActiveMQAsfEndpointWorker] Reconnect cause: 
javax.jms.JMSException: Error reading socket: java.io.EOFException
	at
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:49)
	at
org.activemq.transport.tcp.TcpTransportChannel.doClose(TcpTransportChannel.java:509)
	at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:330)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException
	at java.io.DataInputStream.readByte(Unknown Source)
	at
org.activemq.io.AbstractWireFormat.readPacket(AbstractWireFormat.java:230)
	at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:313)
	... 1 more
10:23:29,069 WARN  [TransportChannelSupport] Caught exception dispatching
message and no ExceptionListener registered: javax.jms.JMSException: Error
reading socket: java.io.EOFException
javax.jms.JMSException: Error reading socket: java.io.EOFException
	at
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:49)
	at
org.activemq.transport.tcp.TcpTransportChannel.doClose(TcpTransportChannel.java:509)
	at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:330)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.io.EOFException
	at java.io.DataInputStream.readByte(Unknown Source)
	at
org.activemq.io.AbstractWireFormat.readPacket(AbstractWireFormat.java:230)
	at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:313)
	... 1 more
10:23:29,069 INFO  [ActiveMQManagedConnection] Error occured during close of
a JMS connection.
javax.jms.JMSException: syncSendTimedOut: connection no longer OK
	at
org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1403)
	at
org.activemq.ActiveMQConnection.sendConnectionInfoToBroker(ActiveMQConnection.java:1628)
	at org.activemq.ActiveMQConnection.close(ActiveMQConnection.java:763)
	at
org.activemq.ra.ActiveMQManagedConnection.destroy(ActiveMQManagedConnection.java:225)
	at
org.apache.geronimo.connector.outbound.MCFConnectionInterceptor.returnConnection(MCFConnectionInterceptor.java:57)
	at
org.apache.geronimo.connector.outbound.XAResourceInsertionInterceptor.returnConnection(XAResourceInsertionInterceptor.java:47)
	at
org.apache.geronimo.connector.outbound.SinglePoolConnectionInterceptor.internalReturn(SinglePoolConnectionInterceptor.java:162)
	at
org.apache.geronimo.connector.outbound.AbstractSinglePoolConnectionInterceptor.returnConnection(AbstractSinglePoolConnectionInterceptor.java:119)
	at
org.apache.geronimo.connector.outbound.TransactionEnlistingInterceptor.returnConnection(TransactionEnlistingInterceptor.java:94)
	at
org.apache.geronimo.connector.outbound.TransactionCachingInterceptor.returnConnection(TransactionCachingInterceptor.java:93)
	at
org.apache.geronimo.connector.outbound.ConnectionHandleInterceptor.returnConnection(ConnectionHandleInterceptor.java:71)
	at
org.apache.geronimo.connector.outbound.TCCLInterceptor.returnConnection(TCCLInterceptor.java:50)
	at
org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor.returnConnection(ConnectionTrackingInterceptor.java:82)
	at
org.apache.geronimo.connector.outbound.GeronimoConnectionEventListener.connectionErrorOccurred(GeronimoConnectionEventListener.java:81)
	at
org.activemq.ra.ActiveMQManagedConnection.fireErrorOccurredEvent(ActiveMQManagedConnection.java:192)
	at
org.activemq.ra.ActiveMQManagedConnection.onException(ActiveMQManagedConnection.java:409)
	at
org.activemq.transport.TransportChannelSupport.onAsyncException(TransportChannelSupport.java:445)
	at
org.activemq.transport.tcp.TcpTransportChannel.doClose(TcpTransportChannel.java:509)
	at
org.activemq.transport.tcp.TcpTransportChannel.run(TcpTransportChannel.java:330)
	at java.lang.Thread.run(Unknown Source)
10:23:29,085 DEBUG [JournalMessageStore] removedFromJournal=0
10:23:29,085 DEBUG [JournalMessageStore] Checkpoint: JMS-QUEUE-OUTBOUND
10:23:29,085 DEBUG [JournalMessageStore] Added 0 message(s) and removed 0
message(s). removedFromJournal=0
10:23:29,085 DEBUG [JournalMessageStore] In flight journal locations: []
10:23:29,085 DEBUG [JournalMessageStore] removedFromJournal=0
10:23:29,085 DEBUG [JournalMessageStore] Checkpoint: JMS-QUEUE-INBOUND
10:23:29,085 DEBUG [JournalMessageStore] Added 0 message(s) and removed 0
message(s). removedFromJournal=0
10:23:29,085 DEBUG [JournalMessageStore] In flight journal locations: []
10:23:29,085 DEBUG [JournalMessageStore] removedFromJournal=0
10:23:29,085 DEBUG [JournalMessageStore] Checkpoint: JMS-QUEUE-STREAM
10:23:29,085 DEBUG [JournalMessageStore] Added 0 message(s) and removed 0
message(s). removedFromJournal=0
10:23:29,085 DEBUG [JournalMessageStore] In flight journal locations: []
10:23:31,132 DEBUG [ActiveMQAsfEndpointWorker] Reconnect cause: 
javax.jms.JMSException: Initialization of TcpTransportChannel failed. URI
was: tcp://0.0.0.0:61616 Reason: java.net.ConnectException: Connection
refused: connect
	at
org.activemq.util.JMSExceptionHelper.newJMSException(JMSExceptionHelper.java:49)
	at
org.activemq.transport.tcp.TcpTransportChannel.<init>(TcpTransportChannel.java:107)
	at
org.activemq.transport.tcp.TcpTransportChannelFactory.create(TcpTransportChannelFactory.java:43)
	at
org.activemq.ActiveMQConnectionFactory.createTransportChannel(ActiveMQConnectionFactory.java:827)
	at
org.activemq.ActiveMQConnectionFactory.createConnection(ActiveMQConnectionFactory.java:608)
	at
org.activemq.ra.ActiveMQResourceAdapter.makeConnection(ActiveMQResourceAdapter.java:137)
	at
org.activemq.ra.ActiveMQAsfEndpointWorker$1.run(ActiveMQAsfEndpointWorker.java:79)
	at
org.apache.geronimo.connector.work.WorkerContext.run(WorkerContext.java:291)
	at EDU.oswego.cs.dl.util.concurrent.PooledExecutor$Worker.run(Unknown
Source)
	at java.lang.Thread.run(Unknown Source)
Caused by: java.net.ConnectException: Connection refused: connect
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.PlainSocketImpl.doConnect(Unknown Source)
	at java.net.PlainSocketImpl.connectToAddress(Unknown Source)
	at java.net.PlainSocketImpl.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at java.net.Socket.connect(Unknown Source)
	at
org.activemq.transport.tcp.TcpTransportChannel.createSocket(TcpTransportChannel.java:565)
	at
org.activemq.transport.tcp.TcpTransportChannel.<init>(TcpTransportChannel.java:103)
	... 8 more
10:23:33,132 INFO  [ActiveMQManagedConnection] Error occured during close of
a JMS connection.
javax.jms.JMSException: syncSendTimedOut: connection no longer OK
	at
org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1403)
	at
org.activemq.ActiveMQConnection.sendConnectionInfoToBroker(ActiveMQConnection.java:1628)
	at org.activemq.ActiveMQConnection.close(ActiveMQConnection.java:763)
	at
org.activemq.ra.ActiveMQManagedConnection.destroy(ActiveMQManagedConnection.java:225)
	at
org.apache.geronimo.connector.outbound.SinglePoolConnectionInterceptor.internalDestroy(SinglePoolConnectionInterceptor.java:121)
	at
org.apache.geronimo.connector.outbound.AbstractSinglePoolConnectionInterceptor.destroy(AbstractSinglePoolConnectionInterceptor.java:138)
	at
org.apache.geronimo.connector.outbound.TransactionEnlistingInterceptor.destroy(TransactionEnlistingInterceptor.java:98)
	at
org.apache.geronimo.connector.outbound.TransactionCachingInterceptor.destroy(TransactionCachingInterceptor.java:113)
	at
org.apache.geronimo.connector.outbound.ConnectionHandleInterceptor.destroy(ConnectionHandleInterceptor.java:75)
	at
org.apache.geronimo.connector.outbound.TCCLInterceptor.destroy(TCCLInterceptor.java:57)
	at
org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor.destroy(ConnectionTrackingInterceptor.java:86)
	at
org.apache.geronimo.connector.outbound.AbstractConnectionManager.doStop(AbstractConnectionManager.java:165)
	at
org.apache.geronimo.gbean.runtime.GBeanInstance.destroyInstance(GBeanInstance.java:1079)
	at
org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStop(GBeanInstanceState.java:395)
	at
org.apache.geronimo.gbean.runtime.GBeanInstanceState.stop(GBeanInstanceState.java:200)
	at
org.apache.geronimo.gbean.runtime.GBeanInstance.stop(GBeanInstance.java:545)
	at
org.apache.geronimo.kernel.basic.BasicKernel.stopGBean(BasicKernel.java:213)
	at
org.apache.geronimo.gbean.runtime.GBeanInstanceState.stop(GBeanInstanceState.java:192)
	at
org.apache.geronimo.gbean.runtime.GBeanInstance.stop(GBeanInstance.java:545)
	at
org.apache.geronimo.kernel.basic.BasicKernel.stopGBean(BasicKernel.java:213)
	at
org.apache.geronimo.gbean.runtime.GBeanInstanceState.stop(GBeanInstanceState.java:192)
	at
org.apache.geronimo.gbean.runtime.GBeanInstance.stop(GBeanInstance.java:545)
	at
org.apache.geronimo.kernel.basic.BasicKernel.stopGBean(BasicKernel.java:213)
	at
org.apache.geronimo.gbean.runtime.GBeanInstanceState.stop(GBeanInstanceState.java:192)
	at
org.apache.geronimo.gbean.runtime.GBeanInstance.stop(GBeanInstance.java:545)
	at
org.apache.geronimo.kernel.basic.BasicKernel.stopGBean(BasicKernel.java:213)
	at
org.apache.geronimo.gbean.runtime.GBeanInstanceState.stop(GBeanInstanceState.java:192)
	at
org.apache.geronimo.gbean.runtime.GBeanInstance.stop(GBeanInstance.java:545)
	at
org.apache.geronimo.kernel.basic.BasicKernel.stopGBean(BasicKernel.java:213)
	at
org.apache.geronimo.gbean.runtime.GBeanInstanceState.stop(GBeanInstanceState.java:192)
	at
org.apache.geronimo.gbean.runtime.GBeanInstance.stop(GBeanInstance.java:545)
	at
org.apache.geronimo.kernel.basic.BasicKernel.stopGBean(BasicKernel.java:213)
	at
org.apache.geronimo.kernel.config.ConfigurationManagerImpl$ShutdownHook.run(ConfigurationManagerImpl.java:287)
	at
org.apache.geronimo.kernel.basic.BasicKernel.notifyShutdownHooks(BasicKernel.java:406)
	at
org.apache.geronimo.kernel.basic.BasicKernel.shutdown(BasicKernel.java:383)
	at org.apache.geronimo.system.main.Daemon$1.run(Daemon.java:296)
10:23:33,147 INFO  [ActiveMQManagedConnection] Error occured during close of
a JMS connection.
javax.jms.JMSException: syncSendTimedOut: connection no longer OK
	at
org.activemq.ActiveMQConnection.syncSendPacket(ActiveMQConnection.java:1403)
	at
org.activemq.ActiveMQConnection.sendConnectionInfoToBroker(ActiveMQConnection.java:1628)
	at org.activemq.ActiveMQConnection.close(ActiveMQConnection.java:763)
	at
org.activemq.ra.ActiveMQManagedConnection.destroy(ActiveMQManagedConnection.java:225)
	at
org.apache.geronimo.connector.outbound.SinglePoolConnectionInterceptor.internalDestroy(SinglePoolConnectionInterceptor.java:121)
	at
org.apache.geronimo.connector.outbound.AbstractSinglePoolConnectionInterceptor.destroy(AbstractSinglePoolConnectionInterceptor.java:138)
	at
org.apache.geronimo.connector.outbound.TransactionEnlistingInterceptor.destroy(TransactionEnlistingInterceptor.java:98)
	at
org.apache.geronimo.connector.outbound.TransactionCachingInterceptor.destroy(TransactionCachingInterceptor.java:113)
	at
org.apache.geronimo.connector.outbound.ConnectionHandleInterceptor.destroy(ConnectionHandleInterceptor.java:75)
	at
org.apache.geronimo.connector.outbound.TCCLInterceptor.destroy(TCCLInterceptor.java:57)
	at
org.apache.geronimo.connector.outbound.ConnectionTrackingInterceptor.destroy(ConnectionTrackingInterceptor.java:86)
	at
org.apache.geronimo.connector.outbound.AbstractConnectionManager.doStop(AbstractConnectionManager.java:165)
	at
org.apache.geronimo.gbean.runtime.GBeanInstance.destroyInstance(GBeanInstance.java:1079)
	at
org.apache.geronimo.gbean.runtime.GBeanInstanceState.attemptFullStop(GBeanInstanceState.java:395)
	at
org.apache.geronimo.gbean.runtime.GBeanInstanceState.stop(GBeanInstanceState.java:200)
	at
org.apache.geronimo.gbean.runtime.GBeanInstance.stop(GBeanInstance.java:545)
	at
org.apache.geronimo.kernel.basic.BasicKernel.stopGBean(BasicKernel.java:213)
	at
org.apache.geronimo.gbean.runtime.GBeanInstanceState.stop(GBeanInstanceState.java:192)
	at
org.apache.geronimo.gbean.runtime.GBeanInstance.stop(GBeanInstance.java:545)
	at
org.apache.geronimo.kernel.basic.BasicKernel.stopGBean(BasicKernel.java:213)
	at
org.apache.geronimo.gbean.runtime.GBeanInstanceState.stop(GBeanInstanceState.java:192)
	at
org.apache.geronimo.gbean.runtime.GBeanInstance.stop(GBeanInstance.java:545)
	at
org.apache.geronimo.kernel.basic.BasicKernel.stopGBean(BasicKernel.java:213)
	at
org.apache.geronimo.gbean.runtime.GBeanInstanceState.stop(GBeanInstanceState.java:192)
	at
org.apache.geronimo.gbean.runtime.GBeanInstance.stop(GBeanInstance.java:545)
	at
org.apache.geronimo.kernel.basic.BasicKernel.stopGBean(BasicKernel.java:213)
	at
org.apache.geronimo.gbean.runtime.GBeanInstanceState.stop(GBeanInstanceState.java:192)
	at
org.apache.geronimo.gbean.runtime.GBeanInstance.stop(GBeanInstance.java:545)
	at
org.apache.geronimo.kernel.basic.BasicKernel.stopGBean(BasicKernel.java:213)
	at
org.apache.geronimo.gbean.runtime.GBeanInstanceState.stop(GBeanInstanceState.java:192)
	at
org.apache.geronimo.gbean.runtime.GBeanInstance.stop(GBeanInstance.java:545)
	at
org.apache.geronimo.kernel.basic.BasicKernel.stopGBean(BasicKernel.java:213)
	at
org.apache.geronimo.kernel.config.ConfigurationManagerImpl$ShutdownHook.run(ConfigurationManagerImpl.java:287)
	at
org.apache.geronimo.kernel.basic.BasicKernel.notifyShutdownHooks(BasicKernel.java:406)
	at
org.apache.geronimo.kernel.basic.BasicKernel.shutdown(BasicKernel.java:383)
	at org.apache.geronimo.system.main.Daemon$1.run(Daemon.java:296)



-- 
View this message in context: http://www.nabble.com/Active-MQ-3.2.1-QueueSender-tf1920777.html#a5274003
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Active MQ 3.2.1 QueueSender

Posted by avin98 <av...@yahoo.com>.
No I don't get any exceptions as such.....Its just that the QueueReceiver
never gets any message from the Queue.
-- 
View this message in context: http://www.nabble.com/Active-MQ-3.2.1-QueueSender-tf1920777.html#a5273735
Sent from the ActiveMQ - User forum at Nabble.com.


Re: Active MQ 3.2.1 QueueSender

Posted by Hiram Chirino <hi...@hiramchirino.com>.
do you get any exceptions?

On 7/10/06, avin98 <av...@yahoo.com> wrote:
>
>
> When you try to send a message to a queue in ActiveMQ 3.2.2 (bundled along
> with geronimo), it doesn't work the first time.
>
> Why is this ??? I faced the same problem with the samples as well, when I
> try to send message from a servlet.
>
> Here is the code snippet that does that:
>
>         QueueSession session = null;
>         QueueSender sender = null;
>         TextMessage message = null;
>         String correlationId = null;
>         QueueConnection connection = null;
>         String connectionFactoryName = "java:comp/env/jms/broker";
>         String queueName = "java:comp/env/jms/queue/OutboundQueue";
>         try {
>
>             InitialContext naming = new InitialContext();
>
>             // lookup queue connection factory
>             QueueConnectionFactory connectionFactory =
> (QueueConnectionFactory) naming
>                 .lookup(connectionFactoryName);
>
>             // create jms connection
>             connection = connectionFactory
>                 .createQueueConnection();
>
>             // System.out.println("Connection is:"+ connection);
>
>             // lookup jms queue
>             Queue queue = (Queue) naming.lookup(queueName);
>
>             // create a session.
>             session = connection.createQueueSession(false,
>                 Session.AUTO_ACKNOWLEDGE);
>
>             // create a QueueSender
>             sender = session.createSender(queue);
>             sender.setDeliveryMode(DeliveryMode.NON_PERSISTENT);
>
>             // create a message to send to the queue...
>             message = session.createTextMessage();
>
>             message.setText(dataStream);
>
>
>             // send
>             sender.send(message);
>
>             // store the messageID as correlationID
>             correlationId = message.getJMSMessageID();
>
>
>
>         } catch (Exception je) {
>             je.printStackTrace();
>
>         } finally {
>             try {
>                 if (sender != null)
>                     sender.close();
>                 if (session != null)
>                     session.close();
>                 if(connection !=null)
>                     connection.close();
>              } catch (JMSException je) {
>                 je.printStackTrace();
>
>             }
>         }
>
> --
> View this message in context:
> http://www.nabble.com/Active-MQ-3.2.1-QueueSender-tf1920777.html#a5259006
> Sent from the ActiveMQ - User forum at Nabble.com.
>
>


-- 
Regards,
Hiram

Blog: http://hiramchirino.com