You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@activemq.apache.org by David Birdsall <da...@mxdata.co.uk> on 2006/12/09 22:44:17 UTC

NMS and 4.1.0 problems

Hi there,

I checked out the ActiveMQ-dotnet trunk from:

https://svn.apache.org/repos/asf/incubator/activemq/activemq-dotnet/trunk

Revision 484893 jlim
Last commit revision 477581

And have been having problems with the NMS client and ActiveMQ release
4.1.0.

I can get a connection, but when I try and do anything with it, the code
throws a Null reference exception. I based my code on the example given on
the NMS webpage on the ActiveMQ website:

IConnectionFactory factory = new ConnectionFactory(new
Uri("tcp://serendipity:61616"));
using (IConnection connection = factory.CreateConnection())
{
  connection.ExceptionListener += new
ExceptionListener(connection_ExceptionListener);
  ISession session = connection.CreateSession();
}
...

I've configured everything up as follows:

    <transportConnectors>
       <transportConnector name="openwire" uri="tcp://serendipity:61616"/>
       <transportConnector name="stomp"    uri="stomp://serendipity:61613"/>
    </transportConnectors>

The example java consumer and producers work fine, so I am guessing there's
some problem with the C# code, unless I am doing something wrong?

I've tried changing the url from "serendipity" to "localhost" in both client
and configuration, but the problem still remains.

There seems to be a problem in TcpTransport.ReadLoop caused by a NULL_TYPE
being read inside OpenWireFormat.Unmarshal, because the first two commands
(dataTypes = 1, 2) are unmarshalled:

{WireFormatInfo[ Magic=System.Byte[] Version=2
MarshalledProperties={StackTraceEnabled=True, MaxInactivityDuration=30000,
CacheSize=1024, TcpNoDelayEnabled=True, TightEncodingEnabled=True,
SizePrefixDisabled=False, CacheEnabled=True} ]}
{BrokerInfo[ BrokerId=BrokerId[ Value=ID:serendipity-1439-1165697313562-1:0
] BrokerURL=tcp://serendipity:61616
PeerBrokerInfos=ActiveMQ.Commands.BrokerInfo[] BrokerName=localhost
SlaveBroker=False MasterBroker=False FaultTolerantConfiguration=False
DuplexConnection=False NetworkConnection=False ]}

But on the 3rd iteration, it reads a NULL_TYPE and then throws with a null
Command.

I did notice the "NetworkConnection=False" in the second command - am I
doing something wrong with my configuration? And if so, how come the example
java consumer and producers work okay with my installation.

The java examples both work when ActiveMQ is run as a Windows service and
from the batch file.

Another slight problem I had - the Service Wrapper "wrapper.jar" wasn't
included in the 4.1.0 binary distribution I downloaded, so I had to download
it separately from TanukiSoftware's website.

Many thanks for your time and help, I'm looking forward to using ActiveMQ
once I can get NMS working :-)

David Birdsall
Software Engineer
mxData Ltd
david.birdsall@mxdata.co.uk
-- 
View this message in context: http://www.nabble.com/NMS-and-4.1.0-problems-tf2787347.html#a7776760
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: NMS and 4.1.0 problems

Posted by JanV <ja...@vrxstudios.com>.
Here is some more info. Running TestMain demo code for NMS with added
ConnectionException handler. 
--------------------
                IConnectionFactory factory = new ConnectionFactory(new
Uri("tcp://localhost:61616"));
                using (IConnection connection = factory.CreateConnection())
                {
                    Console.WriteLine("Created a connection!");

                    connection.ExceptionListener += new
ExceptionListener(connection_ExceptionListener);

                    ISession session = connection.CreateSession();
---------------------
        static void connection_ExceptionListener(Exception exception)
        {
            Console.WriteLine("Exception Message: " + exception.Message);
            Console.WriteLine("Exception Stack: " + exception.StackTrace);
        }
--------------------------------

Running AMQ Broker 4.0.2. Following two exceptions seem to alternate in no
particular order. (This version runs the full course and exits).

About to connect to ActiveMQ
Created a connection!
Using destination: FOO.BAR
Received message with ID:   61ebf54e-f07c-4598-b8e9-18bb629ba45d:1:1:1
Received message with text: Hello World!
Exception Message: Unable to read beyond the end of the stream.
Exception Stack:    at System.IO.__Error.EndOfFile()
   at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
   at System.IO.BinaryReader.ReadInt32()
   at ActiveMQ.OpenWire.OpenWireBinaryReader.ReadInt32() in
D:\activemq-dotnet\s
rc\main\csharp\ActiveMQ\OpenWire\OpenWireBinaryReader.cs:line 132
   at ActiveMQ.OpenWire.OpenWireFormat.Unmarshal(BinaryReader dis) in
D:\activem
q-dotnet\src\main\csharp\ActiveMQ\OpenWire\OpenWireFormat.cs:line 157
   at ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop() in
D:\activemq-dotnet\src\m
ain\csharp\ActiveMQ\Transport\Tcp\TcpTransport.cs:line 131

About to connect to ActiveMQ
Created a connection!
Using destination: FOO.BAR
Received message with ID:   414aea76-0b1f-43a1-b078-bab35937c475:1:1:1
Received message with text: Hello World!
Exception Message: Object reference not set to an instance of an object.
Exception Stack:    at
ActiveMQ.Transport.WireFormatNegotiator.OnCommand(ITransp
ort sender, Command command) in
D:\activemq-dotnet\src\main\csharp\ActiveMQ\Tran
sport\WireFormatNegotiator.cs:line 75
   at ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop() in
D:\activemq-dotnet\src\m
ain\csharp\ActiveMQ\Transport\Tcp\TcpTransport.cs:line 146


Now the latest release. Running AMQ Broker 4.1.0 and the TestMain demo code
for NMS. (This version hangs at the ISession session =
connection.CreateSession() statement in TestMain).

About to connect to ActiveMQ
Created a connection!
Exception Message: Object reference not set to an instance of an object.
Exception Stack:    at
ActiveMQ.Transport.WireFormatNegotiator.OnCommand(ITransp
ort sender, Command command) in
D:\activemq-dotnet\src\main\csharp\ActiveMQ\Tran
sport\WireFormatNegotiator.cs:line 75
   at ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop() in
D:\activemq-dotnet\src\m
ain\csharp\ActiveMQ\Transport\Tcp\TcpTransport.cs:line 146
Exception Message: Object reference not set to an instance of an object.
Exception Stack:    at
ActiveMQ.Transport.WireFormatNegotiator.OnCommand(ITransp
ort sender, Command command) in
D:\activemq-dotnet\src\main\csharp\ActiveMQ\Tran
sport\WireFormatNegotiator.cs:line 75
   at ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop() in
D:\activemq-dotnet\src\m
ain\csharp\ActiveMQ\Transport\Tcp\TcpTransport.cs:line 146
Exception Message: Object reference not set to an instance of an object.
Exception Stack:    at
ActiveMQ.Transport.WireFormatNegotiator.OnCommand(ITransp
ort sender, Command command) in
D:\activemq-dotnet\src\main\csharp\ActiveMQ\Tran
sport\WireFormatNegotiator.cs:line 75
   at ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop() in
D:\activemq-dotnet\src\m
ain\csharp\ActiveMQ\Transport\Tcp\TcpTransport.cs:line 146
Exception Message: Object reference not set to an instance of an object.
Exception Stack:    at
ActiveMQ.Transport.WireFormatNegotiator.OnCommand(ITransp
ort sender, Command command) in
D:\activemq-dotnet\src\main\csharp\ActiveMQ\Tran
sport\WireFormatNegotiator.cs:line 75
   at ActiveMQ.Transport.Tcp.TcpTransport.ReadLoop() in
D:\activemq-dotnet\src\m
ain\csharp\ActiveMQ\Transport\Tcp\TcpTransport.cs:line 146



-- 
View this message in context: http://www.nabble.com/NMS-and-4.1.0-problems-tf2787347.html#a8165515
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: NMS and 4.1.0 problems

Posted by JanV <ja...@vrxstudios.com>.
I am having the same problem here using the demo/test code.
   // START SNIPPET: demo
     IConnectionFactory factory = new ConnectionFactory(new
Uri("tcp://localhost:61616"));
     using (IConnection connection = factory.CreateConnection())
     {
           Console.WriteLine("Created a connection!");
                  
           ISession session = connection.CreateSession();             //<---
hangs here.

I tracked it down to the ResponseCorrelator

        public override Response Request(Command command)
        {
            FutureResponse future = AsyncRequest(command);  // <-- this
returns a null in the response (probably as per the unmarshalling problem
David mentioned.
            Response response = future.Response;                    // <--
and so this blocks indefinately



I am currently using NMS C# client revision 492630. Windows XP SP2. The same
issue occurs on Release 4.1.0, and the following SNAPSHOTS that I've tried
apache-activemq-4.1-incubator-20070103.004543-24,
apache-activemq-4.2-incubator-20061204.023752-14

The code doesnt really crash, so there is no stack trace for the issue,
however I do have some 'System.NullReferenceException' messages in my
output. Here is how it looks:

'activemq-test.vshost.exe' (Managed): Loaded
'D:\activemq-dotnet\bin\Debug\activemq-test.exe', Symbols loaded.
'activemq-test.vshost.exe' (Managed): Loaded
'D:\activemq-dotnet\bin\Debug\nms.dll', Symbols loaded.
'activemq-test.vshost.exe' (Managed): Loaded
'D:\activemq-dotnet\bin\Debug\activemq.dll', Symbols loaded.
'activemq-test.vshost.exe' (Managed): Loaded
'C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll',
Skipped loading symbols. Module is optimized and the debugger option 'Just
My Code' is enabled.
A first chance exception of type 'System.NullReferenceException' occurred in
activemq.dll
A first chance exception of type 'System.NullReferenceException' occurred in
activemq.dll
A first chance exception of type 'System.NullReferenceException' occurred in
activemq.dll
A first chance exception of type 'System.NullReferenceException' occurred in
activemq.dll


Here is my ActiveMQ broker output:
ACTIVEMQ_HOME: D:\apache-activemq-4.1.0-incubator\bin\..
Loading message broker from: xbean:activemq.xml
INFO  BrokerService                  - ActiveMQ 4.1.0-incubator JMS Message
Broker (localhost) is starting
INFO  BrokerService                  - For help or more information please
see: http://incubator.apache.org/activemq/
INFO  ManagementContext              - JMX consoles can connect to
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
INFO  JDBCPersistenceAdapter         - Database driver recognized:
[apache_derby_embedded_jdbc_driver]
INFO  DefaultDatabaseLocker          - Attempting to acquire the exclusive
lock to become the Master broker
INFO  DefaultDatabaseLocker          - Becoming the master on dataSource:
org.apache.derby.jdbc.EmbeddedDataSource@11a5f
d0
INFO  TransportServerThreadSupport   - Listening for connections at:
tcp://tech2:61616
INFO  TransportConnector             - Connector openwire Started
INFO  BrokerService                  - ActiveMQ JMS Message Broker
(localhost, ID:tech2-1497-1167935001787-1:0) started


As per David's suggestion 4.0.2 worked. It did produce the following two
messages in the output:
A first chance exception of type 'System.IO.IOException' occurred in
System.dll
A first chance exception of type 'System.NullReferenceException' occurred in
activemq.dll






-- 
View this message in context: http://www.nabble.com/NMS-and-4.1.0-problems-tf2787347.html#a8164763
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: NMS and 4.1.0 problems

Posted by David Birdsall <da...@mxdata.co.uk>.
Hi,

I've just tried running the NMS client with release 4.0.2, and it works
fine. OpenWireFormat.cs returns 1,2,30 from ReadByte() in the
TcpTransport.ReadLoop(), whereas before it was returning 1,2,0 where the 0
was causing the null command reference.

public Object Unmarshal(BinaryReader dis)
        {
            // lets ignore the size of the packet
			if( !sizePrefixDisabled ) {
				dis.ReadInt32();
			}
            
            // first byte is the type of the packet
            byte dataType = dis.ReadByte(); <-- the 1,2,30 / 1,2,0 problem
was found here
            if (dataType != NULL_TYPE)
            {
...

I will switch to using 4.0.2 for now.

Many thanks,
David
-- 
View this message in context: http://www.nabble.com/NMS-and-4.1.0-problems-tf2787347.html#a7831238
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: NMS and 4.1.0 problems

Posted by David Birdsall <da...@mxdata.co.uk>.
I've tried running 4.1.0 at work, using revision 484893 of NMS, and this is
the stack trace of ActiveMQ:

ACTIVEMQ_HOME: C:\testes\apache-activemq-4.1.0-incubator\bin\..
Loading message broker from: xbean:activemq.xml
INFO  BrokerService                  - ActiveMQ 4.1.0-incubator JMS Message
Broker (localhost) is starting
INFO  BrokerService                  - For help or more information please
see: http://incubator.apache.org/activemq/
INFO  ManagementContext              - JMX consoles can connect to
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
INFO  JDBCPersistenceAdapter         - Database driver recognized:
[apache_derby_embedded_jdbc_driver]
INFO  DefaultDatabaseLocker          - Attempting to acquire the exclusive
lock to become the Master broker
INFO  DefaultDatabaseLocker          - Becoming the master on dataSource:
org.apache.derby.jdbc.EmbeddedDataSource@1a3aa2c
INFO  JournalPersistenceAdapter      - Journal Recovery Started from: Active
Journal: using 5 x 20.0 Megs at:
C:\test\apache-activemq-4.1.0-incubator\activemq-data\journal
INFO  JournalPersistenceAdapter      - Journal Recovered: 0 message(s) in
transactions recovered.
INFO  TransportServerThreadSupport   - Listening for connections at:
tcp://MXDATA-09:61616?trace=true
INFO  TransportConnector             - Connector openwire Started
INFO  BrokerService                  - ActiveMQ JMS Message Broker
(localhost, ID:MXDATA-09-1935-1165920577980-1:0) started

There doesn't appear to be a stack trace?

I originally thought my problem may have been related to issue AMQ-991, but
there doesn't appear to be any exceptions thrown by the server.

..?
-- 
View this message in context: http://www.nabble.com/NMS-and-4.1.0-problems-tf2787347.html#a7830978
Sent from the ActiveMQ - User mailing list archive at Nabble.com.


Re: NMS and 4.1.0 problems

Posted by James Strachan <ja...@gmail.com>.
On 12/9/06, David Birdsall <da...@mxdata.co.uk> wrote:
>
> Hi there,
>
> I checked out the ActiveMQ-dotnet trunk from:
>
> https://svn.apache.org/repos/asf/incubator/activemq/activemq-dotnet/trunk
>
> Revision 484893 jlim
> Last commit revision 477581
>
> And have been having problems with the NMS client and ActiveMQ release
> 4.1.0.
>
> I can get a connection, but when I try and do anything with it, the code
> throws a Null reference exception.

Could you give us a stack trace?

-- 

James
-------
http://radio.weblogs.com/0112098/

Re: NMS and 4.1.0 problems

Posted by David Birdsall <da...@mxdata.co.uk>.
I've also checked the state in jconsole, and the connection is Active, not
Blocked, and Connected. I've also tested with my firewall switched off, and
it still has the same problem.
-- 
View this message in context: http://www.nabble.com/NMS-and-4.1.0-problems-tf2787347.html#a7776915
Sent from the ActiveMQ - User mailing list archive at Nabble.com.