[
https://issues.apache.org/activemq/browse/AMQ-866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_37873
]
steve cook commented on AMQ-866:
--------------------------------
Same problem with doubles.
This is just a byte order problem - here is a patch for doubles. floats can be
fixed in the same way:
>
> I've found a byte-order problem sending a double from Java ActiveMQ to a
> NMS/CSharp receiver:
>
> (NMS) ActiveMQ.OpenWire.OpenWireBinaryReader has no definition for
> ReadDouble(), and by default calls the MS .NET BinaryReader.ReadDouble()
> which reads the bytes in the wrong order. Here is the fix:
>
> add a new method to OpenWireBinaryReader.cs:
>
> public override double ReadDouble()
> {
> return EndianSupport.SwitchEndian(base.ReadBytes(8));
> }
>
> add a new method to EndianSupport.cs:
>
> public static double SwitchEndian(byte[] bytes)
> {
> //Reverse byte array
> byte[] reverse = new byte[8];
> reverse[0] = bytes[7];
> reverse[1] = bytes[6];
> reverse[2] = bytes[5];
> reverse[3] = bytes[4];
> reverse[4] = bytes[3];
> reverse[5] = bytes[2];
> reverse[6] = bytes[1];
> reverse[7] = bytes[0];
> BinaryReader br = new BinaryReader(new MemoryStream(reverse));
> return br.ReadDouble();
> }
>
> If anyone knows a cleaner way of doing this, please let me know.
>
> thx
> /Steve
> Problem from open wire dotnet send float properties message to java
> -------------------------------------------------------------------
>
> Key: AMQ-866
> URL: https://issues.apache.org/activemq/browse/AMQ-866
> Project: ActiveMQ
> Issue Type: Bug
> Components: NMS (C# client)
> Reporter: Denis Abramov
>
> Am also interested in this issue (from Discussion forum):
> I found a problem while i using open wire dotnet api to send float property
> message to java platform, the value i recieved that is deffrent with the
> value setting in dotnet platform.
> here is send value(dotnet) is: float floatvalue = 2.1F
> recieved value(java) is value is: 1.757237E-26
> is this a bug or i make some mistake in my test?
> follow is my test code:
> dotnet:
> float value= 2.12F;
> Uri uri = new Uri("tcp://" + ip +
> ":61616?jms.useAsyncSend=true");
> factory = new ConnectionFactory(uri);
> using (IConnection connection = factory.CreateConnection())
> {
> ISession session =
> connection.CreateSession(acknowledgementMode);
> IDestination destination = session.GetQueue(queueName);
> IMessageProducer producer =
> session.CreateProducer(destination);
> producer.Persistent = true;
> // lets send a message
> String text = "text";
> ITextMessage request = session.CreateTextMessage(text);
> request.NMSPersistent = true;
> request.NMSCorrelationID = "abc";
>
> request.Properties["custom8"] = custom8;
> producer.Send(request);
> }
> java:
> public void onMessage(Message message) {
> System.out.println(message.getFloatProperty("custom8"));
> }
> could someone do me a favor?
> Thx!
> Matt
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
https://issues.apache.org/activemq/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira